Error while publishing Java 7 - Java 7 vs Java 8

Asked

Viewed 139 times

1

I rented a VPS server and when trying to connect my android application with Java EE, I received the following message:

type Exception report

message app/server/CSelerServer : Unsupported major.minor version 52.0 (unable to load class app.server.CSelerServer)

description The server encountered an internal error that prevented it from fulfilling this request.

exception

java.lang.UnsupportedClassVersionError: app/server/CSelerServer : Unsupported major.minor version 52.0 (unable to load class app.server.CSelerServer)
    org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2899)
    org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1173)
    org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1681)
    org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
    org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:491)
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
    org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
    org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
    org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1023)
    org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
    org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
    java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    java.lang.Thread.run(Thread.java:745)

note The full stack trace of the root cause is available in the Apache Tomcat/7.0.42 logs.

On the server, I have the WHM/Cpanel CENTOS 6.8 x86_64 Virtuozzo and use the Apache Tomcat as application server. In the project the client side (desktop and mobile) and server side I am using JDK 1.8.

I noticed that the server Tomcat is using JVM 1.7.0

I found two articles that say Centos/Tomcat does not support Java 1.8

https://blog.cpanel.com/tomcat-support-in-centos-7/

https://forums.cpanel.net/threads/tomcat-centos-7.462501/

Got it wrong?

If so, how should I proceed?

Go back to JDK1.7, change application server, change server OS or change control panel?

On localhost everything is working fine.

All help will be welcome.

1 answer

2


The important part of your mistake is this:

Unsupported major.minor version 52.0

The version major/minor number 52 corresponds to Java 8. Since you are running on a Java 7 JVM, then it will not work.

What’s going on is that you are trying to run compiled classes for Java 8 within a Java 7 JVM.

In this case, at least one of the classes compiled with Java 8 is the class app.server.CSelerServer.

So there are three possible solutions:

  1. Upgrade your JVM to Java 8.

  2. Recompiling your classes using Java 7. This means not using any Apis that have been introduced only in Java 8, including Amblas, streams, method interfaces default, etc..

  3. Use the retro-lambda to find a way to transform your Java 8 classes into Java 7 classes.

The link incompatibility issue you posted says cPanel has decided not to support Tomcat anymore. This is something quite different than saying that you can’t run Java 8 inside your virtual machine. Besides, nothing stops you from running Tomcat out of cPanel.

The reason cPanel stopped supporting Tomcat is that:

  • The version cPanel supported for Tomcat was too old;

  • The amount of changes in dependencies needed to update Tomcat support would be quite large and;

  • Less than 0.1% of cPanel customers used Tomcat.

Therefore, for cPanel developers/administrators, the best thing for them was simply to abandon Tomcat.

  • I understood Victor, I worry a little about the fact that I have to go back to the Java7, I have a very large amount of code, although I would only need to go back to the Javaee part, but if that’s the solution I will do it. Wouldn’t it be the case to change the application server? Do you know one that supports java 8 in cPanel?

  • 1

    @Edsonfsantos What I’ve been researching, I can’t, but I’m not absolutely sure. What it looks like is that cPanel has left Java totally and never endured anything more than Tomcat. This means you will have to run the Tomcat outside the cPanel. If you prefer Jetty (I recommend), Glassfish, Wildfly or some other, you will also have to be outside the cPanel. Or, if you really want to keep cPanel, you’ll have to downgrade and stay in the old Tomcat.

  • Victor, was already starting the downgrade when the VPS support put Tomcat to work in cPanel with java8. Saved me a lot of trouble and now we know it’s possible. The app is working with the remote server :)

  • @Edsonfsantos Which version of Tomcat?

  • Apache Tomcat/7.0.42 --- JVM 1.8.0_101-B13

  • 1

    @Edsonfsantos Bem, according to this page, it will work with Java 6 or higher and with Java 7 or higher if you’re gonna use Websocket. You will be stuck to Specification 3.0 of Servlet (that is, you will not be able to use details of Servlets 3.1 and 4.0, but these are quite few). I mean, just switching the JVM should really be enough for you.

Show 1 more comment

Browser other questions tagged

You are not signed in. Login or sign up in order to post.