I have some Hibernate data access code that I want to use in a new Jboss EJB3 based app. I run a simple test following instructions that I can find, but it failed to deploy my bean. Appreciate any help!
When JBOSS started, I got
Code:
DEPLOYMENTS MISSING DEPENDENCIES:
Deployment "jboss.j2ee:ear=wcc.ear,jar=wcc.jar,name=TestEJB,service=EJB3" is missing the following dependencies:
Dependency "<UNKNOWN jboss.j2ee:ear=wcc.ear,jar=wcc.jar,name=TestEJB,service=EJB3>" (should be in state "Described",
but is actually in state "** UNRESOLVED Demands 'persistence.unit:unitName=wcc.ear/#wccDatabase' **")
Deployment "jboss.j2ee:ear=wcc.ear,jar=wcc.jar,name=TestEJB,service=EJB3_endpoint" is missing the following dependenci
es:
Dependency "jboss.j2ee:ear=wcc.ear,jar=wcc.jar,name=TestEJB,service=EJB3" (should be in state "Configured", but is a
ctually in state "PreInstall")
Deployment "persistence.unit:unitName=wcc.ear/#wccDatabase" is missing the following dependencies:
Dependency "jboss.jca:name=wccDatabase,service=DataSourceBinding" (should be in state "Create", but is actually in s
tate "** NOT FOUND Depends on 'jboss.jca:name=wccDatabase,service=DataSourceBinding' **")
If I comment out @PersistenceContext, EJB is deployed fine.
My persistence.xml is like this
Code:
<?xml version="1.0" encoding="UTF-8"?>
<persistence 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_1_0.xsd"
version="1.0">
<persistence-unit name="wccDatabase">
<jta-data-source>java:/wccDatabase</jta-data-source>
<properties>
<property name="hibernate.ejb.cfgfile" value="/hibernate.cfg.xml"/>
<property name="hibernate.hbm2ddl.auto" value="create-drop"/>
</properties>
</persistence-unit>
</persistence>
EJB sources like this,
Code:
@Local
public interface ITestEJB {
public List<User> getUsers();
}
Code:
@Stateless
public class TestEJB implements ITestEJB, Serializable {
private static final long serialVersionUID = -842292318926507620L;
@PersistenceContext(unitName="wccDatabase")
private Session session;
@Override
public List<User> getUsers() {
Criteria criteria = session.createCriteria(User.class);
return criteria.list();
}
}