[jboss-user] [Javassist user questions] - NullPointerException in RuntimeSupport.DefaultMethodHandler.

pmeister do-not-reply at jboss.com
Mon Sep 15 21:23:43 EDT 2008


I'm using javassist-3.8.1.GA with hibernate-core-3.3.0.SP1.  I have a javassist problem that appears to occur when two different threads are doing a JavassistLazyInitializer.getProxy()  on the exact same entity class + id but in two different sessions.  One of the threads ends up in RuntimeSupport.DefaultMethodHandler.invoke() with the "proceed" argument set to null, which results in a NullPointerException.  According to the javadoc for MethodHandler.invoke(), the proceed argument "is null if the overridden mehtod is abstract or declared in the interface", so I'm not sure why DefaultMethodHandler.invoke() doesn't check for null.   But my guess is that there's some sort of race condition causing this.

Here's one thing that might provide a clue:  JavassistLazyInitializer.getProxy() is calling Class.newInstance() to create a new instance of my entity class (Carrier).  The failure happens when a final field is being initialized during construction of that instance.  The final field is declared in an abstract parent class (AbstractCodeParentEntity), and is initialized by calling an inherited method (createStringFieldValue).  In other words, my Carrier entity inherits this field:

    private final FieldValue code = createStringFieldValue("code");

This failure always occurs when createStringFieldValue is executing, so perhaps that provides a clue as to why the "proceed" argument ends up being null.

Please let me know what other information I can provide to help diagnose the problem and whether you can suggest any workarounds.

Below I've included the stack of the two threads that were simultaneously suspended by a setting a conditional breakpoint in Eclipse when proceed == null.  The first is the thread that hit the breakpoint.


Thread [btpool0-0] (Suspended (breakpoint at line 37 in RuntimeSupport$DefaultMethodHandler))	
	RuntimeSupport$DefaultMethodHandler.invoke(Object, Method, Method, Object[]) line: 37	
	Carrier_$$_javassist_70.createStringFieldValue(String) line: not available	
	Carrier_$$_javassist_70(AbstractCodeParentEntity).() line: 17	
	Carrier_$$_javassist_70(Organization).() line: 54	
	Carrier_$$_javassist_70(Carrier).() line: 17	
	Carrier_$$_javassist_70.() line: not available	
	NativeConstructorAccessorImpl.newInstance0(Constructor, Object[]) line: not available [native method]	
	NativeConstructorAccessorImpl.newInstance(Object[]) line: 39	
	DelegatingConstructorAccessorImpl.newInstance(Object[]) line: 27	
	Constructor.newInstance(Object...) line: 513	
	Class.newInstance0() line: 355	
	Class.newInstance() line: 308	
	JavassistLazyInitializer.getProxy(Class, String, Class, Class[], Method, Method, AbstractComponentType, Serializable, SessionImplementor) line: 139	
	JavassistProxyFactory.getProxy(Serializable, SessionImplementor) line: 72	
	PojoEntityTuplizer(AbstractEntityTuplizer).createProxy(Serializable, SessionImplementor) line: 402	
	JoinedSubclassEntityPersister(AbstractEntityPersister).createProxy(Serializable, SessionImplementor) line: 3483	
	DefaultLoadEventListener.createProxyIfNecessary(LoadEvent, EntityPersister, EntityKey, LoadEventListener$LoadType, PersistenceContext) line: 298	
	DefaultLoadEventListener.proxyOrLoad(LoadEvent, EntityPersister, EntityKey, LoadEventListener$LoadType) line: 219	
	DefaultLoadEventListener.onLoad(LoadEvent, LoadEventListener$LoadType) line: 126	
	SessionImpl.fireLoad(LoadEvent, LoadEventListener$LoadType) line: 905	
	SessionImpl.internalLoad(String, Serializable, boolean, boolean) line: 873	
	ManyToOneType(EntityType).resolveIdentifier(Serializable, SessionImplementor) line: 590	
	ManyToOneType(EntityType).resolve(Object, SessionImplementor, Object) line: 412	
	TwoPhaseLoad.initializeEntity(Object, boolean, SessionImplementor, PreLoadEvent, PostLoadEvent) line: 139	
	EntityLoader(Loader).initializeEntitiesAndCollections(List, Object, SessionImplementor, boolean) line: 877	
	EntityLoader(Loader).doQuery(SessionImplementor, QueryParameters, boolean) line: 752	
	EntityLoader(Loader).doQueryAndInitializeNonLazyCollections(SessionImplementor, QueryParameters, boolean) line: 259	
	EntityLoader(Loader).loadEntity(SessionImplementor, Object, Type, Object, String, Serializable, EntityPersister) line: 1881	
	EntityLoader(AbstractEntityLoader).load(SessionImplementor, Object, Object, Serializable) line: 71	
	EntityLoader(AbstractEntityLoader).load(Serializable, Object, SessionImplementor) line: 65	
	SingleTableEntityPersister(AbstractEntityPersister).load(Serializable, Object, LockMode, SessionImplementor) line: 3072	
	DefaultLoadEventListener.loadFromDatasource(LoadEvent, EntityPersister, EntityKey, LoadEventListener$LoadType) line: 434	
	DefaultLoadEventListener.doLoad(LoadEvent, EntityPersister, EntityKey, LoadEventListener$LoadType) line: 415	
	DefaultLoadEventListener.load(LoadEvent, EntityPersister, EntityKey, LoadEventListener$LoadType) line: 165	
	DefaultLoadEventListener.proxyOrLoad(LoadEvent, EntityPersister, EntityKey, LoadEventListener$LoadType) line: 223	
	DefaultLoadEventListener.onLoad(LoadEvent, LoadEventListener$LoadType) line: 126	
	SessionImpl.fireLoad(LoadEvent, LoadEventListener$LoadType) line: 905	
	SessionImpl.get(String, Serializable) line: 842	
	SessionImpl.get(Class, Serializable) line: 835	
	FullTextSessionImpl.get(Class, Serializable) line: 335	
	HivemindFullTextSessionWrapper.get(Class, Serializable) line: 302	
	$FullTextSession_11c689001bf.get(Class, Serializable) line: not available	
	$FullTextSession_11c689001c0.get(Class, Serializable) line: not available	
	BusinessServiceImpl.getById(Long, Class) line: 257	
	$BusinessService_11c6890013b.getById(Long, Class) line: not available	
	$BusinessService_11c6890013a.getById(Long, Class) line: not available	
	EligibilityListenerImpl(AbstractMessageListener).receiveMessage(Reader) line: 134	
	$EligibilityListener_11c68900134.receiveMessage(Reader) line: not available	
	$EligibilityListener_11c68900133.receiveMessage(Reader) line: not available	
	MessageListenerServlet.handlePost(HttpServletRequest, HttpServletResponse) line: 90	
	MessageListenerServlet(AbstractHttpServlet).doPost(HttpServletRequest, HttpServletResponse) line: 99	
	MessageListenerServlet(HttpServlet).service(HttpServletRequest, HttpServletResponse) line: 727	
	MessageListenerServlet(HttpServlet).service(ServletRequest, ServletResponse) line: 820	
	ServletHolder.handle(ServletRequest, ServletResponse) line: 487	
	ServletHandler$CachedChain.doFilter(ServletRequest, ServletResponse) line: 1097	
	HiveMindFilter(HiveMindFilter).doFilter(ServletRequest, ServletResponse, FilterChain) line: 172	
	ServletHandler$CachedChain.doFilter(ServletRequest, ServletResponse) line: 1088	
	ServletHandler.handle(String, HttpServletRequest, HttpServletResponse, int) line: 360	
	SecurityHandler.handle(String, HttpServletRequest, HttpServletResponse, int) line: 216	
	SessionHandler.handle(String, HttpServletRequest, HttpServletResponse, int) line: 181	
	WebAppContext(ContextHandler).handle(String, HttpServletRequest, HttpServletResponse, int) line: 729	
	WebAppContext.handle(String, HttpServletRequest, HttpServletResponse, int) line: 405	
	Server(HandlerWrapper).handle(String, HttpServletRequest, HttpServletResponse, int) line: 152	
	Server.handle(HttpConnection) line: 324	
	HttpConnection.handleRequest() line: 505	
	HttpConnection$RequestHandler.content(Buffer) line: 843	
	HttpParser.parseNext() line: 647	
	HttpParser.parseAvailable() line: 211	
	HttpConnection.handle() line: 380	
	SelectChannelConnector$ConnectorEndPoint(SelectChannelEndPoint).run() line: 395	
	QueuedThreadPool$PoolThread.run() line: 488	

Thread [btpool0-2] (Suspended)	
	Class.getDeclaredMethods0(boolean) line: not available [native method]	
	Class.privateGetDeclaredMethods(boolean) line: 2427	
	Class.getDeclaredMethods() line: 1791	
	SecurityActions.getDeclaredMethods(Class) line: 29	
	RuntimeSupport.findMethod2(Class, String, String) line: 106	
	RuntimeSupport.findMethod(Object, String, String) line: 48	
	Carrier_$$_javassist_70.createStringFieldValue(String) line: not available	
	Carrier_$$_javassist_70(AbstractCodeParentEntity).() line: 17	

	Carrier_$$_javassist_70(Organization).() line: 54	
	Carrier_$$_javassist_70(Carrier).() line: 17	
	Carrier_$$_javassist_70.() line: not available	
	NativeConstructorAccessorImpl.newInstance0(Constructor, Object[]) line: not available [native method]	
	NativeConstructorAccessorImpl.newInstance(Object[]) line: 39	
	DelegatingConstructorAccessorImpl.newInstance(Object[]) line: 27	
	Constructor.newInstance(Object...) line: 513	
	Class.newInstance0() line: 355	
	Class.newInstance() line: 308	
	JavassistLazyInitializer.getProxy(Class, String, Class, Class[], Method, Method, AbstractComponentType, Serializable, SessionImplementor) line: 139	
	JavassistProxyFactory.getProxy(Serializable, SessionImplementor) line: 72	
	PojoEntityTuplizer(AbstractEntityTuplizer).createProxy(Serializable, SessionImplementor) line: 402	
	JoinedSubclassEntityPersister(AbstractEntityPersister).createProxy(Serializable, SessionImplementor) line: 3483	
	DefaultLoadEventListener.createProxyIfNecessary(LoadEvent, EntityPersister, EntityKey, LoadEventListener$LoadType, PersistenceContext) line: 298	
	DefaultLoadEventListener.proxyOrLoad(LoadEvent, EntityPersister, EntityKey, LoadEventListener$LoadType) line: 219	
	DefaultLoadEventListener.onLoad(LoadEvent, LoadEventListener$LoadType) line: 126	
	SessionImpl.fireLoad(LoadEvent, LoadEventListener$LoadType) line: 905	
	SessionImpl.internalLoad(String, Serializable, boolean, boolean) line: 873	
	ManyToOneType(EntityType).resolveIdentifier(Serializable, SessionImplementor) line: 590	
	ManyToOneType(EntityType).resolve(Object, SessionImplementor, Object) line: 412	
	TwoPhaseLoad.initializeEntity(Object, boolean, SessionImplementor, PreLoadEvent, PostLoadEvent) line: 139	
	EntityLoader(Loader).initializeEntitiesAndCollections(List, Object, SessionImplementor, boolean) line: 877	
	EntityLoader(Loader).doQuery(SessionImplementor, QueryParameters, boolean) line: 752	
	EntityLoader(Loader).doQueryAndInitializeNonLazyCollections(SessionImplementor, QueryParameters, boolean) line: 259	
	EntityLoader(Loader).loadEntity(SessionImplementor, Object, Type, Object, String, Serializable, EntityPersister) line: 1881	
	EntityLoader(AbstractEntityLoader).load(SessionImplementor, Object, Object, Serializable) line: 71	
	EntityLoader(AbstractEntityLoader).load(Serializable, Object, SessionImplementor) line: 65	
	SingleTableEntityPersister(AbstractEntityPersister).load(Serializable, Object, LockMode, SessionImplementor) line: 3072	
	DefaultLoadEventListener.loadFromDatasource(LoadEvent, EntityPersister, EntityKey, LoadEventListener$LoadType) line: 434	
	DefaultLoadEventListener.doLoad(LoadEvent, EntityPersister, EntityKey, LoadEventListener$LoadType) line: 415	
	DefaultLoadEventListener.load(LoadEvent, EntityPersister, EntityKey, LoadEventListener$LoadType) line: 165	
	DefaultLoadEventListener.proxyOrLoad(LoadEvent, EntityPersister, EntityKey, LoadEventListener$LoadType) line: 223	
	DefaultLoadEventListener.onLoad(LoadEvent, LoadEventListener$LoadType) line: 126	
	SessionImpl.fireLoad(LoadEvent, LoadEventListener$LoadType) line: 905	
	SessionImpl.get(String, Serializable) line: 842	
	SessionImpl.get(Class, Serializable) line: 835	
	FullTextSessionImpl.get(Class, Serializable) line: 335	
	HivemindFullTextSessionWrapper.get(Class, Serializable) line: 302	
	$FullTextSession_11c689001bf.get(Class, Serializable) line: not available	
	$FullTextSession_11c689001c0.get(Class, Serializable) line: not available	
	BusinessServiceImpl.getById(Long, Class) line: 257	
	$BusinessService_11c6890013b.getById(Long, Class) line: not available	
	$BusinessService_11c6890013a.getById(Long, Class) line: not available	
	EligibilityListenerImpl(AbstractMessageListener).receiveMessage(Reader) line: 134	
	$EligibilityListener_11c68900134.receiveMessage(Reader) line: not available	
	$EligibilityListener_11c68900133.receiveMessage(Reader) line: not available	
	MessageListenerServlet.handlePost(HttpServletRequest, HttpServletResponse) line: 90	
	MessageListenerServlet(AbstractHttpServlet).doPost(HttpServletRequest, HttpServletResponse) line: 99	
	MessageListenerServlet(HttpServlet).service(HttpServletRequest, HttpServletResponse) line: 727	
	MessageListenerServlet(HttpServlet).service(ServletRequest, ServletResponse) line: 820	
	ServletHolder.handle(ServletRequest, ServletResponse) line: 487	
	ServletHandler$CachedChain.doFilter(ServletRequest, ServletResponse) line: 1097	
	HiveMindFilter(HiveMindFilter).doFilter(ServletRequest, ServletResponse, FilterChain) line: 172	
	ServletHandler$CachedChain.doFilter(ServletRequest, ServletResponse) line: 1088	
	ServletHandler.handle(String, HttpServletRequest, HttpServletResponse, int) line: 360	
	SecurityHandler.handle(String, HttpServletRequest, HttpServletResponse, int) line: 216	
	SessionHandler.handle(String, HttpServletRequest, HttpServletResponse, int) line: 181	
	WebAppContext(ContextHandler).handle(String, HttpServletRequest, HttpServletResponse, int) line: 729	
	WebAppContext.handle(String, HttpServletRequest, HttpServletResponse, int) line: 405	
	Server(HandlerWrapper).handle(String, HttpServletRequest, HttpServletResponse, int) line: 152	
	Server.handle(HttpConnection) line: 324	
	HttpConnection.handleRequest() line: 505	
	HttpConnection$RequestHandler.content(Buffer) line: 843	
	HttpParser.parseNext() line: 647	
	HttpParser.parseAvailable() line: 211	
	HttpConnection.handle() line: 380	
	SelectChannelConnector$ConnectorEndPoint(SelectChannelEndPoint).run() line: 395	
	QueuedThreadPool$PoolThread.run() line: 488	


View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4176648#4176648

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4176648



More information about the jboss-user mailing list