11

In offcial page of Tomcat it says that Tomcat 7 supports Java 8. If I download this and run with Java 8 it works.

But, on Openshift is Tomcat 7 (JBoss EWS 2.0). In this webpage it says that EWS 2.0 doesn't support Java 8. If I deploy my Java 8 application to Openshift (Tomcat 7) it isn't working.

Why?


I tried to install Java 8 on Tomcat 7 on Openshift with this: https://stackoverflow.com/a/23895161/2442133 But it isnt' working for me. I have error:

org.springframework.beans.factory.BeanCreationException: Error creating bean
with name 'org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping':
Initialization of bean failed; nested exception is 
org.springframework.beans.factory.CannotLoadBeanClassException: Error loading 
class [pl.xxx.controller.HomeController] for bean with name 'homeController'     
defined in file [/var/lib/openshift/xxx/app-    
root/runtime/dependencies/jbossews/webapps/web1/WEB-
INF/classes/xxx/controller/HomeController.class]: problem with class file or
dependent class; nested exception is java.lang.UnsupportedClassVersionError: 
xxx/controller/HomeController : Unsupported major.minor version 52.0 (unable to
load class xxx.controller.HomeController)

Unsupported major.minor version 52.0 says that Java version is wrong (Java 7 intead Java 8).

Community
  • 1
  • 1
mkczyk
  • 2,460
  • 2
  • 25
  • 40
  • That's a Spring bean in the exception you cite. It might be a Spring issue. Which version of Spring are you running? Tomcat on JBOSS might be altered from the version on the Apache site. I'd believe the JVM, not the citations you listed. – duffymo Dec 21 '15 at 02:31
  • I'm using Tomcat with Java 8, but not Spring. – user207421 Dec 21 '15 at 02:35
  • 1
    That's because their machines have Java JRE 7 installed. – Luiggi Mendoza Dec 21 '15 at 02:35
  • My application work on my computer with Tomcat 7, but don't work with Tomcat 7 on Openshift. If I change version Maven Java compiler 1.8 to 1.7 in pom.xml, it works also in Openshift. My version Spring 4.1.6, Maven 3.3, Java compiler 1.8. – mkczyk Dec 21 '15 at 02:36
  • Note that the EWS website you link does not state that EWS does not support Java 8, it just states that Java 8 is not among the "enterprise supported" configurations. E.g. if you buy support from RedHat and run on Java8, they'd be free to ask you to run it on Java7 and not fix issues under Java8. That being said, my bet is that @EJP's answer is correct: You're running your Java8-compiled code on a Java7 runtime. That's what the "Unsupported major.minor version" tells you. – Olaf Kock Dec 21 '15 at 11:42

2 Answers2

8

The Unsupported major.minor version 52.0 error says that you have a Java 8 class file but a Java <= 7 JRE. So you haven't succeeded in installing Java 8 for Tomcat at all. You may need to adjust something in the Tomcat configuration to make it use Java 8.

user207421
  • 305,947
  • 44
  • 307
  • 483
5

If you happen to run Tomcat as a service on Windows you might need to change the JRE that tomcat uses by issuing:

tomcat7w.exe //ES/<your_service_name>

Which should lead you to this dialog:

enter image description here

Make sure "use default" is ticked or the right "Java virtual Machine" is used.

Jens
  • 6,243
  • 1
  • 49
  • 79