Hello, I also have a strange behavior when reloading my tomcat application, it uses hibernate 3.1.3, I upgraded cglib jar to version 2.1.3, trying to find out where the problem could be or if there's some cleanUp() method I forgot to call I included a small code to inspect threadLocals in all threads in the JVM, this is the result: (sorry, I don't know how to format an html table but you can copy this text an open it in a browser)
<table align="center" border="1"><tr><td>threadName</td><td>threadClass</td><td>classLoader</td><td>threadLocals</td></tr>
<tr><td>main</td><td>java.lang.Thread</td><td>org.apache.catalina.loader.StandardClassLoader@e86da0</td><td><table border="1"><tr><td>class</td><td>object</td></tr>
<tr><td>java.lang.Integer</td><td>10</td></tr>
<tr><td>[C</td><td>[C@1779885</td></tr>
<tr><td>java.lang.ref.SoftReference</td><td>java.lang.ref.SoftReference@be76c7 (pointing to: null)</td></tr>
<tr><td>java.lang.ref.SoftReference</td><td>java.lang.ref.SoftReference@682406 (pointing to: null)</td></tr>
</table></td></tr>
<tr><td>StandardManager[/admin]<br>(org.apache.catalina.session.StandardManager)</td><td>java.lang.Thread</td><td>org.apache.catalina.loader.WebappClassLoader@1ad6b4b</td><td><table border="1"><tr><td>class</td><td>object</td></tr>
</table></td></tr>
<tr><td>StandardManager[/manager]<br>(org.apache.catalina.session.StandardManager)</td><td>java.lang.Thread</td><td>org.apache.catalina.loader.WebappClassLoader@2b249</td><td><table border="1"><tr><td>class</td><td>object</td></tr>
</table></td></tr>
<tr><td>HostConfig[localhost]<br>(org.apache.catalina.startup.HostConfig)</td><td>java.lang.Thread</td><td>org.apache.catalina.loader.StandardClassLoader@e86da0</td><td><table border="1"><tr><td>class</td><td>object</td></tr>
</table></td></tr>
<tr><td>http-8080-Processor1<br>(org.apache.tomcat.util.threads.ThreadPool$ControlRunnable)</td><td>org.apache.tomcat.util.threads.ThreadWithAttributes</td><td>org.apache.catalina.loader.StandardClassLoader@e86da0</td><td><table border="1"><tr><td>class</td><td>object</td></tr>
</table></td></tr>
<tr><td>http-8080-Processor2<br>(org.apache.tomcat.util.threads.ThreadPool$ControlRunnable)</td><td>org.apache.tomcat.util.threads.ThreadWithAttributes</td><td>org.apache.catalina.loader.StandardClassLoader@e86da0</td><td><table border="1"><tr><td>class</td><td>object</td></tr>
</table></td></tr>
<tr><td>http-8080-Processor3<br>(org.apache.tomcat.util.threads.ThreadPool$ControlRunnable)</td><td>org.apache.tomcat.util.threads.ThreadWithAttributes</td><td>org.apache.catalina.loader.WebappClassLoader@e222eb</td><td><table border="1"><tr><td>class</td><td>object</td></tr>
<tr><td>[Lnet.sf.cglib.proxy.Callback;</td><td>[Lnet.sf.cglib.proxy.Callback;@74c144</td></tr>
<tr><td>[Lnet.sf.cglib.proxy.Callback;</td><td>[Lnet.sf.cglib.proxy.Callback;@13c765e</td></tr>
<tr><td>[C</td><td>[C@1e3bfb6</td></tr>
<tr><td>[Lnet.sf.cglib.proxy.Callback;</td><td>[Lnet.sf.cglib.proxy.Callback;@7f2036</td></tr>
<tr><td>java.lang.ref.SoftReference</td><td>java.lang.ref.SoftReference@1bd427 (pointing to: java.lang.StringCoding$CharsetSD instance)</td></tr>
<tr><td>[Lnet.sf.cglib.proxy.Callback;</td><td>[Lnet.sf.cglib.proxy.Callback;@1054f93</td></tr>
<tr><td>[Lnet.sf.cglib.proxy.Callback;</td><td>[Lnet.sf.cglib.proxy.Callback;@1ab4292</td></tr>
<tr><td>java.lang.ref.SoftReference</td><td>java.lang.ref.SoftReference@39f16f (pointing to: java.lang.StringCoding$CharsetSE instance)</td></tr>
</table></td></tr>
<tr><td>http-8080-Processor4<br>(org.apache.tomcat.util.threads.ThreadPool$ControlRunnable)</td><td>org.apache.tomcat.util.threads.ThreadWithAttributes</td><td>org.apache.catalina.loader.StandardClassLoader@e86da0</td><td><table border="1"><tr><td>class</td><td>object</td></tr>
<tr><td>[Lnet.sf.cglib.proxy.Callback;</td><td>[Lnet.sf.cglib.proxy.Callback;@9fac35</td></tr>
<tr><td>java.lang.ref.SoftReference</td><td>java.lang.ref.SoftReference@153e0c0 (pointing to: null)</td></tr>
<tr><td>[Lnet.sf.cglib.proxy.Callback;</td><td>[Lnet.sf.cglib.proxy.Callback;@e2e276</td></tr>
<tr><td>java.lang.ref.SoftReference</td><td>java.lang.ref.SoftReference@181c4eb (pointing to: null)</td></tr>
<tr><td>java.lang.ref.SoftReference</td><td>java.lang.ref.SoftReference@1e514a9 (pointing to: null)</td></tr>
<tr><td>[Lnet.sf.cglib.proxy.Callback;</td><td>[Lnet.sf.cglib.proxy.Callback;@a75e9f</td></tr>
<tr><td>java.lang.ref.SoftReference</td><td>java.lang.ref.SoftReference@b91602 (pointing to: null)</td></tr>
<tr><td>[Lnet.sf.cglib.proxy.Callback;</td><td>[Lnet.sf.cglib.proxy.Callback;@3534c1</td></tr>
<tr><td>[C</td><td>[C@1c88f2b</td></tr>
<tr><td>[Lnet.sf.cglib.proxy.Callback;</td><td>[Lnet.sf.cglib.proxy.Callback;@11a7e7f</td></tr>
</table></td></tr>
<tr><td>http-8080-Processor5<br>(org.apache.tomcat.util.threads.ThreadPool$ControlRunnable)</td><td>org.apache.tomcat.util.threads.ThreadWithAttributes</td><td>org.apache.catalina.loader.StandardClassLoader@e86da0</td><td><table border="1"><tr><td>class</td><td>object</td></tr>
<tr><td>[Lnet.sf.cglib.proxy.Callback;</td><td>[Lnet.sf.cglib.proxy.Callback;@af8b32</td></tr>
<tr><td>[Lnet.sf.cglib.proxy.Callback;</td><td>[Lnet.sf.cglib.proxy.Callback;@1c5809e</td></tr>
<tr><td>java.lang.ref.SoftReference</td><td>java.lang.ref.SoftReference@66fcd5 (pointing to: java.lang.StringCoding$CharsetSD instance)</td></tr>
<tr><td>[Lnet.sf.cglib.proxy.Callback;</td><td>[Lnet.sf.cglib.proxy.Callback;@baa573</td></tr>
<tr><td>[Lnet.sf.cglib.proxy.Callback;</td><td>[Lnet.sf.cglib.proxy.Callback;@6e8504</td></tr>
<tr><td>java.lang.ref.SoftReference</td><td>java.lang.ref.SoftReference@2110fc (pointing to: java.lang.StringCoding$CharsetSE instance)</td></tr>
<tr><td>[Lnet.sf.cglib.proxy.Callback;</td><td>[Lnet.sf.cglib.proxy.Callback;@1c44a6d</td></tr>
<tr><td>[Lnet.sf.cglib.proxy.Callback;</td><td>[Lnet.sf.cglib.proxy.Callback;@1f2412a</td></tr>
<tr><td>[Lnet.sf.cglib.proxy.Callback;</td><td>[Lnet.sf.cglib.proxy.Callback;@d9205</td></tr>
<tr><td>[C</td><td>[C@edbca8</td></tr>
<tr><td>[Lnet.sf.cglib.proxy.Callback;</td><td>[Lnet.sf.cglib.proxy.Callback;@194566d</td></tr>
<tr><td>[Lnet.sf.cglib.proxy.Callback;</td><td>[Lnet.sf.cglib.proxy.Callback;@1b64b70</td></tr>
<tr><td>[Lnet.sf.cglib.proxy.Callback;</td><td>[Lnet.sf.cglib.proxy.Callback;@1fcca7b</td></tr>
<tr><td>[Lnet.sf.cglib.proxy.Callback;</td><td>[Lnet.sf.cglib.proxy.Callback;@112bc7b</td></tr>
<tr><td>[Lnet.sf.cglib.proxy.Callback;</td><td>[Lnet.sf.cglib.proxy.Callback;@11456c5</td></tr>
<tr><td>java.lang.ref.SoftReference</td><td>java.lang.ref.SoftReference@b4faeb (pointing to: null)</td></tr>
<tr><td>[Lnet.sf.cglib.proxy.Callback;</td><td>[Lnet.sf.cglib.proxy.Callback;@4ca42b</td></tr>
<tr><td>[Lnet.sf.cglib.proxy.Callback;</td><td>[Lnet.sf.cglib.proxy.Callback;@1ae0e7d</td></tr>
<tr><td>[Lnet.sf.cglib.proxy.Callback;</td><td>[Lnet.sf.cglib.proxy.Callback;@1517e5e</td></tr>
</table></td></tr>
<tr><td>http-8080-Monitor<br>(org.apache.tomcat.util.threads.ThreadPool$MonitorRunnable)</td><td>java.lang.Thread</td><td>org.apache.catalina.loader.StandardClassLoader@e86da0</td><td><table border="1"><tr><td>class</td><td>object</td></tr>
</table></td></tr>
<tr><td>TP-Processor1<br>(org.apache.tomcat.util.threads.ThreadPool$ControlRunnable)</td><td>org.apache.tomcat.util.threads.ThreadWithAttributes</td><td>org.apache.catalina.loader.StandardClassLoader@e86da0</td><td><table border="1"><tr><td>class</td><td>object</td></tr>
</table></td></tr>
<tr><td>TP-Processor2<br>(org.apache.tomcat.util.threads.ThreadPool$ControlRunnable)</td><td>org.apache.tomcat.util.threads.ThreadWithAttributes</td><td>org.apache.catalina.loader.StandardClassLoader@e86da0</td><td><table border="1"><tr><td>class</td><td>object</td></tr>
</table></td></tr>
<tr><td>TP-Processor3<br>(org.apache.tomcat.util.threads.ThreadPool$ControlRunnable)</td><td>org.apache.tomcat.util.threads.ThreadWithAttributes</td><td>org.apache.catalina.loader.StandardClassLoader@e86da0</td><td><table border="1"><tr><td>class</td><td>object</td></tr>
</table></td></tr>
<tr><td>TP-Processor4<br>(org.apache.tomcat.util.threads.ThreadPool$ControlRunnable)</td><td>org.apache.tomcat.util.threads.ThreadWithAttributes</td><td>org.apache.catalina.loader.StandardClassLoader@e86da0</td><td><table border="1"><tr><td>class</td><td>object</td></tr>
</table></td></tr>
<tr><td>TP-Processor5<br>(org.apache.tomcat.util.threads.ThreadPool$ControlRunnable)</td><td>org.apache.tomcat.util.threads.ThreadWithAttributes</td><td>org.apache.catalina.loader.StandardClassLoader@e86da0</td><td><table border="1"><tr><td>class</td><td>object</td></tr>
</table></td></tr>
<tr><td>TP-Monitor<br>(org.apache.tomcat.util.threads.ThreadPool$MonitorRunnable)</td><td>java.lang.Thread</td><td>org.apache.catalina.loader.StandardClassLoader@e86da0</td><td><table border="1"><tr><td>class</td><td>object</td></tr>
</table></td></tr>
<tr><td>Java2D Disposer<br>(sun.java2d.Disposer)</td><td>java.lang.Thread</td><td>org.apache.catalina.loader.WebappClassLoader@419d05</td><td><table border="1"><tr><td>class</td><td>object</td></tr>
</table></td></tr>
<tr><td>WebappLoader[/estructura]<br>(org.apache.catalina.loader.WebappLoader)</td><td>java.lang.Thread</td><td>null</td><td><table border="1"><tr><td>class</td><td>object</td></tr>
</table></td></tr>
<tr><td>estructura gTimer started at 2/01/07 09:52 AM</td><td>java.util.TimerThread</td><td>org.apache.catalina.loader.WebappClassLoader@e222eb</td><td><table border="1"><tr><td>class</td><td>object</td></tr>
</table></td></tr>
<tr><td>StandardManager[/estructura]<br>(org.apache.catalina.session.StandardManager)</td><td>java.lang.Thread</td><td>org.apache.catalina.loader.WebappClassLoader@e222eb</td><td><table border="1"><tr><td>class</td><td>object</td></tr>
</table></td></tr>
</table>
This code is executed after a couple of reloads in my application executing some jsp code that uses hibernate between reloads. The jsp that prints this thread table is executed just after a reload and before calling any code that initializes hibernate. I implemented a ServletContextListener class that executes (among other things) this:
Code:
.
.
.
org.apache.log4j.LogManager.shutdown();
org.apache.commons.logging.LogFactory.releaseAll();
session.set(null); // <-- my session threadlocal (which now I never use, just in case)
session = null;
if (sessionFactory != null)
{
((SessionFactory)sessionFactory).close();
sessionFactory = null;
}
.
.
.
I also reproduced the problem including in my contextInitialized method this code:
Code:
org.hibernate.Session session = HibernateUtil.newSession();
try {
org.hibernate.Transaction transaction = session.beginTransaction();
com.msd.database.sfs.Territory territory = (com.msd.database.sfs.Territory) session.get(com.msd.database.sfs.Territory.class, new Integer(1347));
transaction.commit();
} finally {
session.close();
}
But this code kind of confused me because I don't know which thread is executing it. Just loading an instance of com.msd.database.sfs.Territory generates the problem, this class has references to other classes, this is the .hbm.xml definition:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.msd.database.sfs">
<class
name="Territory"
table="TERRITORY">
<id
name="id_territory"
column="ID_TERRITORY">
<generator class="sequence">
<param name="sequence">id_territory</param>
</generator>
</id>
<many-to-one
name="representative"
class="Representative"
column="ID_REPRESENTATIVE"/>
<many-to-one
name="salesForce"
class="SalesForce"
column="ID_SALESFORCE"/>
<many-to-one
name="district"
class="District"
column="ID_DISTRICT"/>
<set name="bricks"
table="TERRITORY_BRICK"
lazy="true"
cascade="save-update">
<key column="ID_TERRITORY"/>
<many-to-many class="Brick" column="ID_BRICK"/>
</set>
<property name="name" type="string" column="NAME"/>
<property name="code" type="string" column="CODE"/>
<property name="fecha_modificacion" type="string" column="FECHA_MODIFICACION"/>
<property name="usuario_modificacion" type="string" column="USUARIO_MODIFICACION"/>
<property name="active" type="string" column="ACTIVE"/>
<property name="r2005" type="string" column="R2005"/>
<property name="codeIncentives" type="string" column="CODEINCENTIVES"/>
<property name="dateModified" type="timestamp" column="DATEMODIFIED"/>
</class>
</hibernate-mapping>
Any help would be greatly appreciated I don't know what else to do...
I configured my jvm to generate a heap dump automatically and I have many dumps to share, but a .zip dump is over 9MB, If interested just tell me how can I share it.