Tim Visser
Tim Visser

Reputation: 919

Play Framework 2.3.x (Java) distribution with Ebean

I tested my Play Framework application on my local machine. Everything is working. When I first start my Play application on localhost:9000 it gives me the error that my database 'default' needs an evolution. This all is to be expected and works like a charm.

Cropped print screen of the local error

Now, when I render a distribution with the command activator clean dist, target/universal/my-project-name-version-number-SNAPSHOT.zip is outputted. This file I then upload to my distribution server and unzip it there.

Now I come to my question. The archive is unzipped and I navigate to /bin. Then I run the command ./my-project-name which outputs the following:

Play server process ID is 1234
[info] play - database [default] connected at jdbc:h2:mem:my-project-name
Oops, cannot start the server.
Configuration error: Configuration error[Cannot register class [models.ModelName] in Ebean server]
    at play.api.Configuration$.play$api$Configuration$$configError(Configuration.scala:94)
    at play.api.Configuration.reportError(Configuration.scala:743)
    at play.Configuration.reportError(Configuration.java:310)
    at play.db.ebean.EbeanPlugin.onStart(EbeanPlugin.java:81)
    at play.api.Play$$anonfun$start$1$$anonfun$apply$mcV$sp$1.apply(Play.scala:91)
    at play.api.Play$$anonfun$start$1$$anonfun$apply$mcV$sp$1.apply(Play.scala:91)
    at scala.collection.immutable.List.foreach(List.scala:383)
    at play.api.Play$$anonfun$start$1.apply$mcV$sp(Play.scala:91)
    at play.api.Play$$anonfun$start$1.apply(Play.scala:91)
    at play.api.Play$$anonfun$start$1.apply(Play.scala:91)
    at play.utils.Threads$.withContextClassLoader(Threads.scala:21)
    at play.api.Play$.start(Play.scala:90)
    at play.core.StaticApplication.<init>(ApplicationProvider.scala:55)
    at play.core.server.NettyServer$.createServer(NettyServer.scala:253)
    at play.core.server.NettyServer$$anonfun$main$3.apply(NettyServer.scala:289)
    at play.core.server.NettyServer$$anonfun$main$3.apply(NettyServer.scala:284)
    at scala.Option.map(Option.scala:145)
    at play.core.server.NettyServer$.main(NettyServer.scala:284)
    at play.core.server.NettyServer.main(NettyServer.scala)
Caused by: java.lang.UnsupportedClassVersionError: models/ModelName : Unsupportedmajor.minor version 52.0
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
    at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:274)
    at play.db.ebean.EbeanPlugin.onStart(EbeanPlugin.java:79)
    ... 15 more

My models.ModelName looks as follows:

@Entity
public class ModelName extends Model {

    private static final long serialVersionUID = 3937829334149968337L;
    public static final Model.Finder<Long, ModelName> find = new Finder<Long, ModelName>(
        Long.class, ModelName.class
    );

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    protected Long id;

    @Constraints.Required
    protected String name;

    @Constraints.Required
    @Lob
    protected byte[] data;


    /** Getters/setters */
    public Long getId() {
        return this.id;
    }

    public String getName() {
        return this.name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public byte[] getData() {
        return this.data;
    }

    public void setData(byte[] data) {
        this.data = data;
    }
}

Does anyone know why this is and how it can be fixed?

EDIT

Putting the option applyEvolutions.default=true in my application.conf file does not make a difference.

SOLVE

The command ./activator -DapplyEvolutions=true works. The error was caused by my used platform: Windows. On a Linux platform this runs like a charm. Thanks!

Upvotes: 2

Views: 356

Answers (1)

biesior
biesior

Reputation: 55798

Use the applyEvolutions as a param during starting the app (preferebly write shell script) like:

 ./my-project-name -DapplyEvolutions.default=true

Upvotes: 2

Related Questions