persistance.units NOTYETINSTALLED
z3r0 Jan 31, 2007 12:44 PMHi,
I use JBoss 4.0.5 (with EJB3 support) and I develop with Eclipse 3.2.1/WTP 1.5.2.
I try to deploy EJB3s under JBoss, but I'm not abble to access to the persistance manager.
My first EJB Session Stateless runs well :
HelloService.java :
package com.test.jboss.ejb3; import javax.ejb.Local; @Local public interface HelloService { public String hello(String name); }
HelloServiceBean.java :
package com.test.jboss.ejb3; import javax.ejb.Stateless; @Stateless public class HelloServiceBean implements HelloService { public String hello(String name) { return "Hello " + name + " "; } }
This EJB is correctly deployed in JBoss and I can call it form my web module.
My second EJB Session Stateless which use EJB Entity don't run well :
Contact.java :
package com.test.jboss.ejb3; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.Table; @Entity @Table(name="contact") public class Contact { @Id @GeneratedValue(strategy=GenerationType.AUTO) private int id; private String name; public int getId() { return id; } public void setId(int id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } }
ContactService.java :
package com.test.jboss.ejb3; import java.util.Collection; import javax.ejb.Local; @Local public interface ContactService { public Collection<Contact> findAllContact(); }
ContactServiceBean.java :
package com.test.jboss.ejb3; import java.util.Collection; import javax.ejb.Stateless; import javax.persistence.EntityManager; import javax.persistence.PersistenceContext; @Stateless public class ContactServiceBean implements ContactService { @PersistenceContext(unitName = "testdb") protected EntityManager em; @SuppressWarnings("unchecked") public Collection<Contact> findAllContact() { return em.createQuery("SELECT c FROM Contact c").getResultList(); } }
META-INF/persistance.xml :
<?xml version="1.0" encoding="UTF-8"?> <persistence> <persistence-unit name="testdb"> <jta-data-source>java:/DefaultDS</jta-data-source> <properties> <property name="hibernate.hbm2ddl.auto" value="create-drop"/> <property name="hibernate.show_sql" value="true"/> <property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/> </properties> </persistence-unit> </persistence>
This EJB is not correctly loaded in JBoss :
16:07:27,225 INFO [EARDeployer] Init J2EE application: file:/D:/Program Files/jboss-4.0.5.GA/server/default/deploy/test-jboss-ear.ear 16:07:27,444 INFO [Ejb3Deployment] EJB3 deployment time took: 15 16:07:27,460 INFO [JmxKernelAbstraction] installing MBean: jboss.j2ee:ear=test-jboss-ear.ear,jar=test-jboss-ejb.jar,name=ContactServiceBean,service=EJB3 with dependencies: 16:07:27,460 INFO [JmxKernelAbstraction] persistence.units:unitName=testdb 16:07:27,460 INFO [JmxKernelAbstraction] installing MBean: jboss.j2ee:ear=test-jboss-ear.ear,jar=test-jboss-ejb.jar,name=HelloServiceBean,service=EJB3 with dependencies: 16:07:27,475 INFO [EJBContainer] STARTED EJB: com.test.jboss.ejb3.HelloServiceBean ejbName: HelloServiceBean 16:07:27,475 INFO [EJB3Deployer] Deployed: file:/D:/Program Files/jboss-4.0.5.GA/server/default/tmp/deploy/tmp65187test-jboss-ear.ear-contents/test-jboss-ejb.jar 16:07:27,491 INFO [TomcatDeployer] deploy, ctxPath=/test-jboss-web, warUrl=.../tmp/deploy/tmp65187test-jboss-ear.ear-contents/test-jboss-web-exp.war/ 16:07:27,694 INFO [EARDeployer] Started J2EE application: file:/D:/Program Files/jboss-4.0.5.GA/server/default/deploy/test-jboss-ear.ear 16:07:27,694 ERROR [URLDeploymentScanner] Incomplete Deployment listing: --- MBeans waiting for other MBeans --- ObjectName: jboss.j2ee:ear=test-jboss-ear.ear,jar=test-jboss-ejb.jar,name=ContactServiceBean,service=EJB3 State: NOTYETINSTALLED I Depend On: persistence.units:unitName=testdb --- MBEANS THAT ARE THE ROOT CAUSE OF THE PROBLEM --- ObjectName: persistence.units:unitName=testdb State: NOTYETINSTALLED Depends On Me: jboss.j2ee:ear=test-jboss-ear.ear,jar=test-jboss-ejb.jar,name=ContactServiceBean,service=EJB3
Moreover, my web module cannot call the EJB because the following exception is throwed : javax.naming.NameNotFoundException: ContactServiceBean not bound.
Anybody can explain me the trouble please ?
Thanks,
Regards,
Zero