<html>
<head>
<style>
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Verdana
}
</style>
</head>
<body class='hmmessage'>
Hi,<br><br>We had an issue in our project where large hql expressions holding on lock to ChangeAwareClassloader in weblogic. <br>We had an hql query which was like <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>select * from ClassA a where a.identifier = 'id1' or a.identifier='id2' or .....&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; a.identifier='id1000'.<br><br>This was certainly bad to have this big or expression, but an issue this caused in weblogic is something interesting.<br>Hibernate query engine processes each identifier in a query to see if its a Java Class. So for each one of ClassA, a.identifier etc it calls Class.forName, if NoClassDefFound exception is thrown, ReflectHelper.getConstantValue returns null.<br><br>Now the problem is, if the expression is huge, recursive calls to /NodeTraverser.visitDepthFirst create huge stack trace. While building ClassNotFoundException, system class loader gets stuck to build all this stack trace. Because weblogic/utils/classloaders/ChangeAwareClassLoader.loadClass method is synchronized, any other thread trying to load any other class is blocked. If the stack trace is huge and taking consideratble amount of time to create Exception object, the lock is held for that much time, blocking every other thread trying to any the class. It brought down our servers in test environment.<br><br>Is this a known issue in weblogic and hibernate? I know that building such a large expression is bad(and we have already changed the code which was doing that), but the way its blocking the classloader in weblogic is an issue I think. <br><br>Following is the thread dump.<br><br>"[STUCK] ExecuteThread: '9' for queue: 'weblogic.kernel.Default (self-tuning)'" id=614 idx=0x3f8 tid=15385 prio=1 alive, in native, daemon<br>&nbsp;&nbsp;&nbsp; at pthread_cond_wait@@GLIBC_2.3.2+170(:0)@0x318c008a7a<br>&nbsp;&nbsp;&nbsp; at vmtWaitUntilNotSoftSuspended+66(:0)@0x2a955e35c2<br>&nbsp;&nbsp;&nbsp; at find_codeinfo+138(:0)@0x2a955b032e<br>&nbsp;&nbsp;&nbsp; at cmFindStackCodeInfoWithHint+44(:0)@0x2a955b040e<br>&nbsp;&nbsp;&nbsp; at frameIterFindCodeInfo+19(:0)@0x2a9571b11f<br>&nbsp;&nbsp;&nbsp; at frameIterGetCurrentAndStep+130(:0)@0x2a9571b489<br>&nbsp;&nbsp;&nbsp; at jniFillInStackTrace+368(:0)@0x2a95630d25<br>&nbsp;&nbsp;&nbsp; at JVM_FillInStackTrace+9(:0)@0x2a95647661<br>&nbsp;&nbsp;&nbsp; at RJNI_jrockit_vm_Reflect_fillInStackTrace0+9(:0)@0x2a956f5983<br>&nbsp;&nbsp;&nbsp; at jrockit/vm/Reflect.fillInStackTrace0(Ljava/lang/Throwable;)V(Native Method)<br>&nbsp;&nbsp;&nbsp; at java/lang/Throwable.fillInStackTrace()Ljava/lang/Throwable;(Native Method)[optimized]<br>&nbsp;&nbsp;&nbsp; at java/lang/Throwable.&lt;init&gt;(Throwable.java:218)[optimized]<br>&nbsp;&nbsp;&nbsp; at java/lang/Exception.&lt;init&gt;(Exception.java:59)[inlined]<br>&nbsp;&nbsp;&nbsp; at java/lang/ClassNotFoundException.&lt;init&gt;(ClassNotFoundException.java:65)[optimized]<br>&nbsp;&nbsp;&nbsp; at java/net/URLClassLoader$1.run(URLClassLoader.java:200)[inlined]<br>&nbsp;&nbsp;&nbsp; at jrockit/vm/AccessController.doPrivileged(AccessController.java:255)[inlined]<br>&nbsp;&nbsp;&nbsp; at java/net/URLClassLoader.findClass(URLClassLoader.java:188)[optimized]<br>&nbsp;&nbsp;&nbsp; at java/lang/ClassLoader.loadClass(ClassLoader.java:306)[optimized]<br>&nbsp;&nbsp;&nbsp; ^-- Holding lock: java/net/URLClassLoader@0x4993580[thin lock]<br>&nbsp;&nbsp;&nbsp; at java/lang/ClassLoader.loadClass(ClassLoader.java:299)[optimized]<br>&nbsp;&nbsp;&nbsp; ^-- Holding lock: weblogic/utils/classloaders/GenericClassLoader@0x469e900[thin lock]<br>&nbsp;&nbsp;&nbsp; at java/lang/ClassLoader.loadClass(ClassLoader.java:251)[inlined]<br>&nbsp;&nbsp;&nbsp; at weblogic/utils/classloaders/GenericClassLoader.loadClass(GenericClassLoader.java:158)[optimized]<br>&nbsp;&nbsp;&nbsp; at weblogic/utils/classloaders/FilteringClassLoader.findClass(FilteringClassLoader.java:83)[inlined]<br>&nbsp;&nbsp;&nbsp; at weblogic/utils/classloaders/FilteringClassLoader.loadClass(FilteringClassLoader.java:68)[optimized]<br>&nbsp;&nbsp;&nbsp; at java/lang/ClassLoader.loadClass(ClassLoader.java:299)[optimized]<br>&nbsp;&nbsp;&nbsp; ^-- Holding lock: weblogic/utils/classloaders/GenericClassLoader@0x4969138[thin lock]<br>&nbsp;&nbsp;&nbsp; at java/lang/ClassLoader.loadClass(ClassLoader.java:299)[inlined]<br>&nbsp;&nbsp;&nbsp; at java/lang/ClassLoader.loadClass(ClassLoader.java:251)[inlined]<br>&nbsp;&nbsp;&nbsp; at weblogic/utils/classloaders/GenericClassLoader.loadClass(GenericClassLoader.java:158)[inlined]<br>&nbsp;&nbsp;&nbsp; at weblogic/utils/classloaders/ChangeAwareClassLoader.loadClass(ChangeAwareClassLoader.java:35)[optimized]<br>&nbsp;&nbsp;&nbsp; ^-- Holding lock: weblogic/utils/classloaders/ChangeAwareClassLoader@0x4915178[recursive]<br>&nbsp;&nbsp;&nbsp; at jrockit/vm/Classes.loadClassInternal(Classes.java:75)[optimized]<br>&nbsp;&nbsp;&nbsp; ^-- Holding lock: weblogic/utils/classloaders/ChangeAwareClassLoader@0x4915178[fat lock]<br>&nbsp;&nbsp;&nbsp; at jrockit/vm/RNI.c2java(JJJJJ)V(Native Method)<br>&nbsp;&nbsp;&nbsp; at jrockit/vm/Classes.forName0(Ljava/lang/String;ZLjava/lang/ClassLoader;)Ljava/lang/Class;(Native Method)<br>&nbsp;&nbsp;&nbsp; at jrockit/vm/Classes.forName(Classes.java:125)[inlined]<br>&nbsp;&nbsp;&nbsp; at java/lang/Class.forName(Class.java:164)[inlined]<br>&nbsp;&nbsp;&nbsp; at org/hibernate/util/ReflectHelper.classForName(ReflectHelper.java:100)[inlined]<br>&nbsp;&nbsp;&nbsp; at org/hibernate/util/ReflectHelper.getConstantValue(ReflectHelper.java:122)[inlined]<br>&nbsp;&nbsp;&nbsp; at org/hibernate/hql/ast/QueryTranslatorImpl$JavaConstantConverter.handleDotStructure(QueryTranslatorImpl.java:569)[inlined]<br>&nbsp;&nbsp;&nbsp; at org/hibernate/hql/ast/QueryTranslatorImpl$JavaConstantConverter.visit(QueryTranslatorImpl.java:564)[optimized]<br>&nbsp;&nbsp;&nbsp; at org/hibernate/hql/ast/util/NodeTraverser.visitDepthFirst(NodeTraverser.java:40)[optimized]<br><br><br>Following is part of thread dump which shows a thread waiting for Classloader lock.<br><br>"[ACTIVE] ExecuteThread: '51' for queue: 'weblogic.kernel.Default (self-tuning)'" id=7096 idx=0x6f8 tid=7459 prio=5 alive, in native, blocked, daemon<br>&nbsp;&nbsp;&nbsp; -- Blocked trying to get lock: weblogic/utils/classloaders/ChangeAwareClassLoader@0x4915178[fat lock]<br>&nbsp;&nbsp;&nbsp; at pthread_cond_wait@@GLIBC_2.3.2+170(:0)@0x318c008a7a<br>&nbsp;&nbsp;&nbsp; at tsiWaitForSignalForever+58(:0)@0x2a957035b5<br>&nbsp;&nbsp;&nbsp; at tsiWaitForSignal+39(:0)@0x2a95703610<br>&nbsp;&nbsp;&nbsp; at tsiWaitForLockSignal+39(:0)@0x2a957036f6<br>&nbsp;&nbsp;&nbsp; at tsWaitForJavaLockSignal+31(:0)@0x2a957037a5<br>&nbsp;&nbsp;&nbsp; at RJNI_jrockit_vm_Threads_waitForUnblockSignal+14(:0)@0x2a956f7620<br>&nbsp;&nbsp;&nbsp; at jrockit/vm/Threads.waitForUnblockSignal()V(Native Method)<br>&nbsp;&nbsp;&nbsp; at jrockit/vm/Locks.fatLockBlockOrSpin(Locks.java:1674)[optimized]<br>&nbsp;&nbsp;&nbsp; at jrockit/vm/Locks.lockFat(Locks.java:1775)[optimized]<br>&nbsp;&nbsp;&nbsp; at jrockit/vm/Locks.monitorEnterSecondStageHard(Locks.java:1311)[optimized]<br>&nbsp;&nbsp;&nbsp; at jrockit/vm/Locks.monitorEnterSecondStage(Locks.java:1258)[optimized]<br>&nbsp;&nbsp;&nbsp; at weblogic/utils/classloaders/ChangeAwareClassLoader.loadClass(ChangeAwareClassLoader.java:35)[optimized]<br>&nbsp;&nbsp;&nbsp; at com/sun/org/apache/xerces/internal/impl/dv/ObjectFactory.findProviderClass(ObjectFactory.java:403)[inlined]<br>&nbsp;&nbsp;&nbsp; at com/sun/org/apache/xerces/internal/impl/dv/ObjectFactory.newInstance(ObjectFactory.java:354)[inlined]<br>&nbsp;&nbsp;&nbsp; at com/sun/org/apache/xerces/internal/impl/dv/DTDDVFactory.getInstance(DTDDVFactory.java:98)[optimized]<br>&nbsp;&nbsp;&nbsp; ^-- Holding lock: java/lang/Class@0x4fba6b8[recursive]<br>&nbsp;&nbsp;&nbsp; at com/sun/org/apache/xerces/internal/impl/dv/DTDDVFactory.getInstance(DTDDVFactory.java:83)[inlined]<br>&nbsp;&nbsp;&nbsp; at com/sun/org/apache/xerces/internal/parsers/XML11Configuration.&lt;init&gt;(XML11Configuration.java:565)[inlined]<br><br><br>Thanks,<br>Unmesh<br><br>&nbsp;<br><br><br><hr>Make sure your wardrobe reflects the latest trends and styles in the world of fashion. <a href="http://lifestyle.in.msn.com/">Try it!</a><br /><hr />Get easy photo sharing with Windows Live™ Photos. <a href='http://www.microsoft.com/windows/windowslive/photos.aspx' target='_new'>Drag n’ drop</a></body>
</html>