I am trying to use jboss 4.0.4CR2 with the ejb3 option but at the moment
when I try to use an EntityManager from within my session bean the entity
manager is always null.
I have a stateless session bean where I load the entity manager:
@Stateless public class CategorySessionBean implements CategoryView { @PersistenceContext(unitName = "inventPU") protected EntityManager manager; ... public load(){ //HERE THE manager is NULL Query q = manager.createQuery("FROM Category"); } ... }
...|-META-INF ...|-META-INF|-application.xml ...|-invent.par ...|-invent.war
<application> <display-name>invent</display-name> <module> <web> <web-uri>invent.war</web-uri> <context-root>/invent</context-root> </web> </module> <module> <ejb>invent.par</ejb> </module> </application>
...|-META-INF ...|-META-INF|-persistence.xml ...|-gr (the entity and session beans)
<?xml version="1.0" encoding="UTF-8"?> <persistence> <persistence-unit name="inventPU"> <description> AEGEK invent pesrsistent unit</description> <jta-data-source>java:/inventDS</jta-data-source> <properties> <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLInnoDBDialect"/> <property name="hibernate.hbm2ddl.auto" value="create"/> </properties> </persistence-unit> </persistence>
Actually
just found the problem: it was in the way I was calling the session bean from the web page.
;-)
--