Erin Drummond
Erin Drummond

Reputation: 5526

Play framework - how to fix UnsupportedClassVersionError on JRE 6?

I was running my play app on OpenJDK 1.7. All was well and good until I tried to deploy to heroku, which only supports OpenJDK 1.6. I fixed the syntax to run on OpenJDK 1.6, however when I go to run it I get the following error:

erin@bob:/src/playtest$ java -version
java version "1.6.0_23"
OpenJDK Runtime Environment (IcedTea6 1.11pre) (6b23~pre11-0ubuntu1.11.10.2)
OpenJDK 64-Bit Server VM (build 20.0-b11, mixed mode)
erin@bob:/src/playtest$ play run
~        _            _ 
~  _ __ | | __ _ _  _| |
~ | '_ \| |/ _' | || |_|
~ |  __/|_|\____|\__ (_)
~ |_|            |__/   
~
~ play! 1.2.4, http://www.playframework.org
~
~ Ctrl+C to stop
~ 
Listening for transport dt_socket at address: 8000
22:13:21,806 INFO  ~ Starting /src/playtest
22:13:21,811 INFO  ~ Module securesocial is available (/src/play-1.2.4/modules/securesocial-0.2.4)
22:13:21,811 INFO  ~ Module crudsiena is available (/src/playtest/modules/crudsiena-2.0.2)
22:13:21,812 INFO  ~ Module siena is available (/src/playtest/modules/siena-2.0.7)
Exception in thread "main" java.lang.UnsupportedClassVersionError: DocViewerPlugin : Unsupported major.minor version 51.0
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:634)
    at play.classloading.ApplicationClassloader.loadApplicationClass(ApplicationClassloader.java:166)
    at play.classloading.ApplicationClassloader.loadClass(ApplicationClassloader.java:84)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
    at play.plugins.PluginCollection.loadPlugins(PluginCollection.java:158)
    at play.Play.init(Play.java:294)
    at play.server.Server.main(Server.java:158)

It looks like there is a Java 1.7 class compiled somewhere that play is trying to run on the Java 1.6 VM.

I have run play clean, and also deleted the ivy cache and run play deps to reinstall all the dependencies. I have also searched my app directory and my play install directory for stray .class files, and have found none. I also tried clearing /tmp incase a file in there was being referenced, but it had no effect.

DocViewerPlugin is one of the core play plugins and I dont need it, is there any way to blacklist it?

Upvotes: 11

Views: 6502

Answers (2)

knob creek
knob creek

Reputation: 96

You have to compile the code using the -target 1.6 option.

Upvotes: 8

Erin Drummond
Erin Drummond

Reputation: 5526

I figured it out. In application.conf, make sure java.source=1.6 is set.

Upvotes: 10

Related Questions