amqp-client for Java 1.7 RuntimeEnvironment

179 views
Skip to first unread message

Hasan Emre Arguden

unread,
Nov 19, 2018, 3:51:16 AM11/19/18
to rabbitmq-users
Hello everyone,

Our application server. is : Oracle GlassFish Server 3.1.2.2 (build 5), java 1.7 Running.
                 Erlang version : erlang-21.0.6
            RabbitMq version : rabbitmq-server-3.7.8

From the official rabbitMq website ,it says "4.x release series support JDK 6 ". So I get, amqp-client 4.9.0, to put in my application to deploy on Glassfish. But the error get during deployment basically says I need java 8 to run the com/rabbitmq/client/Consumer class(which belongs to amqp-client supposed to compatible with java 7)

Error log : 
WARNING|oracle-glassfish3.1.2|javax.enterprise.system.container.web.com.sun.enterprise.web|_ThreadID=1183;_ThreadName=Thread-2;|java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: java.lang.UnsupportedClassVersionError: com/rabbitmq/client/Consumer : Unsupported major.minor version 52.0
java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: java.lang.UnsupportedClassVersionError: com/rabbitmq/client/Consumer : Unsupported major.minor version 52.0

     -     I realize that amqp-client 4.9.0 that I download from mvnrepository is compiled with jdk 1.8.

     -     So I checkout the source code of amqp-client to build the code(release 4.9.0) with java 7, this time I get compile error saying that ToDoubleFunctions.class(a jdk 1.8 class) not found in java.util

Error log:
.../src/main/java/com/rabbitmq/client/impl/MicrometerMetricsCollector.java:[160,32] cannot access java.util.function.ToDoubleFunction
  class file for java.util.function.ToDoubleFunction not found 

         My question is how 4.x releases are compatible with java 7, if so how can I fix my problem to Run a rabbitmqClient on my application server?

Thanks for reading this long:)

Arnaud Cogoluègnes

unread,
Nov 19, 2018, 4:44:15 AM11/19/18
to rabbitm...@googlegroups.com
I just gave Java client 4.9.0 a try with Zulu 7.0.201 and it worked
fine. The Java client is indeed released with JDK 8, but using
cross-compilation options [1] targeting Java 1.6.

You can unfold the first tutorial [2] with updated dependencies to dig further.

I suspect a higher version being actually on the classpath, but this
is just a guess.

I'm not sure it's worth trying to build on JDK 7 as the build may not
be compatible (we've been using JDK 8 to build this library for years
now). And distributing the library will be a pain anyway.

[1] https://github.com/rabbitmq/rabbitmq-java-client/blob/415060ba2ff97fa677621da95678342fbe869f93/pom.xml#L863-L864
[2] http://www.rabbitmq.com/tutorials/tutorial-one-java.html
> --
> You received this message because you are subscribed to the Google Groups "rabbitmq-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-user...@googlegroups.com.
> To post to this group, send email to rabbitm...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Hasan Emre Arguden

unread,
Nov 19, 2018, 9:12:58 AM11/19/18
to rabbitmq-users
Thank you for your help, but my problem still continues.

Actually I've tried both of your suggestions before writing here.
 - Rabbitmq tutorial says me to use amqp-client 4.x for JDK 6 compatibility(I used that version but it is compiled with JDK8 and got runTimeError)
 - I run that pom.xml of 4.x source code.(Got compilation error since source code has JDK 8 library dependency)

Source code has dependency to ToDoubleFunctions which is released after java 8. So it is not possible to compile with lower version.

And you also confirm that 4.9.0 released with JDK 8. Is Zulu can actually manage to run JDK 8 jar on JRE 7 environment? As far as I know it is not possible.

Arnaud Cogoluègnes

unread,
Nov 19, 2018, 9:44:33 AM11/19/18
to rabbitm...@googlegroups.com
I'm just trying to narrow down what the problem is. Please provide
more about your environment and some steps to reproduce the issue.

Here are the steps I used to confirm Java client 4.9.0 works on the
JDK 7 I have:
- in some directory, create a Send.java file with the content from [1]
- add System.out.println(System.getProperty("java.version")); to the
beginning of the main method
- start a RabbitMQ node on the local machine with the default

Then run the following commands in this directory (I added the output
from my laptop when relevant):
$ wget http://central.maven.org/maven2/com/rabbitmq/amqp-client/4.9.0/amqp-client-4.9.0.jar
$ wget http://central.maven.org/maven2/org/slf4j/slf4j-api/1.7.25/slf4j-api-1.7.25.jar
$ wget http://central.maven.org/maven2/org/slf4j/slf4j-simple/1.7.25/slf4j-simple-1.7.25.jar
$ java -version
openjdk version "1.7.0_201"
OpenJDK Runtime Environment (Zulu 7.25.0.5-linux64) (build 1.7.0_201-b02)
OpenJDK 64-Bit Server VM (Zulu 7.25.0.5-linux64) (build 24.201-b02, mixed mode)
$ javac -cp amqp-client-4.9.0.jar Send.java
$ java -cp .:amqp-client-4.9.0.jar:slf4j-api-1.7.25.jar:slf4j-simple-1.7.25.jar
Send
1.7.0_201
[x] Sent 'Hello World!'


[1] https://raw.githubusercontent.com/rabbitmq/rabbitmq-tutorials/master/java/Send.java

Hasan Emre Arguden

unread,
Nov 22, 2018, 8:23:43 AM11/22/18
to rabbitmq-users
I tried to run my code as you suggested(with "java -cp.." command). Surprisingly it actually worked.

When it comes to deploy my code as a ".war" package to Glassfish 3.1.2, it again throws "Unsupported major.minor version 52.0"

I had to change $JAVA_HOME to jre_1.8 from jre_1.7 for glassfish, and it seem problem is solved that way.(Though I have to test other modules if they still works properly with new JRE)

My own conclusion for the case is that, amqp-client_4.9.0 is actually Java 1.6(or 1.7) compatible, as official web site implies. But glassfish detects that amqp-client jar is compiled with jdk 1.8(as it is) and decides not to run the application, although jre 6 or jre7 is enough for the app. And there is no amqp-client jar compiled with 1.6 or 1.7 available on the web.
As I said this is my thought, can be wrong.

Thanks for your help Arnaud

Arnaud Cogoluègnes

unread,
Nov 22, 2018, 9:12:10 AM11/22/18
to rabbitm...@googlegroups.com
Thanks for letting us know. Out of curiosity, have you checked the WAR
file does actually contain AMQP client 4.9.0, and not a 5.x version
(because of some dependency that would pull this version)?

Hasan Emre Arguden

unread,
Nov 23, 2018, 2:07:42 AM11/23/18
to rabbitmq-users
Yes it is 4.9.0.jar, in my WAR file.
Reply all
Reply to author
Forward
0 new messages