Question

I'm using playframework 2.2.2 on OSX.

My command line reports I am using the following java version:

java version "1.6.0_65"
Java(TM) SE Runtime Environment (build 1.6.0_65-b14-462-11M4609)
Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-462, mixed mode)

I'm using tomcat jdbc pool, and when I load my play app I get this error:

[RuntimeException: java.lang.UnsupportedClassVersionError: org/apache/tomcat/jdbc/pool/PoolConfiguration : Unsupported major.minor version 51.0]

Now correct me if I am wrong, but I believe somehow play uses its own java version, which is java 7 correct? I remember seeing this outputted somewhere when using play but I can seem to figure out where I saw this.

So what is the issue here, is it that play is compiling using java 7 but when I run it is using version 6?

Note: I don't use the play command to run my app, rather I use sbt to enter b/c I have several projects and I then just type run.

My project layout in sbt is:

common
services
web <-- play app

How can I fix this issue as I am a little lost what is going on.

Was it helpful?

Solution

Play 2.2 is compatible with Java 6 and 7. Play itself doesn't ship with Java so your build will be picking up a version of Java that's already on your system.

Here's the logic inside the play command. As you can see, play uses the version of Java in the path or the version within JAVA_HOME.

if [ -z "$JAVA_HOME" ]; then
  JAVA="java"
else
  JAVA="$JAVA_HOME/bin/java"
fi

Since you're getting a runtime error with a Tomcat class, I think it's most likely not a Play compile problem. My guess is that you're using a version of Tomcat that requires Java 7 or higher, such as Tomcat 8. See Apache Tomcat Versions for more info.

By the way, you can configure SBT/Play to make sure it always generates Java 6 bytecode by giving the Java compiler some options:

javacOptions ++= Seq("-source", "1.6", "-target", "1.6")

See SBT's Java Sources docs.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top