[ 
https://issues.apache.org/jira/browse/ARIES-1181?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14194619#comment-14194619
 ] 

Christian Schneider commented on ARIES-1181:
--------------------------------------------

I think this might really be an issue like accessing DB drivers directly in 
OSGi. 

What you really want to do is to use Eclipselink together with aries jpa 
eclipselink adapter.
Simply also install:
install -s 
mvn:org.apache.aries.jpa/org.apache.aries.jpa.eclipselink.adapter/1.0.0-SNAPSHOT
I will organize a release for it soon.

What you did with exporting the EntityManager as a service will also not work. 
EntityManager is not thread safe so you can not simply create it once and 
export it. You can directly work with the EntityManagerFactory and create and 
close the EM in user code. The smoother way is to use aries jpa and the jpa:* 
blueprint element. It allow to work with the EM like in JEE code by wrapping it 
in a thread safe way.

Example:
<bean id="taskServiceImpl" 
class="net.lr.tasklist.persistence.impl.TaskServiceImpl" 
ext:field-injection="true">
    <tx:transaction method="*" value="Required"/>
    <jpa:context unitname="tasklist" property="em"/>
</bean>

Can you try this?

> Getting a NullPointerException trying to instantiate JPA-related classes
> ------------------------------------------------------------------------
>
>                 Key: ARIES-1181
>                 URL: https://issues.apache.org/jira/browse/ARIES-1181
>             Project: Aries
>          Issue Type: Bug
>          Components: Blueprint
>         Environment: ServiceMix 5.0.0, Mac OS X 10.8.5, Oracle Java 1.7.0_40, 
> EclipseLink 2.5.1, JPA 2.1
>            Reporter: Matt Sicker
>            Priority: Blocker
>         Attachments: jpa-test.tar.gz
>
>
> Due to the JPA blueprint component not supporting JPA 2.1, I thought that I 
> could just manually set up the entity classes using beans and services. 
> However, no matter how I try to configure it, I get an NPE with no useful 
> debugging information available. I'm able to configure a JDBC data source on 
> its own, so I know it's related to the entity beans.
> The error I get is:
> {quote}
> 2014-04-29 15:05:46,929 | WARN  | ervicemix/deploy | BeanRecipe               
>         | ?                                   ? | 8 - 
> org.apache.aries.blueprint.core - 1.4.0 | Object to be destroyed is not an 
> instance of UnwrapperedBeanHolder, type: null
> 2014-04-29 15:05:46,929 | ERROR | ervicemix/deploy | BlueprintContainerImpl   
>         | ?                                   ? | 8 - 
> org.apache.aries.blueprint.core - 1.4.0 | Unable to start blueprint container 
> for bundle com.peapod.jpa-test
> org.osgi.service.blueprint.container.ComponentDefinitionException: Unable to 
> instantiate components
>       at 
> org.apache.aries.blueprint.container.BlueprintContainerImpl.instantiateEagerComponents(BlueprintContainerImpl.java:685)[8:org.apache.aries.blueprint.core:1.4.0]
>       at 
> org.apache.aries.blueprint.container.BlueprintContainerImpl.doRun(BlueprintContainerImpl.java:378)[8:org.apache.aries.blueprint.core:1.4.0]
>       at 
> org.apache.aries.blueprint.container.BlueprintContainerImpl.run(BlueprintContainerImpl.java:269)[8:org.apache.aries.blueprint.core:1.4.0]
>       at 
> org.apache.aries.blueprint.container.BlueprintExtender.createContainer(BlueprintExtender.java:276)[8:org.apache.aries.blueprint.core:1.4.0]
>       at 
> org.apache.aries.blueprint.container.BlueprintExtender.createContainer(BlueprintExtender.java:245)[8:org.apache.aries.blueprint.core:1.4.0]
>       at 
> org.apache.aries.blueprint.container.BlueprintExtender.modifiedBundle(BlueprintExtender.java:235)[8:org.apache.aries.blueprint.core:1.4.0]
>       at 
> org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.customizerModified(BundleHookBundleTracker.java:500)[11:org.apache.aries.util:1.1.0]
>       at 
> org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.customizerModified(BundleHookBundleTracker.java:433)[11:org.apache.aries.util:1.1.0]
>       at 
> org.apache.aries.util.tracker.hook.BundleHookBundleTracker$AbstractTracked.track(BundleHookBundleTracker.java:725)[11:org.apache.aries.util:1.1.0]
>       at 
> org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.bundleChanged(BundleHookBundleTracker.java:463)[11:org.apache.aries.util:1.1.0]
>       at 
> org.apache.aries.util.tracker.hook.BundleHookBundleTracker$BundleEventHook.event(BundleHookBundleTracker.java:422)[11:org.apache.aries.util:1.1.0]
>       at 
> org.apache.felix.framework.util.SecureAction.invokeBundleEventHook(SecureAction.java:1103)[org.apache.felix.framework-4.0.3.jar:]
>       at 
> org.apache.felix.framework.util.EventDispatcher.createWhitelistFromHooks(EventDispatcher.java:695)[org.apache.felix.framework-4.0.3.jar:]
>       at 
> org.apache.felix.framework.util.EventDispatcher.fireBundleEvent(EventDispatcher.java:483)[org.apache.felix.framework-4.0.3.jar:]
>       at 
> org.apache.felix.framework.Felix.fireBundleEvent(Felix.java:4244)[org.apache.felix.framework-4.0.3.jar:]
>       at 
> org.apache.felix.framework.Felix.startBundle(Felix.java:1923)[org.apache.felix.framework-4.0.3.jar:]
>       at 
> org.apache.felix.framework.BundleImpl.start(BundleImpl.java:944)[org.apache.felix.framework-4.0.3.jar:]
>       at 
> org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundle(DirectoryWatcher.java:1263)[7:org.apache.felix.fileinstall:3.2.8]
>       at 
> org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundles(DirectoryWatcher.java:1235)[7:org.apache.felix.fileinstall:3.2.8]
>       at 
> org.apache.felix.fileinstall.internal.DirectoryWatcher.process(DirectoryWatcher.java:524)[7:org.apache.felix.fileinstall:3.2.8]
>       at 
> org.apache.felix.fileinstall.internal.DirectoryWatcher.run(DirectoryWatcher.java:308)[7:org.apache.felix.fileinstall:3.2.8]
> Caused by: java.lang.NullPointerException
>       at 
> org.apache.aries.blueprint.container.BeanRecipe.setProperties(BeanRecipe.java:888)[8:org.apache.aries.blueprint.core:1.4.0]
>       at 
> org.apache.aries.blueprint.container.BeanRecipe.internalCreate2(BeanRecipe.java:820)[8:org.apache.aries.blueprint.core:1.4.0]
>       at 
> org.apache.aries.blueprint.container.BeanRecipe.internalCreate(BeanRecipe.java:787)[8:org.apache.aries.blueprint.core:1.4.0]
>       at 
> org.apache.aries.blueprint.di.AbstractRecipe$1.call(AbstractRecipe.java:79)[8:org.apache.aries.blueprint.core:1.4.0]
>       at java.util.concurrent.FutureTask.run(FutureTask.java:262)[:1.7.0_40]
>       at 
> org.apache.aries.blueprint.di.AbstractRecipe.create(AbstractRecipe.java:88)[8:org.apache.aries.blueprint.core:1.4.0]
>       at 
> org.apache.aries.blueprint.container.BlueprintRepository.createInstances(BlueprintRepository.java:245)[8:org.apache.aries.blueprint.core:1.4.0]
>       at 
> org.apache.aries.blueprint.container.BlueprintRepository.createAll(BlueprintRepository.java:183)[8:org.apache.aries.blueprint.core:1.4.0]
>       at 
> org.apache.aries.blueprint.container.BlueprintContainerImpl.instantiateEagerComponents(BlueprintContainerImpl.java:681)[8:org.apache.aries.blueprint.core:1.4.0]
>       ... 20 more
> {quote}
> I'll attach an example project to demo what I'm using for this test. 



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to