Have you configured your <jta-data-source/> name of your persistence.xml in the jboss-beans.xml?
In persistence.xml, I have
In jboss-beans.xml, I have
<bean name="myDatasourceBootstrap" class="org.jboss.resource.adapter.jdbc.local.LocalTxDataSource"> <property name="driverClass">com.mysql.jdbc.Driver</property> ....other properties.... <property name="transactionManager"><inject bean="TransactionManager"/></property> <property name="cachedConnectionManager"><inject bean="CachedConnectionManager"/></property> <property name="initialContextProperties"><inject bean="InitialContextProperties"/></property> </bean> <bean name="myDatasource" class="java.lang.Object"> <constructor factoryMethod="getDatasource"> <factory bean="myDatasourceBootstrap"/> </constructor> </bean>
Is that what you mean? Does it look right? The whole thing works if I use @PersistenceContext, so it seems like the setup must be reasonably correct.
Yes, it was I meant. You are right if @PersistenceContext is working fine, it seems the problem is with some configuration (components.xml) or component declaration.
Could I see your components.xml configuration and also the whole class (component) where you are trying to inject the the EntityManager in.
In trying to put together a stripped-down class for you, I found out what was wrong.
In the class where I was trying to inject the seam-managed persistence context, I also had several UIInput objects that were bound to components in the xhtml. Without the UIInput objects, everything works fine, but with them I get the exception I listed above.
I'm not sure why having the bound UIInput objects would cause the seam-managed persistence context injection to fail, but it may be something to do with the JSF lifecycle -- maybe the point where bound objects are set into the backing beans is too early for the persistence context, or something.
Anyway, it looks like I've got this fixed now. Thanks for looking at it.