While load testing our web app, under high concurrency scenarios, I ran into the following exception while trying to invoke a method on a lazy proxy:
Code:
java.lang.NullPointerException
at javassist.util.proxy.RuntimeSupport$DefaultMethodHandler.invoke(RuntimeSupport.java:37)
at edu.academyart.model.Post_$$_javassist_2.getTextTitles(Post_$$_javassist_2.java)
I'm not sure if it's a known issue, but I couldn't find a hibernate jira issue that described it. I chased it down to be what I believe is a bug in javassist, described here with a possible patch:
http://www.jboss.com/index.html?module= ... 30#4115630
In essence, the javassist proxy class generated for any entity class, which is shared by all instances of that entity class for the given classloader (and hence usually the entire web-app), has a non-thread-safe way of caching the lookups of methods in the class it's proxying, which can lead to the above NPE under high concurrency. Note that this isn't a case of trying to use a single hibernate session with multiple threads...all sessions sharing the same classloader are using the same proxy class, because javassist caches proxy class creation, and the proxy class is maintaining a static cache which is not threadsafe.
I'm posting it here in case others hit the same exception. It's not a hibernate bug, but it's a bug in a hibernate dependency.
-Clint