[dna-issues] [JBoss JIRA] Updated: (DNA-591) NullPointerException in JcrNodeDefinition.ensureRequiredPrimaryTypesLoaded()
Brian Carothers (JIRA)
jira-events at lists.jboss.org
Tue Dec 22 21:08:30 EST 2009
[ https://jira.jboss.org/jira/browse/DNA-591?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Brian Carothers updated DNA-591:
--------------------------------
Attachment: DNA-591.patch
Here's a first-cut patch that provides a meaningful error message when this situation occurs. The error occurs because the 3rd type in the .cnd file (ddl:schemaDefinition) declares a residual child node and extends another type in the file (ddl:statement) that also declares a residual child node. This is legal in the current type system if the child node definition in the subclass is "narrower" than the child node definition in the superclass. That is, the subclass's residual child node must be defined such that any node that matches the subclass definition must always match the superclass's definition as well.
This all means that the RNTM must check that (among other things) the required primary types for the subclass are the same as the required primary types for the superclass (or that they are even more restrictive). To do this, the RTNM must load the required primary types of the superclass and subclass and compare the two. But the required primary type of the residual child node definition in the superclass (ddl:statement) is ddl:problem, which is the last type declared in the file. Since ddl:problem hasn't been loaded yet, the attempt to load the required primary types for the residual child node of ddl:statement fails and you get an NPE (or a semi-useful error message if you apply this patch).
Now, the immediate issue can be fixed by moving the definition for ddl:problem to be first in the list. Then you get this slightly more helpful error message:
org.jboss.dna.jcr.nodetype.InvalidNodeTypeDefinitionException: Cannot redefine child node '{}*' with required type 'ddl:ddlProblem' with new child node that does not required that type or a subtype of that type.
To my way of thinking, this is a correct message. ddl:schemaDefinition is attempting to redefine the required priamry type of its residual node from ddl:problem (in the supertype ddl:statement) to ddl:otherStatement. If ddl:otherStatement extended ddl:problem, this would be ok with me.
Having said that, not everyone agrees with me on this and the point is still being debated. I'm not going to try to commit this patch unless/until a consensus is reached on the issue of overriding child node definitions.
> NullPointerException in JcrNodeDefinition.ensureRequiredPrimaryTypesLoaded()
> -----------------------------------------------------------------------------
>
> Key: DNA-591
> URL: https://jira.jboss.org/jira/browse/DNA-591
> Project: DNA
> Issue Type: Bug
> Affects Versions: 0.7
> Reporter: Barry LaFond
> Attachments: DNA-591.patch, DNA_591_Test.java, test_cnd.cnd
>
>
> Using the attached CND file, the repository set-up fails with an NPE when attempting to resolve node types. (ala config.repository(xxxxxx).addNodeTypes('test_cnd.cnd')
> java.lang.NullPointerException
> at org.jboss.dna.jcr.JcrNodeDefinition.ensureRequiredPrimaryTypesLoaded(JcrNodeDefinition.java:113)
> at org.jboss.dna.jcr.JcrNodeDefinition.getRequiredPrimaryTypes(JcrNodeDefinition.java:161)
> at org.jboss.dna.jcr.RepositoryNodeTypeManager.validate(RepositoryNodeTypeManager.java:1938)
> at org.jboss.dna.jcr.RepositoryNodeTypeManager.validate(RepositoryNodeTypeManager.java:1861)
> at org.jboss.dna.jcr.RepositoryNodeTypeManager.registerNodeTypes(RepositoryNodeTypeManager.java:1513)
> at org.jboss.dna.jcr.JcrEngine.doCreateJcrRepository(JcrEngine.java:246)
> at org.jboss.dna.jcr.JcrEngine.getRepository(JcrEngine.java:161)
> My original DDL seqencer cnd is much more complex, but by paring it down to the following, the error still occured.
> //------------------------------------------------------------------------------
> // N A M E S P A C E S
> //------------------------------------------------------------------------------
> <jcr='http://www.jcp.org/jcr/1.0'>
> <nt='http://www.jcp.org/jcr/nt/1.0'>
> <mix='http://www.jcp.org/jcr/mix/1.0'>
> <ddl='http://jboss.org/dna/ddl/1.0'>
> [ddl:statement] mixin abstract
> - ddl:expression (string) mandatory
> + * (ddl:ddlProblem) = ddl:ddlProblem multiple
> [ddl:schemaDefinition] > ddl:statement mixin
> - ddl:defaultCharacterSetName (STRING)
> + * (ddl:ddlStatement) = ddl:ddlStatement multiple
>
> [ddl:ddlProblem] mixin
> - ddl:problemLevel (LONG) mandatory
> - ddl:message (STRING) mandatory
> The [ddl:schemaDefinition] mixin is the ONLY mixin that both extends a mixin and allows children of the same mixin type (i.e. [ddl:statement]) however the NPE is occuring when attempting to find the primary node type for [ddl:ddlProblem]
> Note that the NPE does not occur when the [ddl:schemaDefinition] type is removed.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the dna-issues
mailing list