我正在尝试使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>
我尚未编写任何代码,只是对其进行了配置。
好吧,我自己弄清楚了。两个版本的xml-api确实存在问题。一种来自Play本身,另一种来自Apache Directory API。我将build.sbt中的工件更改为,并且现在可以正常工作:
"org.apache.directory.api" % "api-all" % "1.0.0-M14"