openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Albert Lee (Closed) (JIRA)" <j...@apache.org>
Subject [jira] [Closed] (OPENJPA-1910) openjpa uses application ClassLoader for resolving BrokerFactory (revisited)
Date Thu, 02 Feb 2012 17:02:52 GMT

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

Albert Lee closed OPENJPA-1910.
-------------------------------


Close issue in preparation for 2.2.0 release.
                
> openjpa uses application ClassLoader for resolving BrokerFactory (revisited)
> ----------------------------------------------------------------------------
>
>                 Key: OPENJPA-1910
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-1910
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: osgi
>    Affects Versions: 2.0.1, 2.1.0, 2.2.0
>         Environment: apache-karaf 2.1.0,  openjdk-1.6.0b18
>            Reporter: Wolfgang Glas
>            Assignee: Rick Curtis
>             Fix For: 2.1.0, 2.2.0
>
>
> We are using openjpa-2.0.1 with a thin wrapper inside apache-karaf.
> The wrapper essentially sets the context class loader to the class loader of the application
bundle and then calls 
>    PersistenceProvider.createEntityManagerFactory(String emName, Map map)
> on the service exported by openjpa.
> We get an exception like cited at the end of this report, which is pretty much the same
issue than OPENJPA-1491, where the exception occurred in the alternate method
>     PersistenceProvider.createContainerEntityManagerFactory(PersistenceUnitInfo pui,
Map m)
> The code in
>  org.apache.openjpa.persistence.PersistenceProviderImpl.getBrokerFactory(PersistenceProviderImpl.java:148)
> reads
>             BrokerFactory factory = getBrokerFactory(cp, poolValue, null);
> , which is exactly the same issue as in OPENJPA-1491, because the null CLassLoader causes
the underlying code to use the context class loader, which is set to the class loader of the
application and not the class loader of the openjpa bundle.
>   Replacing the above mentioned line by
>             BrokerFactory factory = getBrokerFactory(cp, poolValue, BundleUtils.getBundleClassLoader());
>  
> would fix this issue as in OPENJPA-1491.
> (remark: BundleUtils.getBundleClassLoader() return null outside OSGi contexts, so this
code works outside OSGi, too....)
>   Best regards,
>    Wolfgang
> My stack trace is:
> org.osgi.service.blueprint.container.ComponentDefinitionException: Error when instantiating
bean entityManagerFactory of class null
>         at org.apache.aries.blueprint.container.BeanRecipe.getInstance(BeanRecipe.java:233)[7:org.apache.aries.blueprint:0.3.0.incubating-SNAPSHOT]
>         at org.apache.aries.blueprint.container.BeanRecipe.internalCreate(BeanRecipe.java:726)[7:org.apache.aries.blueprint:0.3.0.incubating-SNAPSHOT]
>         at org.apache.aries.blueprint.di.AbstractRecipe.create(AbstractRecipe.java:64)[7:org.apache.aries.blueprint:0.3.0.incubating-SNAPSHOT]
>         at org.apache.aries.blueprint.container.BlueprintRepository.createInstances(BlueprintRepository.java:219)[7:org.apache.aries.blueprint:0.3.0.incubating-SNAPS
> HOT]
>         at org.apache.aries.blueprint.container.BlueprintRepository.createAll(BlueprintRepository.java:147)[7:org.apache.aries.blueprint:0.3.0.incubating-SNAPSHOT]
>         at org.apache.aries.blueprint.container.BlueprintContainerImpl.instantiateEagerComponents(BlueprintContainerImpl.java:624)[7:org.apache.aries.blueprint:0.3.0
> .incubating-SNAPSHOT]
>         at org.apache.aries.blueprint.container.BlueprintContainerImpl.doRun(BlueprintContainerImpl.java:315)[7:org.apache.aries.blueprint:0.3.0.incubating-SNAPSHOT]
>         at org.apache.aries.blueprint.container.BlueprintContainerImpl.run(BlueprintContainerImpl.java:213)[7:org.apache.aries.blueprint:0.3.0.incubating-SNAPSHOT]
>         at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)[:1.6.0_20]
>         at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)[:1.6.0_20]
>         at java.util.concurrent.FutureTask.run(FutureTask.java:166)[:1.6.0_20]
>         at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(ScheduledThreadPoolExecutor.java:165)[:1.6.0_20]
>         at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:266)[:1.6.0_20]
>         at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)[:1.6.0_20]
>         at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)[:1.6.0_20]
>         at java.lang.Thread.run(Thread.java:636)[:1.6.0_20]
> Caused by: <openjpa-2.0.1-r422266:989424 fatal user error> org.apache.openjpa.persistence.ArgumentException:
Could not invoke the static newInstance method on the na
> med factory class "<<openjpa-2.0.1-r422266:989424 fatal user error> org.apache.openjpa.util.UserException:
The named BrokerFactory "org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory" is not valid.>".
>         at org.apache.openjpa.kernel.Bootstrap.newBrokerFactory(Bootstrap.java:70)
>         at org.apache.openjpa.persistence.PersistenceProviderImpl.getBrokerFactory(PersistenceProviderImpl.java:148)
>         at org.apache.openjpa.persistence.PersistenceProviderImpl.createEntityManagerFactory(PersistenceProviderImpl.java:94)
>         at org.apache.openjpa.persistence.PersistenceProviderImpl.createEntityManagerFactory(PersistenceProviderImpl.java:154)
>         at org.apache.openjpa.persistence.PersistenceProviderImpl.createEntityManagerFactory(PersistenceProviderImpl.java:65)
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)[:1.6.0_20]
>         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)[:1.6.0_20]
>         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)[:1.6.0_20]
>         at java.lang.reflect.Method.invoke(Method.java:616)[:1.6.0_20]
>         at org.apache.aries.blueprint.container.AbstractServiceReferenceRecipe$JdkProxyFactory$1.invoke(AbstractServiceReferenceRecipe.java:632)
>         at $Proxy48.createEntityManagerFactory(Unknown Source)
>         at org.clazzes.util.jpa.provider.EntityManagerFactoryFactory.newEntityManagerFactory(EntityManagerFactoryFactory.java:67)
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)[:1.6.0_20]
>         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)[:1.6.0_20]
>         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)[:1.6.0_20]
>         at java.lang.reflect.Method.invoke(Method.java:616)[:1.6.0_20]
>         at org.apache.aries.blueprint.utils.ReflectionUtils.invoke(ReflectionUtils.java:221)[7:org.apache.aries.blueprint:0.3.0.incubating-SNAPSHOT]
>         at org.apache.aries.blueprint.container.BeanRecipe.invoke(BeanRecipe.java:844)[7:org.apache.aries.blueprint:0.3.0.incubating-SNAPSHOT]
>         at org.apache.aries.blueprint.container.BeanRecipe.getInstance(BeanRecipe.java:231)[7:org.apache.aries.blueprint:0.3.0.incubating-SNAPSHOT]
>         ... 15 more
> Caused by: <openjpa-2.0.1-r422266:989424 fatal user error> org.apache.openjpa.persistence.ArgumentException:
The named BrokerFactory "org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory" is not valid.
>         at org.apache.openjpa.kernel.Bootstrap.getFactoryClass(Bootstrap.java:159)
>         at org.apache.openjpa.kernel.Bootstrap.invokeFactory(Bootstrap.java:111)
>         at org.apache.openjpa.kernel.Bootstrap.newBrokerFactory(Bootstrap.java:62)
>         ... 33 more
> Caused by: java.lang.ClassNotFoundException: org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory
>         at java.net.URLClassLoader$1.run(URLClassLoader.java:217)[:1.6.0_20]
>         at java.security.AccessController.doPrivileged(Native Method)[:1.6.0_20]
>         at java.net.URLClassLoader.findClass(URLClassLoader.java:205)[:1.6.0_20]
>         at java.lang.ClassLoader.loadClass(ClassLoader.java:321)[:1.6.0_20]
>         at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)[:1.6.0_20]
>         at java.lang.ClassLoader.loadClass(ClassLoader.java:266)[:1.6.0_20]
>         at java.lang.Class.forName0(Native Method)[:1.6.0_20]
>         at java.lang.Class.forName(Class.java:264)[:1.6.0_20]
>         at org.apache.openjpa.kernel.Bootstrap.getFactoryClass(Bootstrap.java:157)
>         ... 35 more

--
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