简体   繁体   中英

Using EJB to persist. How do I configure the Persistence Unit on it?

I've been learning about J2EE tech. Now I'm trying to out my CRUD in a EJB, but when I try to deploy my web application, I have these problems. I don't have a clue about this one. Can you give me some tips about it?

This is my actual 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>

And this is the WildFly error when I try to deploy my application:

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

Thank you guys!

RedFIVE, thanks for your attention! I'm was talking with my teacher, and he remembered me about the problem that NETBeans has with the Hibernate JPA. So I've tried changing for EclpiseLink provider, and ran it on GlassingFish server. It FINALLY WORKED!

Thanks once more!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM