Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Got NPE on Marshall with JAX-RS and multi requests(When I use org.eclipse.persistence.jaxb.JAXBContextFactory and two requests get concurrency I got NullPointerException)
Got NPE on Marshall with JAX-RS and multi requests [message #1265995] Thu, 06 March 2014 21:14 Go to next message
Clovis Wichoski is currently offline Clovis WichoskiFriend
Messages: 7
Registered: March 2012
Junior Member
Hi,

I'm using EclipseLink 2.5.1 with JAX-RS and now I got a strange problem, that I think its about multi-threads, the error occurs when I call in parallel REST resources from same client session, if I call the one, then another not in parallel, the NPE dont occurs:

here the full stack for parallel case:

WARNING: WebApplicationException cause:
javax.xml.bind.MarshalException
 - with linked exception:
[java.lang.NullPointerException]
	at org.eclipse.persistence.jaxb.JAXBMarshaller.marshal(JAXBMarshaller.java:539)
	at de.odysseus.staxon.json.jaxb.JsonXMLBinder.marshal(JsonXMLBinder.java:127)
	at de.odysseus.staxon.json.jaxb.JsonXMLBinder.writeObject(JsonXMLBinder.java:155)
	at de.odysseus.staxon.json.jaxrs.jaxb.JsonXMLObjectProvider.write(JsonXMLObjectProvider.java:80)
	at de.odysseus.staxon.json.jaxrs.jaxb.AbstractJsonXMLProvider.writeTo(AbstractJsonXMLProvider.java:135)
	at org.glassfish.jersey.message.internal.WriterInterceptorExecutor$TerminalWriterInterceptor.invokeWriteTo(WriterInterceptorExecutor.java:243)
	at org.glassfish.jersey.message.internal.WriterInterceptorExecutor$TerminalWriterInterceptor.aroundWriteTo(WriterInterceptorExecutor.java:230)
	at org.glassfish.jersey.message.internal.WriterInterceptorExecutor.proceed(WriterInterceptorExecutor.java:149)
	at org.glassfish.jersey.server.internal.JsonWithPaddingInterceptor.aroundWriteTo(JsonWithPaddingInterceptor.java:103)
	at org.glassfish.jersey.message.internal.WriterInterceptorExecutor.proceed(WriterInterceptorExecutor.java:149)
	at org.glassfish.jersey.server.internal.MappableExceptionWrapperInterceptor.aroundWriteTo(MappableExceptionWrapperInterceptor.java:88)
	at org.glassfish.jersey.message.internal.WriterInterceptorExecutor.proceed(WriterInterceptorExecutor.java:149)
	at org.glassfish.jersey.message.internal.MessageBodyFactory.writeTo(MessageBodyFactory.java:1139)
	at org.glassfish.jersey.server.ServerRuntime$Responder.writeResponse(ServerRuntime.java:557)
	at org.glassfish.jersey.server.ServerRuntime$Responder.processResponse(ServerRuntime.java:381)
	at org.glassfish.jersey.server.ServerRuntime$Responder.process(ServerRuntime.java:371)
	at org.glassfish.jersey.server.ServerRuntime$1.run(ServerRuntime.java:262)
	at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271)
	at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267)
	at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
	at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
	at org.glassfish.jersey.internal.Errors.process(Errors.java:267)
	at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:318)
	at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:236)
	at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:983)
	at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:361)
	at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:372)
	at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:335)
	at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:218)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
	at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1023)
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
	at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
	at java.lang.Thread.run(Thread.java:744)
Caused by: java.lang.NullPointerException
	at org.eclipse.persistence.internal.oxm.XMLCompositeObjectMappingNodeValue.marshal(XMLCompositeObjectMappingNodeValue.java:145)
	at org.eclipse.persistence.internal.oxm.NodeValue.marshal(NodeValue.java:102)
	at org.eclipse.persistence.internal.oxm.record.ObjectMarshalContext.marshal(ObjectMarshalContext.java:59)
	at org.eclipse.persistence.internal.oxm.XPathNode.marshal(XPathNode.java:401)
	at org.eclipse.persistence.internal.oxm.XPathObjectBuilder.buildRow(XPathObjectBuilder.java:240)
	at org.eclipse.persistence.internal.oxm.TreeObjectBuilder.buildRow(TreeObjectBuilder.java:118)
	at org.eclipse.persistence.internal.oxm.TreeObjectBuilder.buildRow(TreeObjectBuilder.java:1)
	at org.eclipse.persistence.internal.oxm.XMLCompositeCollectionMappingNodeValue.marshalSingleValue(XMLCompositeCollectionMappingNodeValue.java:328)
	at org.eclipse.persistence.internal.oxm.XMLCompositeCollectionMappingNodeValue.marshal(XMLCompositeCollectionMappingNodeValue.java:108)
	at org.eclipse.persistence.internal.oxm.NodeValue.marshal(NodeValue.java:149)
	at org.eclipse.persistence.internal.oxm.NodeValue.marshal(NodeValue.java:102)
	at org.eclipse.persistence.internal.oxm.record.ObjectMarshalContext.marshal(ObjectMarshalContext.java:59)
	at org.eclipse.persistence.internal.oxm.XPathNode.marshal(XPathNode.java:401)
	at org.eclipse.persistence.internal.oxm.XPathObjectBuilder.buildRow(XPathObjectBuilder.java:240)
	at org.eclipse.persistence.internal.oxm.TreeObjectBuilder.buildRow(TreeObjectBuilder.java:118)
	at org.eclipse.persistence.internal.oxm.TreeObjectBuilder.buildRow(TreeObjectBuilder.java:1)
	at org.eclipse.persistence.internal.oxm.XMLMarshaller.marshal(XMLMarshaller.java:751)
	at org.eclipse.persistence.internal.oxm.XMLMarshaller.marshal(XMLMarshaller.java:571)
	at org.eclipse.persistence.jaxb.JAXBMarshaller.marshal(JAXBMarshaller.java:537)
	... 47 more


Inspecting the code at org.eclipse.persistence.internal.oxm.XMLCompositeObjectMappingNodeValue.marshal(XMLCompositeObjectMappingNodeValue.java:145)

we have this method:
public boolean marshal(XPathFragment xPathFragment, MarshalRecord marshalRecord, Object object, CoreAbstractSession session, NamespaceResolver namespaceResolver, MarshalContext marshalContext) {
        if (xmlCompositeObjectMapping.isReadOnly()) {
            return false;
        }
    	int size =marshalRecord.getCycleDetectionStack().size(); 
        Object objectValue = marshalContext.getAttributeValue(object, xmlCompositeObjectMapping);
        
        if((isInverseReference || xmlCompositeObjectMapping.getInverseReferenceMapping() !=null)&& objectValue !=null && size >= 2){        	
    	    Object owner = marshalRecord.getCycleDetectionStack().get(size - 2);
    	    if(owner.equals(objectValue)){
    	    	return false;
    	    }        	    	
        }

        return this.marshalSingleValue(xPathFragment, marshalRecord, object, objectValue, session, namespaceResolver, marshalContext);
    }


The line with problem is:
if(owner.equals(objectValue)){

But that can throw the NPE only if another thread change the size of getCycleDetectionStack().

how I can avoid that as the marshaller is injected?

regards

Clóvis

ps: The webapp runs inside a tomcat 7

Re: Got NPE on Marshall with JAX-RS and multi requests [message #1267229 is a reply to message #1265995] Sat, 08 March 2014 17:49 Go to previous messageGo to next message
Clovis Wichoski is currently offline Clovis WichoskiFriend
Messages: 7
Registered: March 2012
Junior Member
Updating to version 2.6.0-SNAPSHOT solves the problem, but a clarification about why that problem occurs are welcome.
Re: Got NPE on Marshall with JAX-RS and multi requests [message #1269390 is a reply to message #1267229] Tue, 11 March 2014 20:12 Go to previous messageGo to next message
Blaise Doughan is currently offline Blaise DoughanFriend
Messages: 163
Registered: July 2009
Senior Member

You issue could potentially be related to the following issue which has been fixed:
- http://bugs.eclipse.org/404951
icon14.gif  Re: Got NPE on Marshall with JAX-RS and multi requests [message #1505450 is a reply to message #1265995] Wed, 10 December 2014 03:57 Go to previous messageGo to next message
Christopher Parker is currently offline Christopher ParkerFriend
Messages: 4
Registered: January 2012
Junior Member

Just replying here with a "Me, too!" comment. I have a StackOverflow question about this same exact issue.

stackoverflow.com/questions/27384142/eclipselink-moxy-intermittent-nullpointerexception-marshalexception-with-conc

When I get to work tomorrow, I'm going to try using the latest SNAPSHOT release to see if the problem goes away for me, too.

Thanks!
Re: Got NPE on Marshall with JAX-RS and multi requests [message #1506413 is a reply to message #1505450] Wed, 10 December 2014 21:04 Go to previous message
Christopher Parker is currently offline Christopher ParkerFriend
Messages: 4
Registered: January 2012
Junior Member

Small update... I swapped v2.5.1 out for v2.5.2 and I no longer have this issue.
Previous Topic:Invalid binding with "IN" clause and entity
Next Topic:Eclipselink performance problem
Goto Forum:
  


Current Time: Thu Apr 25 03:50:28 GMT 2024

Powered by FUDForum. Page generated in 0.02988 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top