Thanks,
Giervella
Announcement
Collapse
No announcement yet.
X
-
I have both:
a) JPA mapped entity beans bundled in a EJB module;
b) actual logic coded in EJBs (in the same EJB module).
I implement some services in b) mode (as you say, i have code in WEB module which execute my EJBs in EJB module).
I implement other services in a) mode.
As you correctly deduced, my question is about the a) case. My EJB module contains JPA mapped entity beans. So, the related persistence.xml is in EJB module.
As you saw in the snippet of my data-source, actual data manipulation is executed by JPADataSource code.
"myEntityClass" value of schemaBean attribute is the complete class name of a JPA entity bean in EJB module.
You say it is ok to use EMFProviderBMT, but it seems i cannot use it. It wants a persistence unit ref mapped in web.xml (this means it requires to find persistence.xml in WEB module, but my persistence.xml is in EJB module). I tried it days ago, but i had the "persistence unit not found in WEB module" error.
I know there is the way to create my own implementation of EMFProviderInterface.
If no built-in EMFProvider works out of the box for my application, i will create my implementation.
I focus on EMFProviderCMT because it seems it matches with my application framework.
It requires an EntityManager object and a EntityManagerFactory object mapped in ejb-jar.xml (so, in my EJB module).
Leave a comment:
-
Hi,
Lets clarify:
a) do you have JPA mapped beans bundled in EJB modules or
b) do you have actual logic (fetching, updating, removing) coded in your EJBs.
Snippet of your data-source config allows to deduce that it is a). Actual data manipulation is executed by JPADataSource code. It is OK to use EMFProviderBMT.
In case of b) you should implement code which will execute your EJBs.
If your case does not fit to specified above, you can create your own implementation of EMFProviderInterface.
Regards,
Alius
Leave a comment:
-
First, thank you alius for your help.
I don't use EMFProviderBMT because i have my persistence logic in the EJB module (EJBm), not in the WEB module.
Thanks,
Giervella
Leave a comment:
-
Hi,
I haven't seen your code...
Most probably you should use EMFProviderBMT (instead of EMFProviderCMT).
EMFProviderCMT can be used only if you are executing data source logic from within EJB (extremely rare case).
Regards,
Alius
Leave a comment:
-
EMFProviderCMT on WebSphere 7
Hi,
i am trying to integrate SmartGWT (Power 3.0) CMT in my application running on WebSphere 7.
I have a business logic EJBModule (EJBm) and a SmartGWT web application (GwtWEB).
On fetch, EMFProviderCMT tries to get the EntityManager 'persistenceEM' using a java:comp/env lookup.
The error is the following:
[03/07/12 17.36.21:774 CEST] 00000022 SystemOut O === 2012-07-03 17:36:21,774 [ : 3] DEBUG EMF - [builtinApplication.instrJPA_fetch] Initializing default EMF provider: com.isomorphic.jpa.EMFProviderCMT
[03/07/12 17.36.21:778 CEST] 00000022 SystemOut O === 2012-07-03 17:36:21,777 [ : 3] WARN RequestContext - dsRequest.execute() failed:
javax.persistence.PersistenceException: Unable to acquire entity manager.
at com.isomorphic.jpa.EMFProviderCMT.getEntityManager(EMFProviderCMT.java:157)
at com.isomorphic.jpa.EMF.getEntityManager(EMF.java:129)
at com.isomorphic.jpa.JPADataSource.execute(JPADataSource.java:422)
at com.isomorphic.application.AppBase.executeDefaultDSOperation(AppBase.java:721)
at com.isomorphic.application.AppBase.executeAppOperation(AppBase.java:658)
at com.isomorphic.application.AppBase.execute(AppBase.java:491)
at com.isomorphic.datasource.DSRequest.execute(DSRequest.java:1948)
at com.isomorphic.servlet.IDACall.handleDSRequest(IDACall.java:199)
at com.isomorphic.servlet.IDACall.processRPCTransaction(IDACall.java:156)
at com.isomorphic.servlet.IDACall.processRequest(IDACall.java:121)
.
.
at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775)
at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:905)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1604)
Caused by: javax.naming.NameNotFoundException: Name "persistenceEM" not found in context "java:comp/env".
at com.ibm.ws.naming.ipbase.NameSpace.lookupInternal(NameSpace.java:1178)
at com.ibm.ws.naming.ipbase.NameSpace.lookup(NameSpace.java:1095)
at com.ibm.ws.naming.urlbase.UrlContextImpl.lookup(UrlContextImpl.java:1233)
at com.ibm.ws.naming.java.javaURLContextImpl.lookup(javaURLContextImpl.java:395)
at com.ibm.ws.naming.urlbase.UrlContextImpl.lookup(UrlContextImpl.java:1276)
at com.ibm.ws.naming.java.javaURLContextImpl.lookup(javaURLContextImpl.java:364)
at com.isomorphic.jpa.EMFProviderCMT.getEntityManager(EMFProviderCMT.java:155)
... 41 more
I think the problem is the WebSphere JNDI context management. WebSphere doesn't map EntityManager objects in local JNDI context. I can manually map an EntityManager only in global JNDI context.
Is this the cause?
In this case, is there a way to force a lookup from global JNDI context?
These are my main settings:
My JPA settings in server.properties in GwtWEB:
jpa.emfProvider: com.isomorphic.jpa.EMFProviderCMT
jpa.entityManager: persistenceEM
jpa.entityManagerFactory: persistenceEMF
My test.ds.xml in GwtWEB:
<DataSource
ID="test"
serverConstructor="com.isomorphic.jpa.JPADataSource"
autoDeriveSchema="true"
schemaBean="myEntityClass"
>
</DataSource>
My ebj-jar.xml in EJBm:
<session>
<ejb-name>ProvaEAO</ejb-name>
<home>it.ccg.ejbtest.server.eao.ProvaEAOHomeRemote</home>
<remote>it.ccg.ejbtest.server.eao.ProvaEAORemote</remote>
<local-home>it.ccg.ejbtest.server.eao.ProvaEAOHomeLocal</local-home>
<local>it.ccg.ejbtest.server.eao.ProvaEAOLocal</local>
<business-local>it.ccg.ejbtest.server.eao.ProvaEAOBusinessLocal</business-local>
<business-remote>it.ccg.ejbtest.server.eao.ProvaEAOBusinessRemote</business-remote>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
<persistence-context-ref>
<persistence-context-ref-name>persistenceEM</persistence-context-ref-name>
<persistence-unit-name>EJBTestPersistence</persistence-unit-name>
<persistence-context-type>Transaction</persistence-context-type>
</persistence-context-ref>
<persistence-unit-ref>
<persistence-unit-ref-name>persistenceEMF</persistence-unit-ref-name>
<persistence-unit-name>EJBTestPersistence</persistence-unit-name>
</persistence-unit-ref>
</session>
My persistence.xml in EJBm:
<persistence-unit name="EJBTestPersistence" transaction-type="JTA">
.
.
</persistence-unit>
Thanks in advance for your help.Tags: None
Leave a comment: