-
Enhancement
-
Resolution: Unresolved
-
P3
-
None
-
8, 21
This is a request to add a debug mechanism to log the current ClassLoader (CL) and when the CL changes, what (class.method) might switch the current CL, such as when context CL changes occur using the below calls:
Thread.currentThread().setContextClassLoader();
Thread.currentThread().getContextClassLoader();
This will help investigate situations that lead to ClassNotFoundExceptions, where currently there is no
known way to determine what may have switched the CL. Understanding the context CL changes would help us get to root cause, such as finding the area of code that may have missed resetting the CL.
With the current classloading debug options, we only see which CL loads which classes, but we need to see the details around what changed the CL.
For example, the log file reports the below
ClassNotFoundException (CNFE) because it is attempting to load a class using an
incorrect classloader(CL):
Caused By: java.lang.ClassNotFoundException:
oracle.jbo.client.remote.StringManagerImpl
at java.net.URLClassLoader$1.run(URLClassLoader.java:367)
at java.net.URLClassLoader$1.run(URLClassLoader.java:356)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:355)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:278)
at
oracle.jbo.common.java2.JDK2ClassLoader.loadClassForName(JDK2ClassLoader.java:
34)
at oracle.jbo.common.JBOClass.forName(JBOClass.java:174)
at
oracle.jbo.common.StringManagerFactory.create(StringManagerFactory.java:112)
at
oracle.jbo.common.StringManager.getSingleton(StringManager.java:142)
at
oracle.jbo.common.StringManager.getLocalizedStringFromResourceDef(StringManage
r.java:349)
at
oracle.jbo.common.JboExHelperLocalized.getLocalizedBaseMessage(JboExHelperLoca
lized.java:227)
at
oracle.jbo.JboWarning.getLocalizedBaseMessage(JboWarning.java:353)
at oracle.jbo.JboWarning.writeObject(JboWarning.java:530)
at sun.reflect.GeneratedMethodAccessor16100.invoke(Unknown
Source)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.j
ava:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at
java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:1156)
at
java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1495)
at
java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1431)
at
java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1177)
at
java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1547)
at
java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1508)
at
java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1431)
at
java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1177)
at
java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:347)
at
oracle.adfinternal.controller.util.Utils.verifySerializableCheck(Utils.java:39
3)
at
oracle.adfinternal.controller.util.Utils.verifySerializable(Utils.java:381)
at
oracle.adfinternal.controller.state.ViewPortContextImpl.writeObject(ViewPortCo
ntextImpl.java:1816)
at sun.reflect.GeneratedMethodAccessor1465.invoke(Unknown
Source)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.j
ava:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at
java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:1156)
at
java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1495)
at
java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1431)
at
java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1177)
at
java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:347)
at java.util.HashMap.writeObject(HashMap.java:1130)
at sun.reflect.GeneratedMethodAccessor277.invoke(Unknown
Source)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.j
ava:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at
java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:1156)
at
java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1495)
at
java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1431)
at
java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1177)
at
java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1547)
at
java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:440)
at
java.util.Collections$SynchronizedMap.writeObject(Collections.java:2095)
at sun.reflect.GeneratedMethodAccessor1345.invoke(Unknown
Source)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.j
ava:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at
java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:1156)
at
java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1495)
at
java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1431)
at
java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1177)
at
java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1547)
at
java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1508)
at
java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1431)
at
java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1177)
at
java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1547)
at
java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1508)
at
java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1431)
at
java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1177)
at
java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:347)
at java.util.Hashtable.writeObject(Hashtable.java:961)
at sun.reflect.GeneratedMethodAccessor316.invoke(Unknown
Source)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.j
ava:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at
java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:1156)
at
java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1495)
at
java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1431)
at
java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1177)
at
java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:347)
at
weblogic.servlet.internal.session.ReplicatedSessionData.writeExternal(Replicat
edSessionData.java:175)
at
java.io.ObjectOutputStream.writeExternalData(ObjectOutputStream.java:1458)
at
java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1429)
at
java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1177)
at
java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:347)
at
weblogic.rjvm.MsgAbbrevOutputStream.writeObject(MsgAbbrevOutputStream.java:616
)
at
weblogic.rjvm.MsgAbbrevOutputStream.writeObjectWL(MsgAbbrevOutputStream.java:6
07)
at
weblogic.rmi.internal.ObjectIO.writeObject(ObjectIO.java:38)
at
weblogic.rjvm.BasicOutboundRequest.marshalArgs(BasicOutboundRequest.java:89)
at
weblogic.rmi.internal.BasicRemoteRef.invoke(BasicRemoteRef.java:226)
at
weblogic.cluster.replication.ReplicationManager_1036_WLStub.create(Unknown
Source)
at sun.reflect.GeneratedMethodAccessor1523.invoke(Unknown
Source)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.j
ava:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at
weblogic.cluster.replication.SecureReplicationInvocationHandler$ReplicationSer
vicesInvocationAction.run(SecureReplicationInvocationHandler.java:224)
at
weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.
java:321)
at
weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
at
weblogic.cluster.replication.SecureReplicationInvocationHandler.invoke(SecureR
eplicationInvocationHandler.java:194)
at com.sun.proxy.$Proxy272.create(Unknown Source)
at
weblogic.cluster.replication.ReplicationManager.trySecondary(ReplicationManage
r.java:980)
at
weblogic.cluster.replication.ReplicationManager.createSecondary(ReplicationMan
ager.java:892)
at
weblogic.cluster.replication.ReplicationManager.getPrimary(ReplicationManager.
java:866)
at
weblogic.cluster.replication.ReplicationManager.lookup(ReplicationManager.java
:428)
at
weblogic.servlet.internal.session.ReplicatedSessionContext.lookupSession(Repli
catedSessionContext.java:404)
at
weblogic.servlet.internal.session.ReplicatedSessionContext.getSessionInternal(
ReplicatedSessionContext.java:243)
at
weblogic.servlet.internal.session.ReplicatedSessionContext.getSessionInternal(
ReplicatedSessionContext.java:236)
at
weblogic.servlet.internal.ServletRequestImpl$SessionHelper.getValidSession(Ser
vletRequestImpl.java:3078)
at
weblogic.servlet.internal.ServletRequestImpl$SessionHelper._getSessionInternal
(ServletRequestImpl.java:2584)
at
weblogic.servlet.internal.ServletRequestImpl$SessionHelper.getSessionInternal(
ServletRequestImpl.java:2542)
at
weblogic.servlet.internal.ServletRequestImpl$SessionHelper.getSession(ServletR
equestImpl.java:2532)
at
weblogic.servlet.internal.ServletRequestImpl.getSession(ServletRequestImpl.jav
a:1382)
at
weblogic.servlet.internal.session.ReplicatedSessionContext.lookupAppVersionIdF
orSession(ReplicatedSessionContext.java:565)
at
weblogic.servlet.internal.ServletRequestImpl.findVersionedContext(ServletReque
stImpl.java:1758)
at
weblogic.servlet.internal.ServletRequestImpl.dispatchVersion(ServletRequestImp
l.java:1711)
at
weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1530)
at
weblogic.work.ExecuteThread.execute(ExecuteThread.java:378)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:307)
In the above stack, the method
oracle.jbo.common.java2.JDK2ClassLoader.loadClassForName(JDK2ClassLoader.java:
34
obtains current classloader and uses it to load a class :
ClassLoader cl = getCurrentClassLoader();
return Class.forName(className, true, cl);
The CL returned is a java.net.URLClassLoader (URLCL). However, this WLS thread always sets the
weblogic.utils.classloaders.ChangeAwareClassLoader (CACL) as the current CL at the
start, and it is not clear why the CL was changed.
Logging what changed the CL and why will improve our ability to troubleshoot these situations.
Thread.currentThread().setContextClassLoader();
Thread.currentThread().getContextClassLoader();
This will help investigate situations that lead to ClassNotFoundExceptions, where currently there is no
known way to determine what may have switched the CL. Understanding the context CL changes would help us get to root cause, such as finding the area of code that may have missed resetting the CL.
With the current classloading debug options, we only see which CL loads which classes, but we need to see the details around what changed the CL.
For example, the log file reports the below
ClassNotFoundException (CNFE) because it is attempting to load a class using an
incorrect classloader(CL):
Caused By: java.lang.ClassNotFoundException:
oracle.jbo.client.remote.StringManagerImpl
at java.net.URLClassLoader$1.run(URLClassLoader.java:367)
at java.net.URLClassLoader$1.run(URLClassLoader.java:356)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:355)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:278)
at
oracle.jbo.common.java2.JDK2ClassLoader.loadClassForName(JDK2ClassLoader.java:
34)
at oracle.jbo.common.JBOClass.forName(JBOClass.java:174)
at
oracle.jbo.common.StringManagerFactory.create(StringManagerFactory.java:112)
at
oracle.jbo.common.StringManager.getSingleton(StringManager.java:142)
at
oracle.jbo.common.StringManager.getLocalizedStringFromResourceDef(StringManage
r.java:349)
at
oracle.jbo.common.JboExHelperLocalized.getLocalizedBaseMessage(JboExHelperLoca
lized.java:227)
at
oracle.jbo.JboWarning.getLocalizedBaseMessage(JboWarning.java:353)
at oracle.jbo.JboWarning.writeObject(JboWarning.java:530)
at sun.reflect.GeneratedMethodAccessor16100.invoke(Unknown
Source)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.j
ava:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at
java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:1156)
at
java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1495)
at
java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1431)
at
java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1177)
at
java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1547)
at
java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1508)
at
java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1431)
at
java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1177)
at
java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:347)
at
oracle.adfinternal.controller.util.Utils.verifySerializableCheck(Utils.java:39
3)
at
oracle.adfinternal.controller.util.Utils.verifySerializable(Utils.java:381)
at
oracle.adfinternal.controller.state.ViewPortContextImpl.writeObject(ViewPortCo
ntextImpl.java:1816)
at sun.reflect.GeneratedMethodAccessor1465.invoke(Unknown
Source)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.j
ava:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at
java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:1156)
at
java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1495)
at
java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1431)
at
java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1177)
at
java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:347)
at java.util.HashMap.writeObject(HashMap.java:1130)
at sun.reflect.GeneratedMethodAccessor277.invoke(Unknown
Source)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.j
ava:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at
java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:1156)
at
java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1495)
at
java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1431)
at
java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1177)
at
java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1547)
at
java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:440)
at
java.util.Collections$SynchronizedMap.writeObject(Collections.java:2095)
at sun.reflect.GeneratedMethodAccessor1345.invoke(Unknown
Source)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.j
ava:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at
java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:1156)
at
java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1495)
at
java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1431)
at
java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1177)
at
java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1547)
at
java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1508)
at
java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1431)
at
java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1177)
at
java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1547)
at
java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1508)
at
java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1431)
at
java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1177)
at
java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:347)
at java.util.Hashtable.writeObject(Hashtable.java:961)
at sun.reflect.GeneratedMethodAccessor316.invoke(Unknown
Source)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.j
ava:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at
java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:1156)
at
java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1495)
at
java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1431)
at
java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1177)
at
java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:347)
at
weblogic.servlet.internal.session.ReplicatedSessionData.writeExternal(Replicat
edSessionData.java:175)
at
java.io.ObjectOutputStream.writeExternalData(ObjectOutputStream.java:1458)
at
java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1429)
at
java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1177)
at
java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:347)
at
weblogic.rjvm.MsgAbbrevOutputStream.writeObject(MsgAbbrevOutputStream.java:616
)
at
weblogic.rjvm.MsgAbbrevOutputStream.writeObjectWL(MsgAbbrevOutputStream.java:6
07)
at
weblogic.rmi.internal.ObjectIO.writeObject(ObjectIO.java:38)
at
weblogic.rjvm.BasicOutboundRequest.marshalArgs(BasicOutboundRequest.java:89)
at
weblogic.rmi.internal.BasicRemoteRef.invoke(BasicRemoteRef.java:226)
at
weblogic.cluster.replication.ReplicationManager_1036_WLStub.create(Unknown
Source)
at sun.reflect.GeneratedMethodAccessor1523.invoke(Unknown
Source)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.j
ava:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at
weblogic.cluster.replication.SecureReplicationInvocationHandler$ReplicationSer
vicesInvocationAction.run(SecureReplicationInvocationHandler.java:224)
at
weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.
java:321)
at
weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
at
weblogic.cluster.replication.SecureReplicationInvocationHandler.invoke(SecureR
eplicationInvocationHandler.java:194)
at com.sun.proxy.$Proxy272.create(Unknown Source)
at
weblogic.cluster.replication.ReplicationManager.trySecondary(ReplicationManage
r.java:980)
at
weblogic.cluster.replication.ReplicationManager.createSecondary(ReplicationMan
ager.java:892)
at
weblogic.cluster.replication.ReplicationManager.getPrimary(ReplicationManager.
java:866)
at
weblogic.cluster.replication.ReplicationManager.lookup(ReplicationManager.java
:428)
at
weblogic.servlet.internal.session.ReplicatedSessionContext.lookupSession(Repli
catedSessionContext.java:404)
at
weblogic.servlet.internal.session.ReplicatedSessionContext.getSessionInternal(
ReplicatedSessionContext.java:243)
at
weblogic.servlet.internal.session.ReplicatedSessionContext.getSessionInternal(
ReplicatedSessionContext.java:236)
at
weblogic.servlet.internal.ServletRequestImpl$SessionHelper.getValidSession(Ser
vletRequestImpl.java:3078)
at
weblogic.servlet.internal.ServletRequestImpl$SessionHelper._getSessionInternal
(ServletRequestImpl.java:2584)
at
weblogic.servlet.internal.ServletRequestImpl$SessionHelper.getSessionInternal(
ServletRequestImpl.java:2542)
at
weblogic.servlet.internal.ServletRequestImpl$SessionHelper.getSession(ServletR
equestImpl.java:2532)
at
weblogic.servlet.internal.ServletRequestImpl.getSession(ServletRequestImpl.jav
a:1382)
at
weblogic.servlet.internal.session.ReplicatedSessionContext.lookupAppVersionIdF
orSession(ReplicatedSessionContext.java:565)
at
weblogic.servlet.internal.ServletRequestImpl.findVersionedContext(ServletReque
stImpl.java:1758)
at
weblogic.servlet.internal.ServletRequestImpl.dispatchVersion(ServletRequestImp
l.java:1711)
at
weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1530)
at
weblogic.work.ExecuteThread.execute(ExecuteThread.java:378)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:307)
In the above stack, the method
oracle.jbo.common.java2.JDK2ClassLoader.loadClassForName(JDK2ClassLoader.java:
34
obtains current classloader and uses it to load a class :
ClassLoader cl = getCurrentClassLoader();
return Class.forName(className, true, cl);
The CL returned is a java.net.URLClassLoader (URLCL). However, this WLS thread always sets the
weblogic.utils.classloaders.ChangeAwareClassLoader (CACL) as the current CL at the
start, and it is not clear why the CL was changed.
Logging what changed the CL and why will improve our ability to troubleshoot these situations.