26/06/2015

[TIBCO] BusinessWorks 6 Compress Plugin for ZIP

UPDATE: check latest version 1.2.0.FINAL here

Happy to announce the availability of the 1.0.0.FINAL version of the TIBCO BW6 Compress palette. It includes Zip and Unzip activities. This is developed in my free time and it's not endorsed, verified or supported by TIBCO in any way (yet?).

It uses Apache Common Compress library 1.8.1 with no modifications and it's packaged within the plugin.

[PostgreSQL] Post install error "Password authentication failed for user" when connecting to DB

So you decided that MySQL isn't to your liking and since the other alternatives aren't free enough, you tried out PostgreSQL. Freshly after your installation, you happily try to connect to your DB either via command line (\q guys.. \q seriously?) or pgAdmin, but are baffled when this message appears on screen:

FATAL:  Password authentication failed for user "Administrator"

because you did not remember creating a user during installation, and the only password you were asked to define isn't working.

The solution? Try to connect as postgres user:

psql -U postgres

If it's still not working, check under postgresql.conf if the listen_addresses parameter is specifying a correct and reachable address.

[SQL] Oracle subquery in join statement

In Oracle, it's possible to use sub queries in a join statement by giving an alias to the subquery and joining on that alias:

SELECT a.column1, a.column2, c.column3
FROM a JOIN (
SELECT b.column1, b.column2, b.column3
FROM b
) c
ON (a.column1 = c.column1 AND a.column2 = c.column2)

Obviously you would never write a SIMPLE query EXACTLY as the example above, it's just to show the mechanics when you actually need to create a slightly more complex one

06/06/2015

[OSGi] Spring error Unable to locate Spring NamespaceHandler for XML schema namespace

You're working with OSGi because it's flexible, you like components, and so on, and you also like Spring because you love writing XMLs instead of Java code.

You think it would be a good idea if you could join these technologies but reading is so boring, plus since both use some config files you just need to mash them together and you should be good with your Sprosgienstein creation. But then you realize that some small differences for example in classpath handling and dependency management are making your life difficult.

A common error you might get is: "Unable to locate Spring NamespaceHandler for XML schema namespace XXX"

22/05/2015

[Windows Server 2012] Add role fails

When trying to add a role (eg ActiveDirectory) to a Windows Server 2012 machine, I found that it would try to enable the components, but it would always fail in the end saying that the machine needed a reboot. It doesn't matter how many reboots you do, it will still fail.

The reason was that these services had to be enabled before trying to add the new role:


  • Server
  • Workstation
  • Computer Browser
  • TCP/IP NetBIOS Helper

[Linux] Check remote port connection

It may happen that you're working on a server with a user that has very limited capabilities. Sometimes you have no access to telnet:

telnet host port

nmap:

nmap -A host -p port

curl - it will complain that it did not receive data, meaning that it connected successfully:

curl http://host:port

netcat:

nc host port

 or whatever other tool you like to use. So what to do? Well maybe, you have access to bash:

cat < /dev/tcp/host/port

but I find this method not very reliable. Instead you might have access to Python as well:

python
import socket
test_conn=socket.create_connection(('host',port))

12/04/2015

[Java] JMX connection and bean operation invocation

In this example we'll see how to create a JMX connection, with or without authentication, and invoke a bean method.

 import javax.management.remote.JMXServiceURL;  
 import javax.management.MBeanAttributeInfo;  
 import javax.management.MBeanInfo;  
 import javax.management.MBeanServerConnection;  
 import javax.management.ObjectName;  
 import javax.management.remote.JMXConnector;  
 import javax.management.remote.JMXConnectorFactory;  
 import java.util.Hashtable;  
   
 public class myJMXConnection{  
   
   private static String HOST = "HOST";  
   private static String PORT = "PORT"; //usually it's 1099  
   private static String BEAN_NAME = "BEAN_NAME"; //com.groglogs.myclass:type=MyObject  
   private static String BEAN_OP = "BEAN_OPERATION";  
   private static String USER = "USERNAME";  
   private static String PASS = "PASSWORD";  
   
      public static void main(String[] args) throws Exception{  
   
   try{  
        
           JMXServiceURL target = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://" + HOST + ":" + PORT+"/jmxrmi");  
           //only if authentication is required  
           Hashtable<String, String[]> env = new Hashtable<String, String[]>();  
           String[] credentials = new String[] {USER,PASS};  
           env.put(JMXConnector.CREDENTIALS, credentials);   
     JMXConnector connector = JMXConnectorFactory.connect(target, env);  
     //if not required, use simply JMXConnector connector = JMXConnectorFactory.connect(target);  
     MBeanServerConnection remote = connector.getMBeanServerConnection();  
     ObjectName bean = new ObjectName(BEAN_NAME);  
     remote.invoke(bean, BEAN_OP, null, null);//invoke the remote method. Ensure first that the user calling this method has the necessary rights to invoke it!  
   
     connector.close();  
   
   }catch(Exception e){  
   
     System.out.println(e.getMessage());  
   
     System.exit(0);  
   
      }  
   }  
 }  
   

An important thing to note, is to always remember to check first if the user calling the method has the required permissions to invoke it