You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by "Matthew Robson (JIRA)" <ji...@apache.org> on 2015/08/12 15:52:45 UTC
[jira] [Created] (OPENJPA-2606) Global Property File openjpa.xml is
not usable in an OSGi environment
Matthew Robson created OPENJPA-2606:
---------------------------------------
Summary: Global Property File openjpa.xml is not usable in an OSGi environment
Key: OPENJPA-2606
URL: https://issues.apache.org/jira/browse/OPENJPA-2606
Project: OpenJPA
Issue Type: Bug
Components: lib, osgi
Affects Versions: 2.3.0
Reporter: Matthew Robson
Attempting to use openjpa.xml in an OSGi environment, the container ends up looking for the openjpa.xml file within the classpath of the OpenJPA bundle and not the application bundle as seen below.
Karaf Shell Console Thread[1] print getClass().getClassLoader()
getClass().getClassLoader() = "org.apache.openjpa [316]"
Karaf Shell Console Thread[1] print loader._loaders
loader._loaders = "[sun.misc.Launcher$AppClassLoader@77abfbdc, org.apache.openjpa [316]]"
Step completed: "thread=Karaf Shell Console Thread", org.apache.openjpa.persistence.PersistenceProductDerivation.getResourceURLs(), line=495 bci=71
Karaf Shell Console Thread[1] locals
Method arguments:
rsrc = "META-INF/openjpa.xml"
loader = instance of org.apache.openjpa.lib.util.MultiClassLoader(id=10453)
Local variables:
urls = instance of sun.misc.CompoundEnumeration(id=10468)
Karaf Shell Console Thread[1] print rsrc
rsrc = "META-INF/openjpa.xml"
Karaf Shell Console Thread[1] dump urls
urls = {
enums: instance of java.util.Enumeration[2] (id=10469)
index: 2
}
Karaf Shell Console Thread[1] dump urls.enums
urls.enums = {
instance of java.lang.ClassLoader$2(id=10470), instance of java.util.Vector$1(id=10471)
}
Karaf Shell Console Thread[1] dump urls.enums[0]
urls.enums[0] = {
val$e: instance of sun.misc.URLClassPath$2(id=10474)
}
Karaf Shell Console Thread[1] dump urls.enums[0].val$e
urls.enums[0].val$e = {
index: 17
res: null
val$name: "META-INF/openjpa.xml"
val$check: true
this$0: instance of sun.misc.URLClassPath(id=10475)
}
Karaf Shell Console Thread[1] dump urls.enums[0].val$e.this$0
urls.enums[0].val$e.this$0 = {
USER_AGENT_JAVA_VERSION: "UA-Java-Version"
JAVA_VERSION: "1.7.0_71"
DEBUG: false
DISABLE_JAR_CHECKING: false
path: instance of java.util.ArrayList(id=10478)
urls: instance of java.util.Stack(id=10479)
loaders: instance of java.util.ArrayList(id=10480)
lmap: instance of java.util.HashMap(id=10481)
jarHandler: instance of sun.net.www.protocol.jar.Handler(id=10482)
closed: false
}
It looks like loadGlobals is getting the CL from here and it does not take the OSGi bundle CL into consideration.
https://github.com/apache/openjpa/blob/2.3.0/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ConfigurationImpl.java#L178
MultiClassLoader loader = AccessController.doPrivileged(J2DoPrivHelper.newMultiClassLoaderAction());
loader.addClassLoader(AccessController.doPrivileged(J2DoPrivHelper.getContextClassLoaderAction()));
loader.addClassLoader(getClass().getClassLoader());
ConfigurationProvider provider = ProductDerivations.loadGlobals(loader);
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)