java Tomee jpa设置
无法部署应用程序,java异常。lang.异常:未找到持久化单元:持久化-750441533localhost:Name“openejb/PersistenceUnit/persistence-750441533localhost”。 被试了很多次。对设置有什么建议吗
坚持。xml
<persistence xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://xmlns.jcp.org/xml/ns/persistence"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence
http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"
version="2.1">
<persistence-unit name="persistence">
<description>Hibernate JPA</description>
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<non-jta-data-source>jdbc/postgres</non-jta-data-source>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
</properties>
</persistence-unit>
</persistence>
上下文。xml
<Context antiJARLocking="true" path="/postgres">
<Resource name="jdbc/postgres"
auth="Container"
type="javax.sql.DataSource"
username="root"
password="root"
driverClassName="org.postgresql.Driver"
url="jdbc:postgresql://localhost:5432/base"
maxTotal="20"
maxActive="25"
maxIdle="3"/>
</Context>
错误
org.apache.catalina.LifecycleException: An invalid Lifecycle transition was attempted ([before_destroy]) for component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[]] in state [STARTING_PREP]
14-Jun-2019 17:21:36.774 SEVERE [http-nio-8080-exec-4]
org.apache.openejb.assembler.classic.Assembler.destroyApplication
undeployException original cause
java.lang.Exception: deployment not found: .Comp1964794492
14-Jun-2019 17:21:36.777 SEVERE [http-nio-8080-exec-4]
org.apache.openejb.assembler.classic.Assembler.destroyApplication
undeployException original cause
java.lang.Exception: persistence-unit: persistence
-750441533localhost: Name "openejb/PersistenceUnit/persistence
-750441533localhost" not found.
org.apache.openejb.OpenEJBRuntimeException: javax.persistence.PersistenceException: [PersistenceUnit: persistence] Unable to build Hibernate SessionFactory: javax.persistence.PersistenceException: [PersistenceUnit: persistence] Unable to build Hibernate SessionFactory
# 1 楼答案
我找到了解决办法。TOME的Jta配置:
main/resources/META-INF/persistence。xml
tomee\conf\tomee。xml
日食专家:
别忘了放jdbc驱动器。jar到tomee\lib
还要注意的是,eclipselink只对tomee羽流起作用