RSA 8, WAS 7, SCA and JPA 2.0 feature packs
I have an SCA component with a Java implementation and a web service binding. My Java implementation uses JPA for persistence. No matter how I try to configure my projects (1 project with everything, 1 SCA project + 1 JPA project...), I can't get JPA to work properly. Specifically, my JPA beans are not being enhanced, which ends up in an exception being thrown.
Does anybody have an example of a working configuration? I'm very open about the packaging and can do whatever it takes. Thanks!
This topic has been locked.
7 replies Latest Post - 2011-03-04T19:09:31Z by FlorianP.
Pinned topic SCA and JPA
Answered question This question has been answered.
Unanswered question This question has not been answered yet.
Updated on 2011-03-04T19:09:31Z at 2011-03-04T19:09:31Z by FlorianP.
SystemAdmin 110000D4XK126 Posts
Re: SCA and JPA2011-03-02T18:47:53Z in response to SystemAdminHi Victor, here is the exception:
3/2/11 12:52:11:337 EST00000024 DataAccessorI E Error parsing entity types for application HiltonDemo
<openjpa-2.0.1-SNAPSHOT-r422266:980199 fatal user error> org.apache.openjpa.util.MetaDataException: The type "class com.ibm.bedl.jpa.Charge" has not been enhanced.
HasanMuhammad 060001CT108 PostsACCEPTED ANSWER
Re: SCA and JPA2011-03-02T20:05:47Z in response to FlorianP.SCA FEP supports JEE resources that are explicitly wired. However, we do not support impl.java with JPA since there is no architected java:/comp space for implementation.java programs, and further we have no architected place in the SCA contribution for res-refs. If this was supported you could have tied impl.java with EntityManager by binding the @EntityManager to JNDI resource, and then wiring impl.java to this resource.
Both OSGi and JEE define how to cope with res-refs. Hence you'll need an implementation type that is also a JPA container, e.g impl.osgi or impl.jee. For OSGI application, the OSGI FEP ships a sample called "blog" which shows how to do JPA using POJOs and Blueprint. But in SCA FEP, we dont yet have an official sample that shows how to use an OSGI application as a component implementation type.
sutter 120000EB4G1 PostACCEPTED ANSWER
Re: SCA and JPA2011-03-02T20:47:38Z in response to HasanMuhammadHi,
I am not an SCA expert, but I do know a few things about JPA... It sounds like SCA by itself does not provide a "container-like" environment that would support the necessary infrastructure for JPA managed persistence. If you combine SCA with either the OSGi or Java EE runtime, then the infrastructure would be in place.
But, you should (key word here) be able to use JPA in a non-managed or application managed environment. In this case, you would have to ensure that your Entity classes are enhanced during your build process . And, your application would have to take care of creating and managing the EntityManagerFactories and EntityManagers. It's more work on your part, but you would still have the advantage of the JPA programming model and the consistencies that it provides.
Although a little dated (an update should be posted this month), this article  on developer works talks about using OpenJPA in a non-managed WAS v6.1 environment. In my mind, this usage would be similar to what is being requested here for the SCA environment. Essentially, you would be using JPA as a utility framework.
I hope I haven't opened a can of worms for the SCA team... :-)
Re: SCA and JPA2011-03-04T14:52:17Z in response to sutterThanks Kevin, that helped a lot. I was already managing my entity managers, and enhancing the JPA beans at build time solved the problem (I'm still getting errors, but they're purely JPA now).  explains how to proceed for build-time enhancement. I used the OpenJPA eclipse plugin.