gpt4 book ai didi

java - 使用EJB 来持久化。如何在其上配置持久性单元?

转载 作者:太空宇宙 更新时间:2023-11-04 13:18:57 25 4
gpt4 key购买 nike

我一直在学习 J2EE 技术。现在我尝试在 EJB 中执行 CRUD,但是当我尝试部署 Web 应用程序时,我遇到了这些问题。我对此一无所知。你能给我一些建议吗?

这是我实际的 persistence.xml:

    <?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
<persistence-unit name="UsuarioPU" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>LP3</jta-data-source>
<class>mack.entities.UsuarioImpl</class>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="javax.persistence.jdbc.url" value="jdbc:derby://localhost:1527/LP3"/>
<property name="javax.persistence.jdbc.user" value="lp3"/>
<property name="javax.persistence.jdbc.driver" value="org.apache.derby.jdbc.ClientDriver"/>
<property name="javax.persistence.jdbc.password" value="lp3"/>
<property name="hibernate.cache.provider_class" value="org.hibernate.cache.NoCacheProvider"/>
</properties>
</persistence-unit>
</persistence>

这是我尝试部署应用程序时出现的 WildFly 错误:

12:26:09,070 INFO  [org.jboss.weld.deployer] (MSC service thread 1-6) JBAS016002: Processing weld deployment Atividade_1.war
12:26:09,285 ERROR [org.jboss.as.controller.management-operation] (XNIO-1 task-2) JBAS014613: Operation ("add") failed - address: ([{"deployment" => "Atividade_2Enterprise.ear"}]) - failure description: {"JBAS014771: Services with missing/unavailable dependencies" => [
"jboss.naming.context.java.comp.Atividade_2Enterprise.Atividade_2EJB.Atividade_2Bean.ValidatorFactory is missing [jboss.naming.context.java.comp.Atividade_2Enterprise.Atividade_2EJB.Atividade_2Bean]",
"jboss.deployment.unit.\"Atividade_2Enterprise.ear\".weld.weldClassIntrospector is missing [jboss.deployment.unit.\"Atividade_2Enterprise.ear\".beanmanager]",
"jboss.naming.context.java.comp.Atividade_2Enterprise.Atividade_2EJB.Atividade_2Bean.InAppClientContainer is missing [jboss.naming.context.java.comp.Atividade_2Enterprise.Atividade_2EJB.Atividade_2Bean]",
"jboss.deployment.subunit.\"Atividade_2Enterprise.ear\".\"Atividade_2EJB.jar\".weld.weldClassIntrospector is missing [jboss.deployment.subunit.\"Atividade_2Enterprise.ear\".\"Atividade_2EJB.jar\".beanmanager]",
"jboss.persistenceunit.\"Atividade_2Enterprise.ear/EJBPersistencia.jar#UsuarioPU\".__FIRST_PHASE__ is missing [jboss.naming.context.java.LP3]",
"jboss.naming.context.java.comp.Atividade_2Enterprise.Atividade_2EJB.Atividade_2Bean.Validator is missing [jboss.naming.context.java.comp.Atividade_2Enterprise.Atividade_2EJB.Atividade_2Bean]",
"jboss.naming.context.java.comp.Atividade_2Enterprise.Atividade_2EJB.Atividade_2Bean.InstanceName is missing [jboss.naming.context.java.comp.Atividade_2Enterprise.Atividade_2EJB.Atividade_2Bean]"
]}
12:26:09,367 ERROR [org.jboss.as.server] (XNIO-1 task-2) JBAS015870: Deploy of deployment "Atividade_2Enterprise.ear" was rolled back with the following failure message:
{"JBAS014771: Services with missing/unavailable dependencies" => [
"jboss.naming.context.java.comp.Atividade_2Enterprise.Atividade_2EJB.Atividade_2Bean.ValidatorFactory is missing [jboss.naming.context.java.comp.Atividade_2Enterprise.Atividade_2EJB.Atividade_2Bean]",
"jboss.deployment.unit.\"Atividade_2Enterprise.ear\".weld.weldClassIntrospector is missing [jboss.deployment.unit.\"Atividade_2Enterprise.ear\".beanmanager]",
"jboss.naming.context.java.comp.Atividade_2Enterprise.Atividade_2EJB.Atividade_2Bean.InAppClientContainer is missing [jboss.naming.context.java.comp.Atividade_2Enterprise.Atividade_2EJB.Atividade_2Bean]",
"jboss.deployment.subunit.\"Atividade_2Enterprise.ear\".\"Atividade_2EJB.jar\".weld.weldClassIntrospector is missing [jboss.deployment.subunit.\"Atividade_2Enterprise.ear\".\"Atividade_2EJB.jar\".beanmanager]",
"jboss.persistenceunit.\"Atividade_2Enterprise.ear/EJBPersistencia.jar#UsuarioPU\".__FIRST_PHASE__ is missing [jboss.naming.context.java.LP3]",
"jboss.naming.context.java.comp.Atividade_2Enterprise.Atividade_2EJB.Atividade_2Bean.Validator is missing [jboss.naming.context.java.comp.Atividade_2Enterprise.Atividade_2EJB.Atividade_2Bean]",
"jboss.naming.context.java.comp.Atividade_2Enterprise.Atividade_2EJB.Atividade_2Bean.InstanceName is missing [jboss.naming.context.java.comp.Atividade_2Enterprise.Atividade_2EJB.Atividade_2Bean]"
]}
12:26:09,398 INFO [org.jboss.as.server.deployment] (MSC service thread 1-5) JBAS015974: Stopped subdeployment (runtime-name: EJBPersistencia.jar) in 35ms
12:26:09,396 INFO [org.jboss.as.server.deployment] (MSC service thread 1-4) JBAS015974: Stopped subdeployment (runtime-name: Atividade_2EJB.jar) in 33ms
12:26:09,647 INFO [org.jboss.as.server.deployment] (MSC service thread 1-3) JBAS015974: Stopped subdeployment (runtime-name: Atividade_1.war) in 285ms
12:26:09,785 INFO [org.jboss.as.server.deployment] (MSC service thread 1-3) JBAS015877: Stopped deployment Atividade_2Enterprise.ear (runtime-name: Atividade_2Enterprise.ear) in 423ms

谢谢大家!

最佳答案

RedFIVE,感谢您的关注!我正在和我的老师交谈,他想起了 NETBeans 与 Hibernate JPA 的问题。所以我尝试更改 EclpiseLink 提供程序,并在 GlassingFish 服务器上运行它。终于成功了!

再次感谢!

关于java - 使用EJB 来持久化。如何在其上配置持久性单元?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33284090/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com