Tuesday, May 27, 2014

JRebel rocks

Recently I used JRebel to do hot deployment of a complicated Web application on BEA WebLogic 12. I found it is very easy to setup and give me a great improvement in web development. I can see the result of my Java or xhtml code changes on the website in a flash. Here is a summary of what I did to enable JRebel with WebLogic and Eclipse:
1. Download JRebel plugin for Eclipse, validate with a license.
2. Enable the Eclipse projects with JRebel by "Add JRebel Nature".
3. Check the auto generated rebel.xml file for each java project to make sure the monitored target directories are correct. Only thing I needed to change is the Web directory since we didn't put our web stuff under default WebContent directory.
4. Build the war file as usual to the deployment directory.
5. Add jrebel.jar to the weblogic domain home directory.  Add this to the startWebLogic.cmd file:
Add -javaagent:%DOMAIN_HOME%\jrebel.jar -Drebel.remoting_plugin=false to the `set SAVE_JAVA_OPTIONS=` line.
6.  Start the Weblogic server and you should see the projects' target directories are monitored by JRebel for changes now.

Here is how it works behind the scene:
JRebel will monitor and detect changes in the target directories for compiled Java files or copied over web based files. Eclipse is moving the changes from source to target directories (compile or copy). Weblogic will allow JRebel to hot swap the files whether it is a Java class, or Xhtml or a properties file.

Combining JReble with Eclipse remote debugging, the Web development and debugging just becomes really easy!

Tuesday, May 13, 2014

Q&A for Activemq JMX connection issue (permission exception) using AnyConnect VPN

After connected to VPN using Cisco Any connect client pgm, I found Java program will have connection issue when accessing the JMX service hosted by Activemq on the same machine(localhost). Permission exception is thrown when trying to connect to the JMX rmi service. The IP address bound to the JMX is an IP address assigned by VPN.

I found the root cause is the JMX stub can not be reached when the service is bound to the IP address assigned by VPN. This IP is behind the NAT and permission exception is thrown when trying to be reached. The workaround is to force bind the JMX server to the public/accessible IP address. When running services locally, adding JVM option ”-Djava.rmi.server.hostname=” to the startup scripts will solve the issue.