2012-07-02 82 views
4

我得到這個錯誤,當我嘗試一個簡單的項目保存到我的H2分貝:播放框架ebean配置

"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()" 

我的戲application.conf文件

# 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.*" 
+0

你知道問題出在哪裏嗎? –

回答

3

要使用JNDI DataSource,你需要設置:

ebean.datasource.factory=jndi 

和datasource.default作爲JNDI的數據源名稱。您可以額外重寫ebean.datasource.jndi.prefix,其默認爲java:comp/env/jdbc /。

+0

當你說「datasource.default作爲JNDI數據源名稱」時,你是什麼意思?你的意思是它應該像這樣設置「db.default.jndiName = datasource.default」? –

0

當沒有正確的.conf文件時,經常會發生這種情況。例如,我跑戰術框架,命令:

~/play-2.1.2/play -Dconfig.file=conf/local.conf 

,我還沒有的local.conf文件。