Search code examples
xpagesactivemq-classiclotus-dominodomino-designer-eclipse

Getting UnsupportedClassVersionError when using third-party Java library


In my XPages project I want to use a third-party Java library called ActiveMQ. In the Domino Designer I add the jar file containing all the classes to the build path. Using the classes in my own Java code (not Java agent) works and I can build the XPages application without any errors.

However, when I try to run my Java functions on a XPage I get an UnsupportedClassVersionError:

java.lang.UnsupportedClassVersionError: JVMCFRE003 bad major version; Class=org/apache/activemq/ActiveMQSslConnectionFactory, Offset=6

followed by a NoClassDefFoundError:

java.lang.NoClassDefFoundError: org/apache/activemq/ActiveMQSslConnectionFactory

which is probably just a subsequent error occuring due to the first one (correct me if I'm wrong).

The UnsupportedClassVersionError suggests that the third-party library has been built with a higher Java version than what is used on the Domino server (Domino 9.0.1 FP4). Executing System.getProperty("java.version") returns 1.6.0 (= Java 6). According to the release notes the third-party Java library (ActiveMQ 5.8.0) has been "compiled with jdk6 and validated with jdk7".

Can anybody tell me why I get this error even though the library has been built with the same Java version that I use to run my code?


PS: Executing java -version in the server computer's command line returns Java version 1.7.0 because an additional JRE7 has been installed on that computer. Yet, the version that "should" matter for the execution on a XPage is the version of the Domino JVM (which is 1.6.0). Still I wanted to mention that...


Solution

  • Domino up to 9.0.1 uses the JVM 1.6 (or 6.0 depending how you count). An upgrade to Java 1.8 (8.0) is expected for the next releases later this year.

    To use ActiveMQ with a JVM 1.6 you need to stick to versions up to 5.10, which you can download from the archive pages (or Maven).

    Let us know how it goes