-
1. Re: ensureRequiredPrimaryTypesLoaded throwing NullPointerException on first access under Jetty
rhauch Jan 18, 2012 9:28 AM (in response to kjq)It does sound like there is a concurrency problem during initialization, but your stack trace confuses me. In particular, the first line:
java.lang.NullPointerException at org.modeshape.jcr.JcrNodeDefinition.ensureRequiredPrimaryTypesLoaded(JcrNodeDefinition.java:114) at
If you're using ModeShape 2.7.0.Final, then line 114 is a simple null reference check, which cannot result in a NullPointerException:
if (requiredPrimaryTypesByName != null) return;
Also, the second line of the stack trace is also troubling, because JcrNodeDefinition line 275 is the terminating '}' of a method.
Have you changed the source in any way, or are you running against a released version?
-
2. Re: ensureRequiredPrimaryTypesLoaded throwing NullPointerException on first access under Jetty
kjq Jan 18, 2012 10:56 AM (in response to rhauch)I am using Modeshape 2.7.0 Final.
Sorry, I was playing with the code to see if I could figure out what the problem is. The exact stack trace returned back is:
java.lang.NullPointerException
at org.modeshape.jcr.JcrNodeDefinition.ensureRequiredPrimaryTypesLoaded(JcrNodeDefinition.java:121)
at org.modeshape.jcr.JcrNodeDefinition.allowsChildWithType(JcrNodeDefinition.java:249)
at org.modeshape.jcr.RepositoryNodeTypeManager.findChildNodeDefinition(RepositoryNodeTypeManager.java:1142)
at org.modeshape.jcr.RepositoryNodeTypeManager.findChildNodeDefinition(RepositoryNodeTypeManager.java:1161)
at org.modeshape.jcr.JcrNodeTypeManager.findChildNodeDefinition(JcrNodeTypeManager.java:433)
at org.modeshape.jcr.SessionCache$JcrNodeOperations.materialize(SessionCache.java:2711)
at org.modeshape.graph.session.GraphSession.findNodeRelativeTo(GraphSession.java:535)
at org.modeshape.graph.session.GraphSession.findNodeWith(GraphSession.java:398)
at org.modeshape.graph.session.GraphSession.findNodeWith(GraphSession.java:381)
at org.modeshape.jcr.SessionCache.findNode(SessionCache.java:532)
at org.modeshape.jcr.SessionCache.findJcrNode(SessionCache.java:643)
at org.modeshape.jcr.JcrSession.getNode(JcrSession.java:838)
at org.modeshape.jcr.JcrSession.getNode(JcrSession.java:703)
at org.modeshape.jcr.JcrSession.getNode(JcrSession.java:96)
at com.acme.contents.ModeshapeManagerBean.findNode(ModeshapeManagerBean.java:67)
at com.acme.contents.ModeshapeManagerBean.findNode(ModeshapeManagerBean.java:50)
at com.acme.views.ResourceController.getStream(ResourceController.java:69)
at comacme.views.ResourceController.handleResource(ResourceController.java:46)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:212)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:126)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:96)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:6
-
3. Re: ensureRequiredPrimaryTypesLoaded throwing NullPointerException on first access under Jetty
rhauch Jan 18, 2012 1:20 PM (in response to kjq)Okay, that makes much more sense, and is perfectly explained by the concurrent bug I found and described in MODE-1374. I have a fix that I'm currently in the process of testing. (The fix doesn't synchronize the whole 'ensureRequiredPrimaryTypesLoaded()' method, but rather synchronizes just one critical part of the method.) I'll likely merge it into the 'master' branch and '3.x' branch within the hour.
Thanks for reporting the issue and doing the initial investigation yourself. That work saved us a great deal of time and effort, and allowed us to quickly identify the problem.
-
4. Re: ensureRequiredPrimaryTypesLoaded throwing NullPointerException on first access under Jetty
rhauch Jan 18, 2012 2:31 PM (in response to rhauch)The fix has been merged into the codebase and will be in all upcoming releases. Feel free to continue to use in the meantime change you suggested to add the 'synchronized' keyword to the 'ensureRequiredNodeTypesLoaded()' mehtod. You can also look at the details of our fix (which is a bit more subtle).
Again, thanks for reporting this!