Error while serving servlet - Java 7 vs Java 8

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 WHM / CPanel CENTS 6.8 x86_64 virtuozzo and use Apache Tomcat as the application server. In the project the client side (desktop and mobile) and server side I'm using JDK 1.8.

I noticed that the server's Tomcat is using JVM 1.7.0

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

link

link

Did I get it wrong?

If so, how should I proceed?

Back to JDK1.7, change the application server, change OS on the server or change the control panel?

At localhost everything is working right.

All help is welcome.

    
asked by anonymous 23.09.2016 / 21:17

1 answer

2

The important part of your error is this:

  

Unsupported major.minor version 52.0

The major / minor version number 52 corresponds to Java 8. As you are running in a Java 7 JVM, then this will not work.

What is happening is you are trying to run compiled classes for Java 8 inside 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:

  • Upgrade your Java 8 JVM.

  • Recompiling your classes using Java 7. This means not using any APIs that were introduced only in Java 8, including lambdas, streams, interfaces with default methods, p>

  • Use retrolambda to get your Java 8 classes converted into Java 7 classes.

  • The problem regarding the incompatibility of the links you posted says that cPanel decided not to support Tomcat anymore. This is quite different from saying that you can not run Java 8 inside your virtual machine. Also, nothing prevents you from running Tomcat outside the cPanel.

    The reason that led cPanel to fail to support Tomcat is that:

    • The version that cPanel supported for Tomcat was too old;

    • The amount of dependency changes required to upgrade Tomcat support would be quite large, and

    • Less than 0.1% of cPanel customers used Tomcat.

    So for cPanel developers / admins, it was best for them to simply abandon Tomcat.

        
    23.09.2016 / 21:56