Play Framework ebean configuration

playframework, playframework-2.0

Solution

To use a JNDI DataSource you need to set:

ebean.datasource.factory=jndi

And datasource.default as the JNDI DataSource name. You can additionally override ebean.datasource.jndi.prefix which defaults to java:comp/env/jdbc/.

Problem

I get this error when I try to save a simple Item to my H2 db: ``` "javax.persistence.PersistenceException: The default EbeanServer has not been defined ? This is normally set via the ebean.datasource.default property. Otherwise it should be registered programatically via registerServer()" ``` my play application.conf file ``` # Database configuration # ~~~~~ # You can declare as many datasources as you want. # By convention, the default datasource is named `efault db.default.driver=org.h2.Driver db.default.url="jdbc:h2:mem:play" db.default.jndiName=DefaultDS db.default.user=sa db.default.password="" # JPA configuration # ~~~~~ # You can declare as many Ebean servers as you want. # By convention, the default server is named `default` jpa.default=defaultPersistenceUnit ebean.datasource.default=DefaultDS ebean.default="models.*" ```

Original source