cancel
Showing results for 
Search instead for 
Did you mean: 

setting mandatory aspect property throws exception

smiconrad
Champ in-the-making
Champ in-the-making
I'm seeing some strange behavior when creating a new aspect:


<aspect name="xx:aspectname">
  <title>Aspect Title</title>
  <properties>
      <property name="xx:weirdprop">
          <title>Why aren't you working man</title>
          <type>d:text</type>
          <index enabled="true">
              <atomic>true</atomic>
              <stored>true</stored>
              <tokenised>true</tokenised>
          </index>
          <mandatory>true</mandatory>
          <constraints>
              <constraint ref="xx:myConstraint" />
          </constraints>
      </property
  </properties>
</aspect>

Check out where the mandatory element is defined. This throws an exception. Moving the mandatory element above the index element works. The exception follows:

…     at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:442)
        at org.apache.catalina.core.StandardService.start(StandardService.java:450)
        at org.apache.catalina.core.StandardServer.start(StandardServer.java:680)
        at org.apache.catalina.startup.Catalina.start(Catalina.java:536)
        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:585)
        at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:275)
        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
Caused by: org.alfresco.service.cmr.dictionary.DictionaryException: Failed to parse model
        at org.alfresco.repo.dictionary.M2Model.createModel(M2Model.java:91)
        at org.alfresco.repo.dictionary.DictionaryBootstrap.bootstrap(DictionaryBootstrap.java:98)
        … 39 more
Caused by: org.jibx.runtime.JiBXException: Expected "{http://www.alfresco.org/model/dictionary/1.0}property" end tag, fo
und "{http://www.alfresco.org/model/dictionary/1.0}mandatory" end tag (line 199, col 33)
        at org.jibx.runtime.impl.UnmarshallingContext.throwEndTagNameError(UnmarshallingContext.java:302)
        at org.jibx.runtime.impl.UnmarshallingContext.parsePastEndTag(UnmarshallingContext.java:808)
        at org.alfresco.repo.dictionary.JiBX_repository_source_java_org_alfresco_repo_dictionary_m2bindingM2Property_acc
ess.unmarshal()
        at org.alfresco.repo.dictionary.JiBX_MungeAdapter.JiBX_repository_source_java_org_alfresco_repo_dictionary_m2bin
ding_unmarshal_1_10()
        at org.alfresco.repo.dictionary.M2Class.JiBX_repository_source_java_org_alfresco_repo_dictionary_m2binding_unmar
shal_1_0(M2Class.java)
        at org.alfresco.repo.dictionary.M2Aspect.JiBX_repository_source_java_org_alfresco_repo_dictionary_m2binding_unma
rshal_2_0(M2Aspect.java)
        at org.alfresco.repo.dictionary.JiBX_repository_source_java_org_alfresco_repo_dictionary_m2bindingM2Aspect_acces
s.unmarshal()
        at org.alfresco.repo.dictionary.JiBX_MungeAdapter.JiBX_repository_source_java_org_alfresco_repo_dictionary_m2bin
ding_unmarshal_1_5()
        at org.alfresco.repo.dictionary.M2Model.JiBX_repository_source_java_org_alfresco_repo_dictionary_m2binding_unmar
shal_1_0(M2Model.java)
        at org.alfresco.repo.dictionary.JiBX_repository_source_java_org_alfresco_repo_dictionary_m2bindingM2Model_access
.unmarshal()
        at org.jibx.runtime.impl.UnmarshallingContext.unmarshalElement(UnmarshallingContext.java:2515)
        at org.jibx.runtime.impl.UnmarshallingContext.unmarshalDocument(UnmarshallingContext.java:2675)
        at org.alfresco.repo.dictionary.M2Model.createModel(M2Model.java:86)
        … 40 more


Any idea why?

Thanks.
conrad
4 REPLIES 4

ajshaw
Champ in-the-making
Champ in-the-making
<aspect name="xx:aspectname"> 
  <title>Aspect Title</title>
  <properties>
      <property name="xx:weirdprop">
          <title>Why aren't you working man</title>
          <type>d:text</type>
          <index enabled="true">
              <atomic>true</atomic>
              <stored>true</stored>
              <tokenised>true</tokenised>
          </index>
          <mandatory>true</mandatory>
          <constraints>
              <constraint ref="xx:myConstraint" />
          </constraints>
      </property           <—————————- Close this up.
  </properties>
</aspect>


Try that.

smiconrad
Champ in-the-making
Champ in-the-making
Apologies for that. I just made a mistake while pasting the XML code to the post. My file has all tags properly formatted.

Like I said earlier, moving the <mandatory> tag above the <index> tag works but having it under the <index> tag doesn't.

I'm just curious as to why this is the case. Shouldn't I be able to put the <mandatory> tag anywhere inside the <property> tag?

Thanks for your help.
conrad

ajshaw
Champ in-the-making
Champ in-the-making
Same thing happens when i try too.

davidc
Star Contributor
Star Contributor
The order of elements within <property> must be:

title
description
type
protected
mandatory
multiple
default
index
constraints

Optional elements can be left out.

You can look at m2binding.xml or modelSchema.xsd for the complete dictionary schema.