2 Replies Latest reply on Feb 19, 2011 2:48 AM by Sam W

    UNRESOLVED Demands 'persistence.unit:unitName=

    Sam W Expert

      Here is the exception error:

       

       

      DEPLOYMENTS IN ERROR:

         Deployment "<UNKNOWN jboss.j2ee:ear=HousewareEnterpriseApplication.ear,jar=HousewareEnterpriseApplication-ejb.jar,name=RoleFacade,service=EJB3>" is in error due to the following reason(s): ** UNRESOLVED Demands 'persistence.unit:unitName=HousewareEnterpriseApplication.ear/HousewareEnterpriseApplication-ejb.jar#HousewareEnterpriseApplication-ejbPU' **

      ...

       

      My persistence.xml file is shown below:

       

      <?xml version="1.0" encoding="UTF-8"?>

      <persistence version="2.0" 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">

        <persistence-unit name="HousewareEnterpriseApplication-ejbPU" transaction-type="JTA">

          <jta-data-source>java:/Houseware</jta-data-source>

          <properties/>

        </persistence-unit>

      </persistence>

       

      My hibernate.cfg.xml file is shown below:

       

      <?xml version="1.0" encoding="UTF-8"?>

      <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

      <hibernate-configuration>

        <session-factory>

          <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>

          <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>

          <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/houseware</property>

          <property name="hibernate.connection.username">root</property>

          <property name="hibernate.connection.password">admin</property>

           <listener type="post-insert" class="org.hibernate.search.event.FullTextIndexEventListener"/>

          <listener type="post-update" class="org.hibernate.search.event.FullTextIndexEventListener"/>

          <listener type="post-delete" class="org.hibernate.search.event.FullTextIndexEventListener"/>

        </session-factory>

      </hibernate-configuration>

       

      Here is the RoleFacade.java file:

       

      package au.com.houseware.ejb.entity.bean;

       

      import au.com.houseware.ejb.entity.Role;

      import au.com.houseware.utils.RandomNumberUtil;

      import javax.annotation.Resource;

      import javax.ejb.Stateless;

      import javax.persistence.EntityManager;

      import javax.persistence.PersistenceContext;

       

      @Stateless

      public class RoleFacade extends AbstractFacade<Role> {

          @PersistenceContext(unitName = "HousewareEnterpriseApplication-ejbPU")

          private EntityManager em;

          @Resource

          private javax.transaction.UserTransaction utx;

       

       

          protected EntityManager getEntityManager() {

              return em;

          }

       

       

          public RoleFacade() {

              super(Role.class);

          }

       

       

          public void createRoleFromName(String name) {

              Role role = new Role();

              role.setRoleId((long)RandomNumberUtil.tinyId());

              role.setRoleName(name);

              super.create(role);

          }

      }

       

      What else I have missing from the project setup? or anything wrong in my RoleFacade file?

       

      Very appreciate for any suggestion and guidance.

       

      Thanks

      Sam