Friday 12 August 2011

JDK7 with JBoss 5.1

I've been doing some blogging recently for C2B2 the company I work covering the use of Google App Engine and auto scalability in 3 parts. Part 1 provided a quick run through of setting up a REST application in Google App Engine, Part 2 described basic testing and what monitoring was available and Part 3 used JAXB to serialize a person so we could chart load to response time. Anyway it's got me back into some blogging so I thought I would have a quick look at JDK 7.

For a trivial start I wonder if it worked with my existing JBoss 5.1 install and it does...kind of.

I installed just the JDK 7 x64 release on Windows 7 and updates the system variables as below

PATH=C:\Apps\Java\jdk1.7.0\bin
JAVA_HOME=C:\Apps\Java\jdk1.7.0

I went into my JBoss 5.1 bin directory and tried to start it...no go.

Calling C:\Apps\jboss-eap-5.1\jboss-as\bin\run.conf.bat
===============================================================================

JBoss Bootstrap Environment

JBOSS_HOME: C:\Apps\jboss-eap-5.1\jboss-as

JAVA: C:\Apps\Java\jdk1.7.0\bin\java

JAVA_OPTS: -Xms768m -Xmx768m -XX:MaxPermSize=256m -Dorg.jboss.resolver.warning=true -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcI
nterval=3600000 -Dsun.lang.ClassLoader.allowArraySyntax=true -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 -Dorg.jbo
ss.resolver.warning=true -Dprogram.name=run.bat -server

CLASSPATH: C:\Apps\Java\jdk1.7.0\lib\tools.jar;C:\Apps\jboss-eap-5.1\jboss-as\bin\run.jar

===============================================================================

Exception in thread "main" java.lang.NoClassDefFoundError: org/jboss/bootstrap/BaseServerConfig
at org.jboss.bootstrap.AbstractServerImpl.doInit(AbstractServerImpl.java:190)
at org.jboss.bootstrap.AbstractServerImpl.init(AbstractServerImpl.java:173)
at org.jboss.bootstrap.AbstractServerImpl.init(AbstractServerImpl.java:143)
at org.jboss.Main.boot(Main.java:218)
at org.jboss.Main$1.run(Main.java:556)
at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.ClassNotFoundException: org.jboss.bootstrap.BaseServerConfig
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
... 6 more
Press any key to continue . . .

So I tried setting the JAVA_HOME back to a 1.6 using:

set JAVA_HOME=C:\Apps\Java\jdk1.6.0_22 and tried again.

This time everything works perfectly.

C:\Apps\jboss-eap-5.1\jboss-as\bin>run
Calling C:\Apps\jboss-eap-5.1\jboss-as\bin\run.conf.bat
===============================================================================

JBoss Bootstrap Environment

JBOSS_HOME: C:\Apps\jboss-eap-5.1\jboss-as

JAVA: C:\Apps\Java\jdk1.6.0_22\bin\java

JAVA_OPTS: -Xms768m -Xmx768m -XX:MaxPermSize=256m -Dorg.jboss.resolver.warning=true -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcI
nterval=3600000 -Dsun.lang.ClassLoader.allowArraySyntax=true -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 -Dorg.jbo
ss.resolver.warning=true -Dprogram.name=run.bat -server

CLASSPATH: C:\Apps\Java\jdk1.6.0_22\lib\tools.jar;C:\Apps\jboss-eap-5.1\jboss-as\bin\run.jar

===============================================================================

14:39:39,788 INFO [ServerImpl] Starting JBoss (Microcontainer)...
14:39:39,791 INFO [ServerImpl] Release ID: JBoss [EAP] 5.1.0 (build: SVNTag=JBPAPP_5_1_0 date=201009150028)
14:39:39,794 INFO [ServerImpl] Bootstrap URL: null
14:39:39,796 INFO [ServerImpl] Home Dir: C:\Apps\jboss-eap-5.1\jboss-as
14:39:39,797 INFO [ServerImpl] Home URL: file:/C:/Apps/jboss-eap-5.1/jboss-as/
14:39:39,799 INFO [ServerImpl] Library URL: file:/C:/Apps/jboss-eap-5.1/jboss-as/lib/
14:39:39,803 INFO [ServerImpl] Patch URL: null
14:39:39,804 INFO [ServerImpl] Common Base URL: file:/C:/Apps/jboss-eap-5.1/jboss-as/common/
14:39:39,806 INFO [ServerImpl] Common Library URL: file:/C:/Apps/jboss-eap-5.1/jboss-as/common/lib/
14:39:39,808 INFO [ServerImpl] Server Name: default
14:39:39,810 INFO [ServerImpl] Server Base Dir: C:\Apps\jboss-eap-5.1\jboss-as\server
14:39:39,815 INFO [ServerImpl] Server Base URL: file:/C:/Apps/jboss-eap-5.1/jboss-as/server/
14:39:39,816 INFO [ServerImpl] Server Config URL: file:/C:/Apps/jboss-eap-5.1/jboss-as/server/default/conf/
14:39:39,818 INFO [ServerImpl] Server Home Dir: C:\Apps\jboss-eap-5.1\jboss-as\server\default
14:39:39,819 INFO [ServerImpl] Server Home URL: file:/C:/Apps/jboss-eap-5.1/jboss-as/server/default/
14:39:39,821 INFO [ServerImpl] Server Data Dir: C:\Apps\jboss-eap-5.1\jboss-as\server\default\data
14:39:39,822 INFO [ServerImpl] Server Library URL: file:/C:/Apps/jboss-eap-5.1/jboss-as/server/default/lib/
14:39:39,823 INFO [ServerImpl] Server Log Dir: C:\Apps\jboss-eap-5.1\jboss-as\server\default\log

Now if you look at http://www.jboss.com/products/platforms/application/supportedconfigurations/ you'll see that JDK 7 isn't a supported configuration so it many ways it's no surprise but it sure is odd. I havent understood yet why it is but I'll come back here to add a note when I do.

I had to try this again with JBoss 5.1 GA on another computer also Win 7 x64. Previously I'd been using JBoss EAP on Win x64. This time it worked first time with JAVA_HOME still pointing at C:\Apps\Java\jdk1.6.0_23 (I have them setup with the same paths) and a java -version command reporting

java version "1.7.0"
Java(TM) SE Runtime Environment (build 1.7.0-b147)
Java HotSpot(TM) 64-Bit Server VM (build 21.0-b17, mixed mode)


I wonder if is because I used EAP before?

So I returned to my laptop and copied the JBoss GA release to it. Set it as below

PATH=C:\Apps\Java\jdk1.7.0\bin
JAVA_HOME=C:\Apps\Java\jdk1.7.0

Tried starting JBoss and it worked fine. So must be either something to do with the JBoss EAP configuration or perhaps because I'd had that install there for a while I had payed with its config to break it under JDK 7. So to get to the bottom of it I needed to get a clean copy of EAP and try again. Of course all this investigation for an unsupported configuration isn't really worth it but I hate not knowing.

OK so I find a clean copy of jboss-eap-5.1 unzip and try to start it and it wont start. jboss-5.1.0.GA will, EAP won't. So I guess its down to either differences in the start-up scripts of the supported and community editions or the packaging of the classes into the jars.

So what's my takeaway from all this? Beware the small differences between the community and supported versions!

I'm going to look at the new fork/join support in JDK 7 next...far more sensible.

Pete Raymond