I tried and it works.
Now EMFProviderCMT is clear.
Thank you Alius for your useful assistance.
Giervella
Announcement
Collapse
No announcement yet.
X
-
In your EJB execute following:Code:DataSource ds = DataSource.forName("myJPADataSourceName", req); DSResponse resp = ds.execute(req);
Leave a comment:
-
Context 'java:comp/EJBContext' is visible only into an inizialized EJB, which i can call only through a local or remote interface.
In the moment EMFProviderCMT can be used/accessible in EJB module, how can i make 'java:comp/EJBContext' visible to it?
Thank you,
Giervella
Leave a comment:
-
Hi,
EMFProviderCMT should be used in cases when you want to call JPADataSource functionality from within EJB and want to join same transaction. It should be used/accessible in EJB module.
Regards,
Alius
Leave a comment:
-
Ok.
I have access to actual JPA entity classes, so JPADataSource is able to create new entity instance.
Thank you Alius, now the use of EMFProviderBMT is clear.
Now, about EMFProviderCMT you said:
- EMFProviderCMT looks up transaction in java:comp/EJBContext.
I have a question:
- EMFProviderCMT class is used in the WEB module. How can it lookup java:comp/EJBContext which is visible only by EJB ?
Thank you,
GiervellaLast edited by giervella; 11 Jul 2012, 01:49.
Leave a comment:
-
No problem: CWWJP0029E error code (with some googling) is enough to understand that server can not find (does not have access to) persistence.xml.
Yes, that's right. You can not "borrow" persistence.xml from other module. Same is true for EMFProviderCMT.
Moreover it is not enough have access to persistence.xml. You have to have access to actual JPA entity classes (JPADataSource should be able to create new entity instance).
Looks like you will have to make changes to structure of your project because of EJB class-loading standards (not because of SmartClient).
Regards,
Alius
Leave a comment:
-
Sorry i posted the error message in my language.
The error is:
JPAApplInfo E CWWJP0029E: Server doesn't find persistence unit MY_PERSISTENCE_UNIT in WEBmodule.war and APP_EAR application.
Here my paths:
APP.EAR/EJBmodule.jar/ejbModuleRoot/META-INF/persistence.xml
APP.EAR/EJBmodule.jar/ejbModuleRoot/entity/an_antity.java
APP:EAR/WEBmodule.war/webModuleRoot/server/some_server_side_code.java
I have a EAR project (APP.EAR) which contains the EJB module and the WEB module. So, i deploy the EAR.
But this is the same to deploy the two modules separately, thus are two distinct modules, they have distinct resources context.
Yes, as i said the WEB module cannot access to persistence.xml (nor to JPA mapped entities) because it is in EJB module. This is the reason why i said EMFProviderBMT doesn't match with the framework of my application.
So, what i understand after your last message is that EMFProviderBMT requires a persistence.xml in WEB module, and there is not a way to use a persistence.xml contained in an external module. Is it right?
Thank you alius,
Giervella
Leave a comment:
-
Looks like problem is not in configuration for EMFProviderBMT.
Problem that persistence.xml is not visible to server.
Can you tell me path to persistence.xml in you application, path to JPA mapped entities, path to web application server-side code?
Should look like this: app.ear/someFile.jar/someFolder/.../
You always emphasize that you have persistence.xml in EJB module. Does it mean that you deploy EJB and WEB modules separately?
If yes then you will not have access neither to persistence.xml nor to JPA mapped entities. In this case you should have a copy of jar (with persistence.xml and JPA entities) in your WEB module.
If EJB and WEB modules are in the SAME app then your persistence.xml is in wrong place.
Alius
Leave a comment:
-
To use EMFProviderBMT:
1) i configured JNDI names for EntityManager and EntityManagerFactory as specified in docs http://www.smartclient.com/docs/8.2/...jpaIntegration.
2) i mapped <persistence-context-ref> and <persistence-unit-ref> in web.xml of my WEB module.
Result:
JPAApplInfo E CWWJP0029E: Il server non riesce a trovare l'unità di persistenza MY_PERSISTENCE_UNIT nel modulo WEBmodule.war ed applicazione APP_EAR.
As i said, i have my persistence.xml in EJB module, not in WEB module.
What are the errors in my configuration for EMFProviderBMT?
Thanks Alius,
Giervella
Leave a comment:
-
Both (EMFProviderBMT and EMFProviderCMT) looks up EntityManager and EntityManagerFactory in JNDI (java:comp/env) via configured names.
Difference between these implementations is transaction handling:
EMFProviderBMT looks up transaction in java:comp/UserTransaction;
EMFProviderCMT looks up transaction in java:comp/EJBContext;
EMFProviderBMT actually commits and rolls back transaction;
EMFProviderCMT does nothing on commit (allows container to commit); marks setRollbackOnly() on rollback.
So you have to correctly configure JNDI names for EntityManager and EntityManagerFactory as specified in docs http://www.smartclient.com/docs/8.2/...jpaIntegration
As I said earlier: for your case you must use EMFProviderBMT
Regards,
Alius
Leave a comment:
-
Ok!
As i saw, i have my persistence.xml in the EJB module.
As you know, i cannot use EMFProviderBMT because it expects to find the persistence.xml in the WEB module.
The framework of my application is the following:
- EJB module. Implements JPA facet and EJB facet.
- WEB module. It is the SmartGWT module.
So, EMFProviderBMT (which search the persistence.xml in WEB module, it wants the persistent unit mapped in web.xml) cannot work for me.
EMFProviderCMT is what matches with my application framework. It expects to find a EntityManager of a EJBean mapped in ejb-jar.xml.
So, it tries to lookup a EntityManager resource located in a ejb business logic module (my EJBmodule).
Now, since:
- as you know, EMFProviderCMT tries to lookup the EntityManager from local JNDI namespace (java:comp/env);
- WebSphere 7 doesn't map EntityManager resources neither in global JNDI namespace or in local JNDI namespace (java:comp/env);
my questions are:
1) can i use EMFProviderCMT out of the box?
2) i can manually map an EntityManager in global JNDI namespace.
If i do this, can i force EMFProviderCMT to look up the EntityManager from global JNDI namespace or i have to create my own EMFProviderInterface implementation to do this?
Thank you for your help Alius.
Giervella
Leave a comment:
-
Hi,
You are aleady talking to the person who have written JPADataSource. That is me ;)
Regards,
Alius
Leave a comment:
-
I can not help you with specific answer as long as I do not know structure of your project.
Anyway I would suggest you to find a correct config for standard JPADataSource implementetion with EMFProviderBMT (it is correct transaction usage for this case).
Use additional configs for data sources with EJB invocation. Look in "Additional configurations" section in
http://www.smartclient.com/docs/8.2/...jpaIntegration
Regards,
Alius
Leave a comment:
Leave a comment: