[jbossseam-issues] [JBoss JIRA] Commented: (JBSEAM-2802) Websphere: unable to inject EntityManager into non-EJBs
Eric Jung (JIRA)
jira-events at lists.jboss.org
Mon Mar 31 10:20:00 EDT 2008
[ http://jira.jboss.com/jira/browse/JBSEAM-2802?page=comments#action_12405910 ]
Eric Jung commented on JBSEAM-2802:
This bug is both has both code additions and configuration steps.
In the Websphere Application Server 6.1 (also works in 5.x) administrative console:
1. Define a Resource Environment Provider
a. Goto Resources->Resource Environment->Resource Environment Providers. Press "New"
b. Enter a name. I chose "JPA" but "Seam Bridge" might have been more appropriate. Click "Apply" then "Save".
2. Define a Referenceable
a. From the Resource Environment Provider list, click the Resource Environment Provider you created in step one.
b. Under "Additional Properties", click "Referenceables"
***c. Click "New" and enter com.company.EMFactoryBridge for "Factory Class Name" and javax.persistence.EntityManagerFactory for "Class Name"
d. Click "Apply" then "Save"
3. Define a Resource Environment Entry
a. Goto Resources->Resource Environment->Resource environment entries. Press "New".
b. Ensure the Resource Environment Provider you created in step 1 is selected in the "Provider" drop-down list.
c. Enter EMFactoryBridge (or whatever you like) for "Name". Enter seam/EMFactoryBridge for JNDI name. This is the value Seam will use to instantiate your provider, expecting it to return a javax.persistence.EntityManagerFactory instance.
d. Ensure com.company.EMFactoryBridge is selected in the "Referenceables" drop-down list.
e. Click Apply then Save.
4. Provide the persistence unit name to the EMFactoryBridge
a. Goto Resources->Resource Environment->Resource environment entries and click the entry created in step 3 (EMFactoryBridge)
b. Under Additional Properties, click "Custom properties"
c. Click New
d. Under "Name", enter persistence-unit-name
e. Under "Value", enter the name of the persistence unit in persistence.xml to be used by this EntityManager. This is the attribute "name" on the <persistence-unit/> element. See attached sample. Here I've chosen "bookingDatabase" as the name.
d. Ensure java.lang.String is selected in the "Type" drop-down list.
e. Click Apply then Save.
5. In components.xml, specify seam/EMFactoryBridge (or whatever value is chose in step 3c) for the persistence-unit-jndi-name attribute of the <persistence:managed-persistence-context/> element. See attached example.
6. Ensure the attached class is in your application's CLASSPATH at runtime (not necessary at build time)
You can now use any persistence provider you like, specified in persistence.xml as usual. You can now inject EntityManager instances into non-EJBs using @In (without @PersistenceContext).
*** Hopefully, you'll integrate the attached org.jboss.seam.persistence.EMFactoryBridge patch into the trunk. Then the user can specify org.jboss.seam.persistence.EMFactoryBridge here (not com.company.EMFactoryBridge), and not have to include the attached class in each and every Seam project. Step 6 would also be obsolete.
> Websphere: unable to inject EntityManager into non-EJBs
> Key: JBSEAM-2802
> URL: http://jira.jboss.com/jira/browse/JBSEAM-2802
> Project: JBoss Seam
> Issue Type: Patch
> Components: EJB3
> Environment: Websphere 6.1 with EJB Feature Pack
> Reporter: Eric Jung
> Seam currently is unable to inject EntityManager instances into non-EJB components. Patch attached.
This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators: http://jira.jboss.com/jira/secure/Administrators.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the seam-issues