Search code examples
javaxmlopencms

Open CMS Structured content Unmarshalling XML document failed. Reason: null Nested exception: null


I am working in open CMS and trying to get a new structured content to work I am reciving this error.

Unmarshalling XML document failed. Reason: null Nested exception: null

org.opencms.xml.CmsXmlException: Unmarshalling XML document failed.
    at org.opencms.xml.CmsXmlUtils.unmarshalHelper(CmsXmlUtils.java:654)
    at org.opencms.xml.CmsXmlUtils.unmarshalHelper(CmsXmlUtils.java:617)
    at org.opencms.xml.CmsXmlContentDefinition.unmarshal(CmsXmlContentDefinition.java:257)
    at org.opencms.file.types.CmsResourceTypeXmlContent.createResource(CmsResourceTypeXmlContent.java:143)
    at org.opencms.file.CmsObject.createResource(CmsObject.java:733)
    at org.opencms.workplace.explorer.CmsNewResourceXmlContent.actionCreateResource(CmsNewResourceXmlContent.java:181)
    at org.apache.jsp.WEB_002dINF.jsp.offline.system.workplace.commons.newresource_005fxmlcontent_jsp._jspService(newresource_005fxmlcontent_jsp.java:77)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:388)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646)
    at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:436)
    at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:374)
    at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:302)
    at org.opencms.loader.CmsJspLoader.load(CmsJspLoader.java:509)
    at org.opencms.loader.CmsResourceManager.loadResource(CmsResourceManager.java:1052)
    at org.opencms.main.OpenCmsCore.showResource(OpenCmsCore.java:1489)
    at org.opencms.main.OpenCmsServlet.doGet(OpenCmsServlet.java:153)
    at org.opencms.main.OpenCmsServlet.doPost(OpenCmsServlet.java:166)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:291)
    at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:190)
    at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:291)
    at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:776)
    at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:705)
    at org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:898)
    at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:690)
    at java.lang.Thread.run(Unknown Source)
Caused by: org.dom4j.DocumentException: null Nested exception: null
    at org.dom4j.io.SAXReader.read(SAXReader.java:484)
    at org.opencms.xml.CmsXmlUtils.unmarshalHelper(CmsXmlUtils.java:652)

Here is my config file for the moduel, rather the protion of the file the controles this structured content

  <module>
            <name>edu.etbu.main.playerProfile</name>
            <nicename><![CDATA[Player Profile]]></nicename>
            <class/>
            <description/>
            <version>0.2</version>
            <authorname><![CDATA[Aaron Blakeley]]></authorname>
            <authoremail><![CDATA[[email protected]]]></authoremail>
            <datecreated/>
            <userinstalled/>
            <dateinstalled/>
            <dependencies/>
            <exportpoints>
                <exportpoint uri="/system/modules/edu.etbu.main.playerProfile/classes/" destination="WEB-INF/classes/"/>
            </exportpoints>
            <resources>
                <resource uri="/system/modules/edu.etbu.main.playerProfile/"/>
                <resource uri="/system/workplace/resources/filetypes/"/>
            </resources>
            <parameters/>
            <resourcetypes>
                <type class="org.opencms.file.types.CmsResourceTypeXmlContent" name="playerProfile" id="110">
                <param name="schema">/system/modules/edu.etbu.main.playerProfile/schemas/sportprofile.xsd</param>
                </type>
            </resourcetypes>
            <explorertypes>
                <explorertype name="playerProfile" key="fileicon.playerProfile" icon="playerProfile.gif" reference="xmlcontent">
                    <newresource page="structurecontent" uri="newresource_xmlcontent.jsp?newresourcetype=playerProfile" order="101" autosetnavigation="false" autosettitle="false" info="desc.playerProfile"/>
                    <accesscontrol>
                        <accessentry principal="GROUP.Administrators" permissions="+r+v+w+c"/>
                        <accessentry principal="GROUP.Projectmanagers" permissions="+r+v+w+c"/>
                        <accessentry principal="GROUP.Users" permissions="+r+v+w+c"/>
                    </accesscontrol>
                </explorertype>
            </explorertypes>
        </module>

Here is my XSD

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">

    <xsd:include schemaLocation="opencms://opencms-xmlcontent.xsd"/>    
    <xsd:element name="playerProfile" type="OpenCmsPlayerProfile"/> 
    <xsd:complexType name="OpenCmsPlayerProfile">
        <xsd:sequence>
            <xsd:element name="playerProfile" type="OpenCmsPlayerProfile" minOccurs="0" maxOccurs="unbounded"/>
        </xsd:sequence>
    </xsd:complexType>

    <xsd:complexType name="OpenCmsPlayerProfile">
        <xsd:sequence>
            <xsd:element name="Name" type="OpenCmsString"  />
            <xsd:element name="Picture" type="OpenCmsVfsFile" />
            <xsd:element name="Sport"  type="OpenCmsString"  />
            <xsd:element name="Position/Event" type="OpenCmsString"  />
            <xsd:element name="Bio" type="OpenCmsHtml"/>            
            <xsd:element name="School" type="OpenCmsString"  />
            <xsd:element name="Origin" type="OpenCmsString"  />
            <xsd:element name="Name" type="OpenCmsString"  />
            <xsd:element name="SpecialSportNotes" type="OpenCmsHtml"/>
        </xsd:sequence>
        <xsd:attribute name="language" type="OpenCmsLocale" use="required"/>
    </xsd:complexType>
    <xsd:annotation>
        <xsd:appinfo>
            <layouts>
                <layout element="Bio" widget="TextareaWidget" />
                <layout element="SpecialSportNotes" widget="HtmlWidget" configuration="source,link,anchor,formatselect,imagegallery,downloadgallery,linkgallery,htmlgallery,tablegallery,height:500px" />
                <layout element="Sport" widget="SelectorWidget" configuration="Women's Basketball|Men's Baseball|Women's Cross Country|Men's Soccer|Women's Tennis|Men's Tennis|VolleyBall|Softball|Men's Golf|Women's Soccer|Football|Women's Golf|Men's Cross Country" />             
                <layout element="Picture" widget="VfsFileWidget"/>                             
            </layouts>
        </xsd:appinfo>
    </xsd:annotation>

 </xsd:schema>

Any help would be appreciated.


Solution

  • Your xsd root element name has to end with an 's', OpenCmsPlayerProfiles instead of OpenCmsPlayerProfile, and the type must have exactly the same term with the prefix "OpenCms".

    <xsd:include schemaLocation="opencms://opencms-xmlcontent.xsd"/>    
    <xsd:element name="PlayerProfiles" type="OpenCmsPlayerProfiles"/> 
    <xsd:complexType name="OpenCmsPlayerProfiles">
        <xsd:sequence>
            <xsd:element name="PlayerProfile" type="OpenCmsPlayerProfile" minOccurs="0" maxOccurs="unbounded"/>
        </xsd:sequence>
    </xsd:complexType>
    
    <xsd:complexType name="OpenCmsPlayerProfile">
        <xsd:sequence>
            <xsd:element name="Name" type="OpenCmsString"  />
            <xsd:element name="Picture" type="OpenCmsVfsFile" />
            <xsd:element name="Sport"  type="OpenCmsString"  />
            <xsd:element name="Position/Event" type="OpenCmsString"  />
            <xsd:element name="Bio" type="OpenCmsHtml"/>            
            <xsd:element name="School" type="OpenCmsString"  />
            <xsd:element name="Origin" type="OpenCmsString"  />
            <xsd:element name="Name" type="OpenCmsString"  />
            <xsd:element name="SpecialSportNotes" type="OpenCmsHtml"/>
        </xsd:sequence>
        <xsd:attribute name="language" type="OpenCmsLocale" use="required"/>
    </xsd:complexType>
    <xsd:annotation>
        ...
    </xsd:annotation>