3

I need to put a app built on top of Spring Boot to run in an environment with Java 6, I'm finding some problems. I did some testing, I downloaded a new project by start.spring.io set to Java 6 and the problem still persists.

I'm finding it strange because the project recovered by start.spring.io (set to Java 6) does not apply the recommended settings in the documentation to run on Java 6

After applying the recommended settings described on the site, the error persists.

With Jetty settings:

ERROR 7776 --- [main] osboot.SpringApplication: Application startup failed

java.lang.UnsupportedClassVersionError: org / apache / tomcat / jdbc / pool / DataSource: Unsupported major.minor version 51.0

With Tomcat configurations:

 05/14/2015 07: 50: 18,112 ERROR 10852 --- [main]
 osboot.SpringApplication: Application startup failed

 Exception in thread "main" java.lang.UnsupportedClassVersionError:
 javax / annotation / ManagedBean: Unsupported major.minor version 51.0

JDK version: 1.6.0_45

Spring Boot: v1.2.3.RELEASE

Build with Gradle

Any suggestions of what I might be doing wrong?

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
Lucas Oliveira
  • 833
  • 1
  • 10
  • 24
  • 1
    The thumb rule is that code must be run on a JRE which is higher than the one used at compile time. Here code was compiled on JDK 7 (.minor version 51.0) and is being run on JRE 6. Hence, the error. – user1933888 May 14 '15 at 11:06
  • Java 6 has been end-of-public-updates since February 2013, ask yourself if you really want to run on such an outdated version. – Mark Rotteveel May 14 '15 at 11:11
  • I am aware of the reasons for the error "Unsupported major.minor version 51.0 ', which I'm not understanding is why the Spring Boot not run on Java 6 because in the own documentation has a section for settings that environment. Also, unfortunately, it is now necessary (: ~) run the system in java 6 – Lucas Oliveira May 14 '15 at 11:17
  • 1
    Use tomcat7 instead of tomcat8. By default spring boot uses this which requires a minimum of Java7 and not Java6. This version also contains a Tomcat JDBC version compiled with Java7 and will therefor not run on Java6. To switch tomcat versions read [this section of the reference guide](http://docs.spring.io/spring-boot/docs/current/reference/html/howto-embedded-servlet-containers.html#howto-use-tomcat-7). – M. Deinum May 14 '15 at 12:24
  • 1
    add ` 7.0.59 ` to your pom.xml – Michał Maciej Gałuszka Aug 31 '15 at 10:12
  • thanks @MichałMaciejGałuszka this worked for java 6. Now spring boot server started with addition of this property in pom.xml – gjosh Dec 11 '15 at 12:10
  • @LucasOliveira I'm using gradle, I did set the tomcat version to tomcat7 instead of tomcat8, but still getting the same error. How did you fix this? – PKR Oct 18 '16 at 00:50
  • @PKR I have updated the Java version from 6 to 8... nowadays new versions of many libraries are only compatible from Java 7+ :(. In my case, it was possible... good luck. – Lucas Oliveira Oct 19 '16 at 12:52

1 Answers1

4

The tomcat jdbc-pool is compiled with Java 7 (version 51.0) and therefore incompatible with Java 6.

Kayaman
  • 72,141
  • 5
  • 83
  • 121