我正在尝试让 Play 2.2 项目与 Hibernate JPA 和 PostgreSQL 数据库一起使用。我之前用 Play 2.1.1 做过,它运行良好。我现在收到以下错误:
play.api.UnexpectedException: Unexpected exception[NoClassDefFoundError: org/w3c/dom/ElementTraversal]
at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$1$$anonfun$1.apply(ApplicationProvider.scala:152) ~[play_2.10.jar:2.2.0]
我不知道这是从哪里来的。我的 build.sbt 看起来像这样:
libraryDependencies ++= Seq(
javaJdbc,
cache,
javaJpa,
"org.apache.directory.api" % "apache-ldap-api" % "1.0.0-M14",
"postgresql" % "postgresql" % "9.1-901-1.jdbc4",
"org.hibernate" % "hibernate-core" % "4.2.3.Final",
"org.hibernate" % "hibernate-entitymanager" % "4.2.3.Final"
)
我的persistence.xml是这样的:
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
version="2.0">
<persistence-unit name="defaultPersistenceUnit"
transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<non-jta-data-source>DefaultDS</non-jta-data-source>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect" />
<property name="hibernate.hbm2ddl.auto" value="update" />
</properties>
</persistence-unit>
我还没有写任何代码,我只是配置了它。