aries-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Timothy Ward (Assigned) (JIRA)" <j...@apache.org>
Subject [jira] [Assigned] (ARIES-808) Problem with JPAWeavingHook in an environment that uses Composite Bundles
Date Wed, 01 Feb 2012 08:44:58 GMT

     [ https://issues.apache.org/jira/browse/ARIES-808?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Timothy Ward reassigned ARIES-808:
----------------------------------

    Assignee: Timothy Ward
    
> Problem with JPAWeavingHook in an environment that uses Composite Bundles
> -------------------------------------------------------------------------
>
>                 Key: ARIES-808
>                 URL: https://issues.apache.org/jira/browse/ARIES-808
>             Project: Aries
>          Issue Type: Bug
>          Components: JPA
>         Environment: I am using Equinox org.eclipse.osgi_3.7.2.R37x_v20111028-1418.jar
with Apache Aries revision 1187719
>            Reporter: Brian DePradine
>            Assignee: Timothy Ward
>            Priority: Critical
>         Attachments: patch.txt, patch.txt, patch2.txt
>
>
> When running my OSGi application that uses JPA I get the following error:
> java.lang.reflect.InvocationTargetException
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
> 	at java.lang.reflect.Method.invoke(Method.java:611)
> 	at com.ibm.osgi.jpa.jpa2.TestTools.run(TestTools.java:60)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
> 	at java.lang.reflect.Method.invoke(Method.java:611)
> 	at org.apache.aries.blueprint.utils.ReflectionUtils.invoke(ReflectionUtils.java:238)
> 	at org.apache.aries.blueprint.container.BeanRecipe.invoke(BeanRecipe.java:838)
> 	at org.apache.aries.blueprint.container.BeanRecipe.runBeanProcInit(BeanRecipe.java:638)
> 	at org.apache.aries.blueprint.container.BeanRecipe.internalCreate(BeanRecipe.java:726)
> 	at org.apache.aries.blueprint.di.AbstractRecipe$1.call(AbstractRecipe.java:71)
> 	at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:314)
> 	at java.util.concurrent.FutureTask.run(FutureTask.java:149)
> 	at org.apache.aries.blueprint.di.AbstractRecipe.create(AbstractRecipe.java:79)
> 	at org.apache.aries.blueprint.container.BlueprintRepository.createInstances(BlueprintRepository.java:220)
> 	at org.apache.aries.blueprint.container.BlueprintRepository.createAll(BlueprintRepository.java:154)
> 	at org.apache.aries.blueprint.container.BlueprintContainerImpl.instantiateEagerComponents(BlueprintContainerImpl.java:630)
> 	at org.apache.aries.blueprint.container.BlueprintContainerImpl.doRun(BlueprintContainerImpl.java:326)
> 	at org.apache.aries.blueprint.container.BlueprintContainerImpl.run(BlueprintContainerImpl.java:228)
> 	at org.apache.aries.blueprint.utils.threading.impl.DiscardableRunnable.run(DiscardableRunnable.java:48)
> 	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:452)
> 	at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:314)
> 	at java.util.concurrent.FutureTask.run(FutureTask.java:149)
> 	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:109)
> 	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:218)
> 	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:897)
> 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:919)
> 	at java.lang.Thread.run(Thread.java:736)
> Caused by: java.lang.NoClassDefFoundError: org.apache.openjpa.enhance.PersistenceCapable
> 	at java.lang.ClassLoader.defineClassImpl(Native Method)
> 	at java.lang.ClassLoader.defineClass(ClassLoader.java:275)
> 	at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.defineClass(DefaultClassLoader.java:188)
> 	at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.defineClass(ClasspathManager.java:601)
> 	at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findClassImpl(ClasspathManager.java:567)
> 	at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLocalClassImpl(ClasspathManager.java:490)
> 	at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLocalClass_LockClassLoader(ClasspathManager.java:478)
> 	at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLocalClass(ClasspathManager.java:458)
> 	at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.findLocalClass(DefaultClassLoader.java:216)
> 	at org.eclipse.osgi.internal.loader.BundleLoader.findLocalClass(BundleLoader.java:400)
> 	at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:476)
> 	at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:429)
> 	at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:417)
> 	at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
> 	at java.lang.ClassLoader.loadClass(ClassLoader.java:619)
> 	at java.lang.Class.forNameImpl(Native Method)
> 	at java.lang.Class.forName(Class.java:172)
> 	at org.apache.openjpa.meta.MetaDataRepository.classForName(MetaDataRepository.java:1552)
> 	at org.apache.openjpa.meta.MetaDataRepository.loadPersistentTypesInternal(MetaDataRepository.java:1528)
> 	at org.apache.openjpa.meta.MetaDataRepository.loadPersistentTypes(MetaDataRepository.java:1506)
> 	at org.apache.openjpa.kernel.AbstractBrokerFactory.loadPersistentTypes(AbstractBrokerFactory.java:282)
> 	at org.apache.openjpa.kernel.AbstractBrokerFactory.initializeBroker(AbstractBrokerFactory.java:238)
> 	at org.apache.openjpa.kernel.AbstractBrokerFactory.newBroker(AbstractBrokerFactory.java:212)
> 	at org.apache.openjpa.kernel.DelegatingBrokerFactory.newBroker(DelegatingBrokerFactory.java:156)
> 	at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:227)
> 	at com.ibm.ws.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:50)
> 	at com.ibm.ws.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:35)
> 	at org.apache.aries.jpa.container.impl.CountingEntityManagerFactory.createEntityManager(CountingEntityManagerFactory.java:65)
> 	at Proxy476b6bea_8a4d_42a3_ba7d_e0257275a826.createEntityManager(Unknown Source)
> 	at com.ibm.osgi.jpa.jpa2.NewAPITest.primeDB(NewAPITest.java:86)
> 	at com.ibm.osgi.jpa.jpa2.NewAPITest.before(NewAPITest.java:35)
> 	... 31 more
> Caused by: java.lang.ClassNotFoundException: org.apache.openjpa.enhance.PersistenceCapable
> 	at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:513)
> 	at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:429)
> 	at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:417)
> 	at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
> 	at java.lang.ClassLoader.loadClass(ClassLoader.java:619)
> 	... 62 more
> I am using Apache Aries with Composite Bundles in order to run my application. Due to
the fact that we are using OSGi 4.3 we are using the JPAWeavingHook to perform load time enhancement
of our entities. The JPAWeavingHook makes use of the org.apache.aries.jpa.container.weaving.impl.WrappingTransformer
to help it determine which packages need to be added as dynamic imports. It contains the following
code:
>   public WrappingTransformer(ClassTransformer delegate,
>       ServiceReference<?> persistenceProvider) {
>     if(delegate == null) 
>       throw new NullPointerException(NLS.MESSAGES.getMessage("jpa.weaving.null.transformer"));
>     
>     if(persistenceProvider == null) {
>       throw new NullPointerException(NLS.MESSAGES.getMessage("jpa.weaving.null.provider"));
>     }
>     
>     this.delegate = delegate;
>     
>     Object packages = persistenceProvider.getProperty("org.apache.aries.jpa.container.weaving.packages");
>     
>     Bundle provider = persistenceProvider.getBundle();
>     String suffix = ";" + Constants.BUNDLE_SYMBOLICNAME_ATTRIBUTE + "=" +
>     provider.getSymbolicName() + ";" + Constants.BUNDLE_VERSION_ATTRIBUTE 
>     + "=" + provider.getVersion();
>     
>     if(packages instanceof String[]) {
>       for(String s : (String[]) packages) {
>         if (s.contains(Constants.BUNDLE_SYMBOLICNAME_ATTRIBUTE)) packageImportsToAdd.add(s);
>         else packageImportsToAdd.add(s + suffix);
>       }
>     } else {
>       BundleRevision br = provider.adapt(BundleWiring.class).getRevision();
>       for(BundleCapability bc : br.getDeclaredCapabilities(BundleRevision.PACKAGE_NAMESPACE))
{
>         packageImportsToAdd.add(bc.getAttributes().get(BundleRevision.PACKAGE_NAMESPACE)
+ suffix);
>       }
>     }
>   }
> The problem is that the suffix is meant to tie the dynamic imports to the persistence
provider bundle so that they only work if the packages come from that bundle. When using Composite
Bundles, however, the bundle that provides those packages will be the surrogate bundle and
not the original persistence provider bundle. This results in the ClassNotFoundException listed
above. As a workaround I can remove the suffix so that the imports can be used from any bundle,
but I am not sure what the long term fix should be that would allow the JPAWeavingHook to
work both with and without Composite Bundles.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Mime
View raw message