[GeoNetwork-devel] GeoNetwork 2.4.1 - java.lang.IllegalStateException: Element not found at ref =

My name is Martin Aubrey with NOAA NGDC. I am inserting xml that is producing an IllegalStateException thrown from the kernel DataManager. This code calls org.fao.geonet.kernel.EditLib.findElement() and gets a null value resulting in the
exception below.

---------------------------------------------------------------------------------------------------------------------------

Scenario:
1) insert xml
2) click id number and then Edit
3) click check to validate

Upon entry into the JeevesServlet engine, the request contains what appears to be the original xml
being checked but transformed into a hash table...ex:

<request>
  <position>-1</position>
  <licenseurl />
  <type />
  <_23>fake abstract</_23>
  <_12_gmdCOLONidentifier>gmd:MD_Identifier</_12_gmdCOLONidentifier>
  <_25 />
  <version>2</version>
  <child />
  <id>12</id>
  <_1_gmdCOLONidentificationInfo>gmd:MD_DataIdentification</_1_gmdCOLONidentificationInfo>
  <_20_codeListValue>creation</_20_codeListValue>
  <name />
  <_ />
  <_1_gmdCOLONcontentInfo>gmd:MD_CoverageDescription</_1_gmdCOLONcontentInfo>
  <fname />
  <template>n</template>
  <_1_gmdCOLONseries>gmd:DS_Initiative</_1_gmdCOLONseries>
  <_6_gcoCOLONnilReason>missing</_6_gcoCOLONnilReason>
  <editing>12</editing>
  <_18>20091001</_18>
  <_10_gmdCOLONresourceConstraints>gmd:MD_Constraints</_10_gmdCOLONresourceConstraints>
  <access />
  <_14>FAKE TITLE</_14>
  <showvalidationerrors>true</showvalidationerrors>
  <_1_gmdCOLONspatialRepresentationInfo>gmd:MD_Georectified</_1_gmdCOLONspatialRepresentationInfo>
  <ref />
  <_1_gmdCOLONmetadataConstraints>gmd:MD_Constraints</_1_gmdCOLONmetadataConstraints>
  <currTab>simple</currTab>
</request>

NOTE the <_ /> in this list. This hash table eventually makes its way to EditUtils where the htChanges hash is
build...skipping the underscore and using the blank object as a key...this hash makes its way to the DataManager
who iterates through this calling EditLib.findElement() passing a blank reference to search on. This findElement method is recurrsive with 3 return points which seems odd but the net of this is that this code does
not handle a hash build from a list containing <_ /> and returns null. The DataManager then throws the exception.

I would like to find out if the <_ /> coming into the JeevesServlet is valid or not and what code produces this...!!
Is the htchanges hash table valid in this case. Maybe this table should not be built and used unless an xsd validation
completes successfully...?
If valid then the findElement() may need some work.

---------------------------------------------------------------------------------------------------------------------------
2009-10-02 14:03:16,133 ERROR [jeeves.service] - Exception when executing service
2009-10-02 14:03:16,133 ERROR [jeeves.service] - (C) Exc : java.lang.IllegalStateException: Element not found at ref =
2009-10-02 14:03:16,134 DEBUG [jeeves.service] - Raised exception while executing service
<error id="error">
  <message>Element not found at ref =</message>
  <class>IllegalStateException</class>
  <stack>
    <at class="org.fao.geonet.kernel.DataManager" file="DataManager.java" line="1355" method="updateMetadataEmbedded" />
    <at class="org.fao.geonet.services.metadata.EditUtils" file="EditUtils.java" line="140" method="updateContent" />
    <at class="org.fao.geonet.services.metadata.Update" file="Update.java" line="103" method="exec" />
    <at class="jeeves.server.dispatchers.ServiceInfo" file="ServiceInfo.java" line="256" method="execService" />
    <at class="jeeves.server.dispatchers.ServiceInfo" file="ServiceInfo.java" line="159" method="execServices" />
    <at class="jeeves.server.dispatchers.ServiceManager" file="ServiceManager.java" line="380" method="dispatch" />
    <at class="jeeves.server.JeevesEngine" file="JeevesEngine.java" line="623" method="dispatch" />
    <at class="jeeves.server.sources.http.JeevesServlet" file="JeevesServlet.java" line="204" method="execute" />
    <at class="jeeves.server.sources.http.JeevesServlet" file="JeevesServlet.java" line="102" method="doPost" />
    <at class="javax.servlet.http.HttpServlet" file="HttpServlet.java" line="727" method="service" />
  </stack>
  <request>
    <language>en</language>
    <service>metadata.update</service>
  </request>
</error>
---------------------------------------------------------------------------------------------------------------------------
Inserted xml: The xml that follows has 7 test scenarios of which 3 produce the exception above.

<gmd:MD_Metadata xmlns:gmi="http://www.isotc211.org/2005/gmi&quot; xmlns:gts="http://www.isotc211.org/2005/gts&quot; xmlns:gco="http://www.isotc211.org/2005/gco&quot; xmlns:gmd="http://www.isotc211.org/2005/gmd&quot; xmlns:srv="http://www.isotc211.org/2005/srv&quot; xmlns:gmx="http://www.isotc211.org/2005/gmx&quot;
        xmlns:gss="http://www.isotc211.org/2005/gss&quot; xmlns:gsr="http://www.isotc211.org/2005/gsr&quot; xmlns:gml="http://www.opengis.net/gml&quot; xmlns:xlink="http://www.w3.org/1999/xlink&quot; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance&quot; xsi:schemaLocation="http://www.isotc211.org/2005/gmd
        http://www.ngdc.noaa.gov/metadata/published/xsd/schema.xsd&quot;&gt;
        <gmd:contact>
                <gmd:CI_ResponsibleParty>
                        <gmd:role gco:nilReason="missing"/>
                </gmd:CI_ResponsibleParty>
        </gmd:contact>
        <gmd:dateStamp>
                <gco:Date>2009-10-01</gco:Date>

        </gmd:dateStamp>
        <gmd:identificationInfo>
                <gmd:MD_DataIdentification>
                        <gmd:citation>
                                <gmd:CI_Citation>
                                        <gmd:title>
                                                <gco:CharacterString>FAKE TITLE</gco:CharacterString>
                                        </gmd:title>

                                        <gmd:date>
                                                <gmd:CI_Date>
                                                        <gmd:date>
                                                                <gco:Date>20091001</gco:Date>
                                                        </gmd:date>
                                                        <gmd:dateType>
                                                                <gmd:CI_DateTypeCode codeList="#fakeURL" codeListValue="creation">creation</gmd:CI_DateTypeCode>
                                                        </gmd:dateType>

                                                </gmd:CI_Date>
                                        </gmd:date>
                                       <!-- 1. validate ok...no ref error -->
                                        <!--<gmd:editionDate><gco:Date>2009-10-02</gco:Date></gmd:editionDate> -->

                                        <!-- 2. validate ok with ref error-->
                                        <!-- <gmd:editionDate gco:nilReason="unknown"/> -->

                                        <!-- 3. validate ok...no ref error -->
                                        <!--<gmd:editionDate gco:nilReason="unknown">
                                                <gco:Date>2009-10-02</gco:Date>
                                        </gmd:editionDate> -->

                                        <!-- 4. does not validate...no ref error-->
                                        <!-- <gmd:editionDate gco:nilReason="unknown">
                                                <gco:Date/>
                                                </gmd:editionDate>-->

                                        <!-- 5. should not validate OR should autopopulate with 'gco:nilReason="missing" and then validate-->
                                        <!-- validate OK with ref error-->
                                        <!-- <gmd:editionDate/> -->

                                        <!-- 6. does not validate with ref error -->
                                        <!--<gmd:editionDate><gco:CharacterString>2009-10-02</gco:CharacterString></gmd:editionDate> -->

                                        <!-- 7. does not validate...no ref error -->
                                        <!--<gmd:editionDate>
                                                <gco:Date/>
                                                </gmd:editionDate> -->

                                </gmd:CI_Citation>
                        </gmd:citation>
                        <gmd:abstract>
                                <gco:CharacterString>fake abstract</gco:CharacterString>
                        </gmd:abstract>
                        <gmd:language>

                                <gco:CharacterString>esperante</gco:CharacterString>
                        </gmd:language>
                </gmd:MD_DataIdentification>
        </gmd:identificationInfo>
</gmd:MD_Metadata>

---------------------------------------------------------------------------------------------------------------------------

Hi Martin,

Your issue happens when you edit an XML document, so maybe some background might help: when you edit an XML metadata document in GeoNetwork extra elements are added to the document (with prefix geonet:) - this is done in the java code of EditLib. One of these extra elements (geonet:element) is added to each element of the XML metadata document and contains a numeric id (attribute ref). This id is used by the editor XSLTs to label the html form inputs it creates so that they can be associated with the appropriate elements of the metadata document when the form is serialized and sent back to the server.

So the hash table/name,value pairs you can see in the request are the XML version of the serialized html form - eg. _23 would refer to the metadata element that had been given an id of 23 (via the ref attribute of a geonet:element added to it on edit).

Looking at the scenarios, it would appear that the xslt template which handles gmd:editionDate in metadata-iso19139.xsl is assuming that a gco:Date or gco:DateTime element will always be present as a child of gmd:editionDate - because it doesn't find one (and consequently doesn't find the ref attribute of a geonet:element) it adds an input to the html form that doesn't have a numeric id, hence you end up with the <_/> element in your request and the exception. The gco:nilReason attribute is being ignored.

I'll open a ticket on the editor to check assumptions about presence/absence of gco: elements and handle gco:nilReason for elements other than gco:CharacterString in update-fixed-info.xsl

You could probably fix most of the problem (but not the gco:nilReason handling) by making the template that handles gmd:editionDate in metadata-iso19139.xsl only match gmd:editionDate when it has a gco:Date/gco:DateTime element - do that by changing gmd:editionDate to gmd:editionDate[gco:Date|gco:DateTime] and ditto for gmd:dateOfNextUpdate.

Cheers and thanks,
Simon

[Also just looking at your scenario and the XML you were inserting - it would seem that your record is based on an extension of ISO19115/19139 (ISO19115-2?). Can I ask whether you have added the XSDs that describe the extensions to one of the schema directories (likely iso19139 if not using a profile) in GeoNetwork? At present, just having a schemalocation attribute in the XML document is not sufficient. The reason is that the GeoNetwork editor is schema driven, so GeoNetwork needs to read the appropriate XSDs on startup for the editor to make sense of an XML document - if you were to use the extension elements in XSDs that were not readable by GeoNetwork, they would most likely disappear when editing.

Action: create an enhancement ticket to include ISO19115-2 schema extensions in GeoNetwork. I think these have been published (but can't see them on isotc211 site - why?), where are the official ones published if not on the tc211 site?]

________________________________________
From: Martin Aubrey [Martin.Aubrey@anonymised.com]
Sent: Saturday, 3 October 2009 7:46 AM
To: geonetwork-devel@lists.sourceforge.net
Subject: [GeoNetwork-devel] GeoNetwork 2.4.1 - java.lang.IllegalStateException: Element not found at ref =

My name is Martin Aubrey with NOAA NGDC.
I am inserting xml that is producing an IllegalStateException thrown
from the kernel DataManager.
This code calls org.fao.geonet.kernel.EditLib.findElement() and gets a
null value resulting in the
exception below.

---------------------------------------------------------------------------------------------------------------------------

Scenario:
1) insert xml
2) click id number and then Edit
3) click check to validate

Upon entry into the JeevesServlet engine, the request contains what
appears to be the original xml
being checked but transformed into a hash table...ex:

<request>
  <position>-1</position>
  <licenseurl />
  <type />
  <_23>fake abstract</_23>
  <_12_gmdCOLONidentifier>gmd:MD_Identifier</_12_gmdCOLONidentifier>
  <_25 />
  <version>2</version>
  <child />
  <id>12</id>

<_1_gmdCOLONidentificationInfo>gmd:MD_DataIdentification</_1_gmdCOLONidentificationInfo>
  <_20_codeListValue>creation</_20_codeListValue>
  <name />
  <_ />

<_1_gmdCOLONcontentInfo>gmd:MD_CoverageDescription</_1_gmdCOLONcontentInfo>
  <fname />
  <template>n</template>
  <_1_gmdCOLONseries>gmd:DS_Initiative</_1_gmdCOLONseries>
  <_6_gcoCOLONnilReason>missing</_6_gcoCOLONnilReason>
  <editing>12</editing>
  <_18>20091001</_18>

<_10_gmdCOLONresourceConstraints>gmd:MD_Constraints</_10_gmdCOLONresourceConstraints>
  <access />
  <_14>FAKE TITLE</_14>
  <showvalidationerrors>true</showvalidationerrors>

<_1_gmdCOLONspatialRepresentationInfo>gmd:MD_Georectified</_1_gmdCOLONspatialRepresentationInfo>
  <ref />

<_1_gmdCOLONmetadataConstraints>gmd:MD_Constraints</_1_gmdCOLONmetadataConstraints>
  <currTab>simple</currTab>
</request>

NOTE the <_ /> in this list. This hash table eventually makes its way
to EditUtils where the htChanges hash is
build...skipping the underscore and using the blank object as a
key...this hash makes its way to the DataManager
who iterates through this calling EditLib.findElement() passing a blank
reference to search on.
This findElement method is recurrsive with 3 return points which seems
odd but the net of this is that this code does
not handle a hash build from a list containing <_ /> and returns null.
The DataManager then throws the exception.

I would like to find out if the <_ /> coming into the JeevesServlet is
valid or not and what code produces this...!!
Is the htchanges hash table valid in this case. Maybe this table should
not be built and used unless an xsd validation
completes successfully...?
If valid then the findElement() may need some work.

---------------------------------------------------------------------------------------------------------------------------
2009-10-02 14:03:16,133 ERROR [jeeves.service] - Exception when
executing service
2009-10-02 14:03:16,133 ERROR [jeeves.service] - (C) Exc :
java.lang.IllegalStateException: Element not found at ref =
2009-10-02 14:03:16,134 DEBUG [jeeves.service] - Raised exception while
executing service
<error id="error">
  <message>Element not found at ref =</message>
  <class>IllegalStateException</class>
  <stack>
    <at class="org.fao.geonet.kernel.DataManager"
file="DataManager.java" line="1355" method="updateMetadataEmbedded" />
    <at class="org.fao.geonet.services.metadata.EditUtils"
file="EditUtils.java" line="140" method="updateContent" />
    <at class="org.fao.geonet.services.metadata.Update"
file="Update.java" line="103" method="exec" />
    <at class="jeeves.server.dispatchers.ServiceInfo"
file="ServiceInfo.java" line="256" method="execService" />
    <at class="jeeves.server.dispatchers.ServiceInfo"
file="ServiceInfo.java" line="159" method="execServices" />
    <at class="jeeves.server.dispatchers.ServiceManager"
file="ServiceManager.java" line="380" method="dispatch" />
    <at class="jeeves.server.JeevesEngine" file="JeevesEngine.java"
line="623" method="dispatch" />
    <at class="jeeves.server.sources.http.JeevesServlet"
file="JeevesServlet.java" line="204" method="execute" />
    <at class="jeeves.server.sources.http.JeevesServlet"
file="JeevesServlet.java" line="102" method="doPost" />
    <at class="javax.servlet.http.HttpServlet" file="HttpServlet.java"
line="727" method="service" />
  </stack>
  <request>
    <language>en</language>
    <service>metadata.update</service>
  </request>
</error>
---------------------------------------------------------------------------------------------------------------------------
Inserted xml: The xml that follows has 7 test scenarios of which 3
produce the exception above.

<gmd:MD_Metadata xmlns:gmi="http://www.isotc211.org/2005/gmi&quot;
xmlns:gts="http://www.isotc211.org/2005/gts&quot;
xmlns:gco="http://www.isotc211.org/2005/gco&quot;
xmlns:gmd="http://www.isotc211.org/2005/gmd&quot;
xmlns:srv="http://www.isotc211.org/2005/srv&quot;
xmlns:gmx="http://www.isotc211.org/2005/gmx&quot;
        xmlns:gss="http://www.isotc211.org/2005/gss&quot;
xmlns:gsr="http://www.isotc211.org/2005/gsr&quot;
xmlns:gml="http://www.opengis.net/gml&quot;
xmlns:xlink="http://www.w3.org/1999/xlink&quot;
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance&quot;
xsi:schemaLocation="GMD — Resource site for ISO/TC 211 Geographic information/Geomatics
        http://www.ngdc.noaa.gov/metadata/published/xsd/schema.xsd&quot;&gt;
        <gmd:contact>
                <gmd:CI_ResponsibleParty>
                        <gmd:role gco:nilReason="missing"/>
                </gmd:CI_ResponsibleParty>
        </gmd:contact>
        <gmd:dateStamp>
                <gco:Date>2009-10-01</gco:Date>

        </gmd:dateStamp>
        <gmd:identificationInfo>
                <gmd:MD_DataIdentification>
                        <gmd:citation>
                                <gmd:CI_Citation>
                                        <gmd:title>

<gco:CharacterString>FAKE TITLE</gco:CharacterString>
                                        </gmd:title>

                                        <gmd:date>
                                                <gmd:CI_Date>
                                                        <gmd:date>

<gco:Date>20091001</gco:Date>
                                                        </gmd:date>
                                                        <gmd:dateType>

<gmd:CI_DateTypeCode codeList="#fakeURL"
codeListValue="creation">creation</gmd:CI_DateTypeCode>
                                                        </gmd:dateType>

                                                </gmd:CI_Date>
                                        </gmd:date>
                                       <!-- 1. validate ok...no ref
error -->

<!--<gmd:editionDate><gco:Date>2009-10-02</gco:Date></gmd:editionDate> -->

                                        <!-- 2. validate ok with ref
error-->
                                        <!-- <gmd:editionDate
gco:nilReason="unknown"/> -->

                                        <!-- 3. validate ok...no ref
error -->
                                        <!--<gmd:editionDate
gco:nilReason="unknown">

<gco:Date>2009-10-02</gco:Date>
                                        </gmd:editionDate> -->

                                        <!-- 4. does not validate...no
ref error-->
                                        <!-- <gmd:editionDate
gco:nilReason="unknown">
                                                <gco:Date/>
                                                </gmd:editionDate>-->

                                        <!-- 5. should not validate OR
should autopopulate with 'gco:nilReason="missing" and then validate-->
                                        <!-- validate OK with ref
error-->
                                        <!-- <gmd:editionDate/> -->

                                        <!-- 6. does not validate with
ref error -->

<!--<gmd:editionDate><gco:CharacterString>2009-10-02</gco:CharacterString></gmd:editionDate>
-->

                                        <!-- 7. does not validate...no
ref error -->
                                        <!--<gmd:editionDate>
                                                <gco:Date/>
                                                </gmd:editionDate> -->

                                </gmd:CI_Citation>
                        </gmd:citation>
                        <gmd:abstract>
                                <gco:CharacterString>fake
abstract</gco:CharacterString>
                        </gmd:abstract>
                        <gmd:language>

<gco:CharacterString>esperante</gco:CharacterString>
                        </gmd:language>
                </gmd:MD_DataIdentification>
        </gmd:identificationInfo>
</gmd:MD_Metadata>

---------------------------------------------------------------------------------------------------------------------------

------------------------------------------------------------------------------
Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;

_______________________________________________
GeoNetwork-devel mailing list
GeoNetwork-devel@lists.sourceforge.net

GeoNetwork OpenSource is maintained at http://sourceforge.net/projects/geonetwork

hi Simon,

a question : would it not be a good idea to read schemas from the reference in schemaLocation, if the XSD is not already known to GeoNetwork ? At least an attempt could be made to do so, I guess. In the ebRIM branch we have some nifty schema-reading code that will load schemas, and any schemas referenced in them, etc. from remote locations. The class is org.geonetwork.utils.xsd.XSD in the project “geonetwork-services-ebrim”.

Just my 2¢

Kind regards
Heikki Doeleman

On Sat, Oct 3, 2009 at 4:01 PM, Simon.Pigot@anonymised.com wrote:

Hi Martin,

Your issue happens when you edit an XML document, so maybe some background might help: when you edit an XML metadata document in GeoNetwork extra elements are added to the document (with prefix geonet:) - this is done in the java code of EditLib. One of these extra elements (geonet:element) is added to each element of the XML metadata document and contains a numeric id (attribute ref). This id is used by the editor XSLTs to label the html form inputs it creates so that they can be associated with the appropriate elements of the metadata document when the form is serialized and sent back to the server.

So the hash table/name,value pairs you can see in the request are the XML version of the serialized html form - eg. _23 would refer to the metadata element that had been given an id of 23 (via the ref attribute of a geonet:element added to it on edit).

Looking at the scenarios, it would appear that the xslt template which handles gmd:editionDate in metadata-iso19139.xsl is assuming that a gco:Date or gco:DateTime element will always be present as a child of gmd:editionDate - because it doesn’t find one (and consequently doesn’t find the ref attribute of a geonet:element) it adds an input to the html form that doesn’t have a numeric id, hence you end up with the <_/> element in your request and the exception. The gco:nilReason attribute is being ignored.

I’ll open a ticket on the editor to check assumptions about presence/absence of gco: elements and handle gco:nilReason for elements other than gco:CharacterString in update-fixed-info.xsl

You could probably fix most of the problem (but not the gco:nilReason handling) by making the template that handles gmd:editionDate in metadata-iso19139.xsl only match gmd:editionDate when it has a gco:Date/gco:DateTime element - do that by changing gmd:editionDate to gmd:editionDate[gco:Date|gco:DateTime] and ditto for gmd:dateOfNextUpdate.

Cheers and thanks,
Simon

[Also just looking at your scenario and the XML you were inserting - it would seem that your record is based on an extension of ISO19115/19139 (ISO19115-2?). Can I ask whether you have added the XSDs that describe the extensions to one of the schema directories (likely iso19139 if not using a profile) in GeoNetwork? At present, just having a schemalocation attribute in the XML document is not sufficient. The reason is that the GeoNetwork editor is schema driven, so GeoNetwork needs to read the appropriate XSDs on startup for the editor to make sense of an XML document - if you were to use the extension elements in XSDs that were not readable by GeoNetwork, they would most likely disappear when editing.

Action: create an enhancement ticket to include ISO19115-2 schema extensions in GeoNetwork. I think these have been published (but can’t see them on isotc211 site - why?), where are the official ones published if not on the tc211 site?]


From: Martin Aubrey [Martin.Aubrey@anonymised.com]
Sent: Saturday, 3 October 2009 7:46 AM
To: geonetwork-devel@lists.sourceforge.net
Subject: [GeoNetwork-devel] GeoNetwork 2.4.1 - java.lang.IllegalStateException: Element not found at ref =

My name is Martin Aubrey with NOAA NGDC.
I am inserting xml that is producing an IllegalStateException thrown
from the kernel DataManager.
This code calls org.fao.geonet.kernel.EditLib.findElement() and gets a
null value resulting in the
exception below.


Scenario:

  1. insert xml
  2. click id number and then Edit
  3. click check to validate

Upon entry into the JeevesServlet engine, the request contains what
appears to be the original xml
being checked but transformed into a hash table…ex:

-1 <_23>fake abstract <_12_gmdCOLONidentifier>gmd:MD_Identifier <_25 /> 2 12

<_1_gmdCOLONidentificationInfo>gmd:MD_DataIdentification</_1_gmdCOLONidentificationInfo>
<_20_codeListValue>creation</20_codeListValue>

<
/>

<_1_gmdCOLONcontentInfo>gmd:MD_CoverageDescription</_1_gmdCOLONcontentInfo>

n
<_1_gmdCOLONseries>gmd:DS_Initiative</_1_gmdCOLONseries>
<_6_gcoCOLONnilReason>missing</_6_gcoCOLONnilReason>
12
<_18>20091001</_18>

<_10_gmdCOLONresourceConstraints>gmd:MD_Constraints</_10_gmdCOLONresourceConstraints>

<_14>FAKE TITLE</_14>
true

<_1_gmdCOLONspatialRepresentationInfo>gmd:MD_Georectified</_1_gmdCOLONspatialRepresentationInfo>

<_1_gmdCOLONmetadataConstraints>gmd:MD_Constraints</_1_gmdCOLONmetadataConstraints>
simple

NOTE the <_ /> in this list. This hash table eventually makes its way
to EditUtils where the htChanges hash is
build…skipping the underscore and using the blank object as a
key…this hash makes its way to the DataManager
who iterates through this calling EditLib.findElement() passing a blank
reference to search on.
This findElement method is recurrsive with 3 return points which seems
odd but the net of this is that this code does
not handle a hash build from a list containing <_ /> and returns null.
The DataManager then throws the exception.

I would like to find out if the <_ /> coming into the JeevesServlet is
valid or not and what code produces this…!!
Is the htchanges hash table valid in this case. Maybe this table should
not be built and used unless an xsd validation
completes successfully…?
If valid then the findElement() may need some work.


2009-10-02 14:03:16,133 ERROR [jeeves.service] - Exception when
executing service
2009-10-02 14:03:16,133 ERROR [jeeves.service] - (C) Exc :
java.lang.IllegalStateException: Element not found at ref =
2009-10-02 14:03:16,134 DEBUG [jeeves.service] - Raised exception while
executing service

Element not found at ref =
IllegalStateException













en
metadata.update

Inserted xml: The xml that follows has 7 test scenarios of which 3
produce the exception above.

<gmd:MD_Metadata xmlns:gmi=“http://www.isotc211.org/2005/gmi
xmlns:gts=“http://www.isotc211.org/2005/gts
xmlns:gco=“http://www.isotc211.org/2005/gco
xmlns:gmd=“http://www.isotc211.org/2005/gmd
xmlns:srv=“http://www.isotc211.org/2005/srv
xmlns:gmx=“http://www.isotc211.org/2005/gmx
xmlns:gss=“http://www.isotc211.org/2005/gss
xmlns:gsr=“http://www.isotc211.org/2005/gsr
xmlns:gml=“http://www.opengis.net/gml
xmlns:xlink=“http://www.w3.org/1999/xlink
xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance
xsi:schemaLocation=“http://www.isotc211.org/2005/gmd
http://www.ngdc.noaa.gov/metadata/published/xsd/schema.xsd”>
gmd:contact
gmd:CI_ResponsibleParty
<gmd:role gco:nilReason=“missing”/>
</gmd:CI_ResponsibleParty>
</gmd:contact>
gmd:dateStamp
gco:Date2009-10-01</gco:Date>

</gmd:dateStamp>
gmd:identificationInfo
gmd:MD_DataIdentification
gmd:citation
gmd:CI_Citation
gmd:title

gco:CharacterStringFAKE TITLE</gco:CharacterString>
</gmd:title>

gmd:date
gmd:CI_Date
gmd:date

gco:Date20091001</gco:Date>
</gmd:date>
gmd:dateType

<gmd:CI_DateTypeCode codeList=“#fakeURL
codeListValue=“creation”>creation</gmd:CI_DateTypeCode>
</gmd:dateType>

</gmd:CI_Date>
</gmd:date>

</gmd:CI_Citation>
</gmd:citation>
gmd:abstract
gco:CharacterStringfake
abstract</gco:CharacterString>
</gmd:abstract>
gmd:language

gco:CharacterStringesperante</gco:CharacterString>
</gmd:language>
</gmd:MD_DataIdentification>
</gmd:identificationInfo>
</gmd:MD_Metadata>



Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf


GeoNetwork-devel mailing list
GeoNetwork-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geonetwork-devel
GeoNetwork OpenSource is maintained at http://sourceforge.net/projects/geonetwork


Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf


GeoNetwork-devel mailing list
GeoNetwork-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geonetwork-devel
GeoNetwork OpenSource is maintained at http://sourceforge.net/projects/geonetwork

Hi Heikki,

Yes - I was thinking that too (hence the sentence starting with "At present," :-)) - thanks for the pointers to the code too - I'll take a look!

Cheers and thanks,
Simon
________________________________________
From: heikki [tropicano@anonymised.com]
Sent: Sunday, 4 October 2009 7:38 AM
To: Pigot, Simon (CMAR, Hobart)
Cc: Martin.Aubrey@anonymised.com; geonetwork-devel@lists.sourceforge.net
Subject: Re: [GeoNetwork-devel] GeoNetwork 2.4.1 - java.lang.IllegalStateException: Element not found at ref =

hi Simon,

a question : would it not be a good idea to read schemas from the reference in schemaLocation, if the XSD is not already known to GeoNetwork ? At least an attempt could be made to do so, I guess. In the ebRIM branch we have some nifty schema-reading code that will load schemas, and any schemas referenced in them, etc. from remote locations. The class is org.geonetwork.utils.xsd.XSD in the project "geonetwork-services-ebrim".

Just my 2¢

Kind regards
Heikki Doeleman

On Sat, Oct 3, 2009 at 4:01 PM, <Simon.Pigot@anonymised.com> wrote:
Hi Martin,

Your issue happens when you edit an XML document, so maybe some background might help: when you edit an XML metadata document in GeoNetwork extra elements are added to the document (with prefix geonet:) - this is done in the java code of EditLib. One of these extra elements (geonet:element) is added to each element of the XML metadata document and contains a numeric id (attribute ref). This id is used by the editor XSLTs to label the html form inputs it creates so that they can be associated with the appropriate elements of the metadata document when the form is serialized and sent back to the server.

So the hash table/name,value pairs you can see in the request are the XML version of the serialized html form - eg. _23 would refer to the metadata element that had been given an id of 23 (via the ref attribute of a geonet:element added to it on edit).

Looking at the scenarios, it would appear that the xslt template which handles gmd:editionDate in metadata-iso19139.xsl is assuming that a gco:Date or gco:DateTime element will always be present as a child of gmd:editionDate - because it doesn't find one (and consequently doesn't find the ref attribute of a geonet:element) it adds an input to the html form that doesn't have a numeric id, hence you end up with the <_/> element in your request and the exception. The gco:nilReason attribute is being ignored.

I'll open a ticket on the editor to check assumptions about presence/absence of gco: elements and handle gco:nilReason for elements other than gco:CharacterString in update-fixed-info.xsl

You could probably fix most of the problem (but not the gco:nilReason handling) by making the template that handles gmd:editionDate in metadata-iso19139.xsl only match gmd:editionDate when it has a gco:Date/gco:DateTime element - do that by changing gmd:editionDate to gmd:editionDate[gco:Date|gco:DateTime] and ditto for gmd:dateOfNextUpdate.

Cheers and thanks,
Simon

[Also just looking at your scenario and the XML you were inserting - it would seem that your record is based on an extension of ISO19115/19139 (ISO19115-2?). Can I ask whether you have added the XSDs that describe the extensions to one of the schema directories (likely iso19139 if not using a profile) in GeoNetwork? At present, just having a schemalocation attribute in the XML document is not sufficient. The reason is that the GeoNetwork editor is schema driven, so GeoNetwork needs to read the appropriate XSDs on startup for the editor to make sense of an XML document - if you were to use the extension elements in XSDs that were not readable by GeoNetwork, they would most likely disappear when editing.

Action: create an enhancement ticket to include ISO19115-2 schema extensions in GeoNetwork. I think these have been published (but can't see them on isotc211 site - why?), where are the official ones published if not on the tc211 site?]

________________________________________
From: Martin Aubrey [Martin.Aubrey@anonymised.com<mailto:Martin.Aubrey@anonymised.com>]
Sent: Saturday, 3 October 2009 7:46 AM
To: geonetwork-devel@lists.sourceforge.net<mailto:geonetwork-devel@anonymised.comurceforge.net>
Subject: [GeoNetwork-devel] GeoNetwork 2.4.1 - java.lang.IllegalStateException: Element not found at ref =

My name is Martin Aubrey with NOAA NGDC.
I am inserting xml that is producing an IllegalStateException thrown
from the kernel DataManager.
This code calls org.fao.geonet.kernel.EditLib.findElement() and gets a
null value resulting in the
exception below.

---------------------------------------------------------------------------------------------------------------------------

Scenario:
1) insert xml
2) click id number and then Edit
3) click check to validate

Upon entry into the JeevesServlet engine, the request contains what
appears to be the original xml
being checked but transformed into a hash table...ex:

<request>
<position>-1</position>
<licenseurl />
<type />
<_23>fake abstract</_23>
<_12_gmdCOLONidentifier>gmd:MD_Identifier</_12_gmdCOLONidentifier>
<_25 />
<version>2</version>
<child />
<id>12</id>

<_1_gmdCOLONidentificationInfo>gmd:MD_DataIdentification</_1_gmdCOLONidentificationInfo>
<_20_codeListValue>creation</_20_codeListValue>
<name />
<_ />

<_1_gmdCOLONcontentInfo>gmd:MD_CoverageDescription</_1_gmdCOLONcontentInfo>
<fname />
<template>n</template>
<_1_gmdCOLONseries>gmd:DS_Initiative</_1_gmdCOLONseries>
<_6_gcoCOLONnilReason>missing</_6_gcoCOLONnilReason>
<editing>12</editing>
<_18>20091001</_18>

<_10_gmdCOLONresourceConstraints>gmd:MD_Constraints</_10_gmdCOLONresourceConstraints>
<access />
<_14>FAKE TITLE</_14>
<showvalidationerrors>true</showvalidationerrors>

<_1_gmdCOLONspatialRepresentationInfo>gmd:MD_Georectified</_1_gmdCOLONspatialRepresentationInfo>
<ref />

<_1_gmdCOLONmetadataConstraints>gmd:MD_Constraints</_1_gmdCOLONmetadataConstraints>
<currTab>simple</currTab>
</request>

NOTE the <_ /> in this list. This hash table eventually makes its way
to EditUtils where the htChanges hash is
build...skipping the underscore and using the blank object as a
key...this hash makes its way to the DataManager
who iterates through this calling EditLib.findElement() passing a blank
reference to search on.
This findElement method is recurrsive with 3 return points which seems
odd but the net of this is that this code does
not handle a hash build from a list containing <_ /> and returns null.
The DataManager then throws the exception.

I would like to find out if the <_ /> coming into the JeevesServlet is
valid or not and what code produces this...!!
Is the htchanges hash table valid in this case. Maybe this table should
not be built and used unless an xsd validation
completes successfully...?
If valid then the findElement() may need some work.

---------------------------------------------------------------------------------------------------------------------------
2009-10-02 14:03:16,133 ERROR [jeeves.service] - Exception when
executing service
2009-10-02 14:03:16,133 ERROR [jeeves.service] - (C) Exc :
java.lang.IllegalStateException: Element not found at ref =
2009-10-02 14:03:16,134 DEBUG [jeeves.service] - Raised exception while
executing service
<error id="error">
<message>Element not found at ref =</message>
<class>IllegalStateException</class>
<stack>
   <at class="org.fao.geonet.kernel.DataManager"
file="DataManager.java" line="1355" method="updateMetadataEmbedded" />
   <at class="org.fao.geonet.services.metadata.EditUtils"
file="EditUtils.java" line="140" method="updateContent" />
   <at class="org.fao.geonet.services.metadata.Update"
file="Update.java" line="103" method="exec" />
   <at class="jeeves.server.dispatchers.ServiceInfo"
file="ServiceInfo.java" line="256" method="execService" />
   <at class="jeeves.server.dispatchers.ServiceInfo"
file="ServiceInfo.java" line="159" method="execServices" />
   <at class="jeeves.server.dispatchers.ServiceManager"
file="ServiceManager.java" line="380" method="dispatch" />
   <at class="jeeves.server.JeevesEngine" file="JeevesEngine.java"
line="623" method="dispatch" />
   <at class="jeeves.server.sources.http.JeevesServlet"
file="JeevesServlet.java" line="204" method="execute" />
   <at class="jeeves.server.sources.http.JeevesServlet"
file="JeevesServlet.java" line="102" method="doPost" />
   <at class="javax.servlet.http.HttpServlet" file="HttpServlet.java"
line="727" method="service" />
</stack>
<request>
   <language>en</language>
   <service>metadata.update</service>
</request>
</error>
---------------------------------------------------------------------------------------------------------------------------
Inserted xml: The xml that follows has 7 test scenarios of which 3
produce the exception above.

<gmd:MD_Metadata xmlns:gmi="http://www.isotc211.org/2005/gmi&quot;
xmlns:gts="http://www.isotc211.org/2005/gts&quot;
xmlns:gco="http://www.isotc211.org/2005/gco&quot;
xmlns:gmd="http://www.isotc211.org/2005/gmd&quot;
xmlns:srv="http://www.isotc211.org/2005/srv&quot;
xmlns:gmx="http://www.isotc211.org/2005/gmx&quot;
       xmlns:gss="http://www.isotc211.org/2005/gss&quot;
xmlns:gsr="http://www.isotc211.org/2005/gsr&quot;
xmlns:gml="http://www.opengis.net/gml&quot;
xmlns:xlink="http://www.w3.org/1999/xlink&quot;
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance&quot;
xsi:schemaLocation="GMD — Resource site for ISO/TC 211 Geographic information/Geomatics
       http://www.ngdc.noaa.gov/metadata/published/xsd/schema.xsd&quot;&gt;
       <gmd:contact>
               <gmd:CI_ResponsibleParty>
                       <gmd:role gco:nilReason="missing"/>
               </gmd:CI_ResponsibleParty>
       </gmd:contact>
       <gmd:dateStamp>
               <gco:Date>2009-10-01</gco:Date>

       </gmd:dateStamp>
       <gmd:identificationInfo>
               <gmd:MD_DataIdentification>
                       <gmd:citation>
                               <gmd:CI_Citation>
                                       <gmd:title>

<gco:CharacterString>FAKE TITLE</gco:CharacterString>
                                       </gmd:title>

                                       <gmd:date>
                                               <gmd:CI_Date>
                                                       <gmd:date>

<gco:Date>20091001</gco:Date>
                                                       </gmd:date>
                                                       <gmd:dateType>

<gmd:CI_DateTypeCode codeList="#fakeURL"
codeListValue="creation">creation</gmd:CI_DateTypeCode>
                                                       </gmd:dateType>

                                               </gmd:CI_Date>
                                       </gmd:date>
                                      <!-- 1. validate ok...no ref
error -->

<!--<gmd:editionDate><gco:Date>2009-10-02</gco:Date></gmd:editionDate> -->

                                       <!-- 2. validate ok with ref
error-->
                                       <!-- <gmd:editionDate
gco:nilReason="unknown"/> -->

                                       <!-- 3. validate ok...no ref
error -->
                                       <!--<gmd:editionDate
gco:nilReason="unknown">

<gco:Date>2009-10-02</gco:Date>
                                       </gmd:editionDate> -->

                                       <!-- 4. does not validate...no
ref error-->
                                       <!-- <gmd:editionDate
gco:nilReason="unknown">
                                               <gco:Date/>
                                               </gmd:editionDate>-->

                                       <!-- 5. should not validate OR
should autopopulate with 'gco:nilReason="missing" and then validate-->
                                       <!-- validate OK with ref
error-->
                                       <!-- <gmd:editionDate/> -->

                                       <!-- 6. does not validate with
ref error -->

<!--<gmd:editionDate><gco:CharacterString>2009-10-02</gco:CharacterString></gmd:editionDate>
-->

                                       <!-- 7. does not validate...no
ref error -->
                                       <!--<gmd:editionDate>
                                               <gco:Date/>
                                               </gmd:editionDate> -->

                               </gmd:CI_Citation>
                       </gmd:citation>
                       <gmd:abstract>
                               <gco:CharacterString>fake
abstract</gco:CharacterString>
                       </gmd:abstract>
                       <gmd:language>

<gco:CharacterString>esperante</gco:CharacterString>
                       </gmd:language>
               </gmd:MD_DataIdentification>
       </gmd:identificationInfo>
</gmd:MD_Metadata>

---------------------------------------------------------------------------------------------------------------------------

------------------------------------------------------------------------------
Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;

_______________________________________________
GeoNetwork-devel mailing list
GeoNetwork-devel@lists.sourceforge.net<mailto:GeoNetwork-devel@anonymised.comforge.net>

GeoNetwork OpenSource is maintained at http://sourceforge.net/projects/geonetwork

------------------------------------------------------------------------------
Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;

_______________________________________________
GeoNetwork-devel mailing list
GeoNetwork-devel@lists.sourceforge.net<mailto:GeoNetwork-devel@anonymised.comforge.net>

GeoNetwork OpenSource is maintained at http://sourceforge.net/projects/geonetwork

Simon,

Great info and many thanks for figuring out this nilReason handling problem. Aren't you glad we Geonetwork users are out there pushing the limits? :wink:

If you or anyone else implements this fix, please let us know so we can download and rebuild.

PS: You have a very sharp eye; yes we are using ISO 19115-2. We've got the XSDs and XSLs working pretty well, we think. I believe we can contribute these to the 2.5 trunk if you wish. (Though I won't promise that for certain w/o talking to some others here at NOAA).

Thanks,
--Rich

Richard Fozzard, Computer Scientist
  Geospatial Metadata at NGDC: http://www.ngdc.noaa.gov/metadata

Cooperative Institute for Research in Environmental Sciences (CIRES)
Univ. Colorado & NOAA National Geophysical Data Center, Enterprise Data Systems 325 S. Broadway, Skaggs 1B-305, Boulder, CO 80305
Office: 303-497-6487, Cell: 303-579-5615, Email: richard.fozzard@anonymised.com

Simon.Pigot@anonymised.com said the following on 10/03/2009 08:01 AM:

Hi Martin,

Your issue happens when you edit an XML document, so maybe some background might help: when you edit an XML metadata document in GeoNetwork extra elements are added to the document (with prefix geonet:) - this is done in the java code of EditLib. One of these extra elements (geonet:element) is added to each element of the XML metadata document and contains a numeric id (attribute ref). This id is used by the editor XSLTs to label the html form inputs it creates so that they can be associated with the appropriate elements of the metadata document when the form is serialized and sent back to the server.

So the hash table/name,value pairs you can see in the request are the XML version of the serialized html form - eg. _23 would refer to the metadata element that had been given an id of 23 (via the ref attribute of a geonet:element added to it on edit).

Looking at the scenarios, it would appear that the xslt template which handles gmd:editionDate in metadata-iso19139.xsl is assuming that a gco:Date or gco:DateTime element will always be present as a child of gmd:editionDate - because it doesn't find one (and consequently doesn't find the ref attribute of a geonet:element) it adds an input to the html form that doesn't have a numeric id, hence you end up with the <_/> element in your request and the exception. The gco:nilReason attribute is being ignored.

I'll open a ticket on the editor to check assumptions about presence/absence of gco: elements and handle gco:nilReason for elements other than gco:CharacterString in update-fixed-info.xsl

You could probably fix most of the problem (but not the gco:nilReason handling) by making the template that handles gmd:editionDate in metadata-iso19139.xsl only match gmd:editionDate when it has a gco:Date/gco:DateTime element - do that by changing gmd:editionDate to gmd:editionDate[gco:Date|gco:DateTime] and ditto for gmd:dateOfNextUpdate.

Cheers and thanks,
Simon

[Also just looking at your scenario and the XML you were inserting - it would seem that your record is based on an extension of ISO19115/19139 (ISO19115-2?). Can I ask whether you have added the XSDs that describe the extensions to one of the schema directories (likely iso19139 if not using a profile) in GeoNetwork? At present, just having a schemalocation attribute in the XML document is not sufficient. The reason is that the GeoNetwork editor is schema driven, so GeoNetwork needs to read the appropriate XSDs on startup for the editor to make sense of an XML document - if you were to use the extension elements in XSDs that were not readable by GeoNetwork, they would most likely disappear when editing.

Action: create an enhancement ticket to include ISO19115-2 schema extensions in GeoNetwork. I think these have been published (but can't see them on isotc211 site - why?), where are the official ones published if not on the tc211 site?]

________________________________________
From: Martin Aubrey [Martin.Aubrey@anonymised.com]
Sent: Saturday, 3 October 2009 7:46 AM
To: geonetwork-devel@lists.sourceforge.net
Subject: [GeoNetwork-devel] GeoNetwork 2.4.1 - java.lang.IllegalStateException: Element not found at ref =

My name is Martin Aubrey with NOAA NGDC.
I am inserting xml that is producing an IllegalStateException thrown
from the kernel DataManager.
This code calls org.fao.geonet.kernel.EditLib.findElement() and gets a
null value resulting in the
exception below.

---------------------------------------------------------------------------------------------------------------------------

Scenario:
1) insert xml
2) click id number and then Edit
3) click check to validate

Upon entry into the JeevesServlet engine, the request contains what
appears to be the original xml
being checked but transformed into a hash table...ex:

<request>
  <position>-1</position>
  <licenseurl />
  <type />
  <_23>fake abstract</_23>
  <_12_gmdCOLONidentifier>gmd:MD_Identifier</_12_gmdCOLONidentifier>
  <_25 />
  <version>2</version>
  <child />
  <id>12</id>

<_1_gmdCOLONidentificationInfo>gmd:MD_DataIdentification</_1_gmdCOLONidentificationInfo>
  <_20_codeListValue>creation</_20_codeListValue>
  <name />
  <_ />

<_1_gmdCOLONcontentInfo>gmd:MD_CoverageDescription</_1_gmdCOLONcontentInfo>
  <fname />
  <template>n</template>
  <_1_gmdCOLONseries>gmd:DS_Initiative</_1_gmdCOLONseries>
  <_6_gcoCOLONnilReason>missing</_6_gcoCOLONnilReason>
  <editing>12</editing>
  <_18>20091001</_18>

<_10_gmdCOLONresourceConstraints>gmd:MD_Constraints</_10_gmdCOLONresourceConstraints>
  <access />
  <_14>FAKE TITLE</_14>
  <showvalidationerrors>true</showvalidationerrors>

<_1_gmdCOLONspatialRepresentationInfo>gmd:MD_Georectified</_1_gmdCOLONspatialRepresentationInfo>
  <ref />

<_1_gmdCOLONmetadataConstraints>gmd:MD_Constraints</_1_gmdCOLONmetadataConstraints>
  <currTab>simple</currTab>
</request>

NOTE the <_ /> in this list. This hash table eventually makes its way
to EditUtils where the htChanges hash is
build...skipping the underscore and using the blank object as a
key...this hash makes its way to the DataManager
who iterates through this calling EditLib.findElement() passing a blank
reference to search on.
This findElement method is recurrsive with 3 return points which seems
odd but the net of this is that this code does
not handle a hash build from a list containing <_ /> and returns null.
The DataManager then throws the exception.

I would like to find out if the <_ /> coming into the JeevesServlet is
valid or not and what code produces this...!!
Is the htchanges hash table valid in this case. Maybe this table should
not be built and used unless an xsd validation
completes successfully...?
If valid then the findElement() may need some work.

---------------------------------------------------------------------------------------------------------------------------
2009-10-02 14:03:16,133 ERROR [jeeves.service] - Exception when
executing service
2009-10-02 14:03:16,133 ERROR [jeeves.service] - (C) Exc :
java.lang.IllegalStateException: Element not found at ref =
2009-10-02 14:03:16,134 DEBUG [jeeves.service] - Raised exception while
executing service
<error id="error">
  <message>Element not found at ref =</message>
  <class>IllegalStateException</class>
  <stack>
    <at class="org.fao.geonet.kernel.DataManager"
file="DataManager.java" line="1355" method="updateMetadataEmbedded" />
    <at class="org.fao.geonet.services.metadata.EditUtils"
file="EditUtils.java" line="140" method="updateContent" />
    <at class="org.fao.geonet.services.metadata.Update"
file="Update.java" line="103" method="exec" />
    <at class="jeeves.server.dispatchers.ServiceInfo"
file="ServiceInfo.java" line="256" method="execService" />
    <at class="jeeves.server.dispatchers.ServiceInfo"
file="ServiceInfo.java" line="159" method="execServices" />
    <at class="jeeves.server.dispatchers.ServiceManager"
file="ServiceManager.java" line="380" method="dispatch" />
    <at class="jeeves.server.JeevesEngine" file="JeevesEngine.java"
line="623" method="dispatch" />
    <at class="jeeves.server.sources.http.JeevesServlet"
file="JeevesServlet.java" line="204" method="execute" />
    <at class="jeeves.server.sources.http.JeevesServlet"
file="JeevesServlet.java" line="102" method="doPost" />
    <at class="javax.servlet.http.HttpServlet" file="HttpServlet.java"
line="727" method="service" />
  </stack>
  <request>
    <language>en</language>
    <service>metadata.update</service>
  </request>
</error>
---------------------------------------------------------------------------------------------------------------------------
Inserted xml: The xml that follows has 7 test scenarios of which 3
produce the exception above.

<gmd:MD_Metadata xmlns:gmi="http://www.isotc211.org/2005/gmi&quot;
xmlns:gts="http://www.isotc211.org/2005/gts&quot;
xmlns:gco="http://www.isotc211.org/2005/gco&quot;
xmlns:gmd="http://www.isotc211.org/2005/gmd&quot;
xmlns:srv="http://www.isotc211.org/2005/srv&quot;
xmlns:gmx="http://www.isotc211.org/2005/gmx&quot;
        xmlns:gss="http://www.isotc211.org/2005/gss&quot;
xmlns:gsr="http://www.isotc211.org/2005/gsr&quot;
xmlns:gml="http://www.opengis.net/gml&quot;
xmlns:xlink="http://www.w3.org/1999/xlink&quot;
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance&quot;
xsi:schemaLocation="http://www.isotc211.org/2005/gmd
        http://www.ngdc.noaa.gov/metadata/published/xsd/schema.xsd&quot;&gt;
        <gmd:contact>
                <gmd:CI_ResponsibleParty>
                        <gmd:role gco:nilReason="missing"/>
                </gmd:CI_ResponsibleParty>
        </gmd:contact>
        <gmd:dateStamp>
                <gco:Date>2009-10-01</gco:Date>

        </gmd:dateStamp>
        <gmd:identificationInfo>
                <gmd:MD_DataIdentification>
                        <gmd:citation>
                                <gmd:CI_Citation>
                                        <gmd:title>

<gco:CharacterString>FAKE TITLE</gco:CharacterString>
                                        </gmd:title>

                                        <gmd:date>
                                                <gmd:CI_Date>
                                                        <gmd:date>

<gco:Date>20091001</gco:Date>
                                                        </gmd:date>
                                                        <gmd:dateType>

<gmd:CI_DateTypeCode codeList="#fakeURL"
codeListValue="creation">creation</gmd:CI_DateTypeCode>
                                                        </gmd:dateType>

                                                </gmd:CI_Date>
                                        </gmd:date>
                                       <!-- 1. validate ok...no ref
error -->

<!--<gmd:editionDate><gco:Date>2009-10-02</gco:Date></gmd:editionDate> -->

                                        <!-- 2. validate ok with ref
error-->
                                        <!-- <gmd:editionDate
gco:nilReason="unknown"/> -->

                                        <!-- 3. validate ok...no ref
error -->
                                        <!--<gmd:editionDate
gco:nilReason="unknown">

<gco:Date>2009-10-02</gco:Date>
                                        </gmd:editionDate> -->

                                        <!-- 4. does not validate...no
ref error-->
                                        <!-- <gmd:editionDate
gco:nilReason="unknown">
                                                <gco:Date/>
                                                </gmd:editionDate>-->

                                        <!-- 5. should not validate OR
should autopopulate with 'gco:nilReason="missing" and then validate-->
                                        <!-- validate OK with ref
error-->
                                        <!-- <gmd:editionDate/> -->

                                        <!-- 6. does not validate with
ref error -->

<!--<gmd:editionDate><gco:CharacterString>2009-10-02</gco:CharacterString></gmd:editionDate>
-->

                                        <!-- 7. does not validate...no
ref error -->
                                        <!--<gmd:editionDate>
                                                <gco:Date/>
                                                </gmd:editionDate> -->

                                </gmd:CI_Citation>
                        </gmd:citation>
                        <gmd:abstract>
                                <gco:CharacterString>fake
abstract</gco:CharacterString>
                        </gmd:abstract>
                        <gmd:language>

<gco:CharacterString>esperante</gco:CharacterString>
                        </gmd:language>
                </gmd:MD_DataIdentification>
        </gmd:identificationInfo>
</gmd:MD_Metadata>

---------------------------------------------------------------------------------------------------------------------------

------------------------------------------------------------------------------
Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
http://p.sf.net/sfu/devconf
_______________________________________________
GeoNetwork-devel mailing list
GeoNetwork-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geonetwork-devel
GeoNetwork OpenSource is maintained at http://sourceforge.net/projects/geonetwork

------------------------------------------------------------------------------
Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
http://p.sf.net/sfu/devconf
_______________________________________________
GeoNetwork-devel mailing list
GeoNetwork-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geonetwork-devel
GeoNetwork OpenSource is maintained at http://sourceforge.net/projects/geonetwork
  

Hi Rich,

Definitely glad to have users pushing the limits and doing things like your team!

I'm interested in adding 19115-2 support - can I see the xslts and try them out at some stage? We might have some users here in Australia who could provide feedback as well - also would be good to add them to 2.5 although bear in mind this is due to come out mid November.

Cheers and thanks,
Simon

________________________________________
From: Richard Fozzard [Richard.Fozzard@anonymised.com]
Sent: Tuesday, 6 October 2009 10:33 AM
To: Pigot, Simon (CMAR, Hobart)
Cc: geonetwork-devel@lists.sourceforge.net
Subject: Re: [GeoNetwork-devel] GeoNetwork 2.4.1 - java.lang.IllegalStateException: Element not found at ref =

Simon,

Great info and many thanks for figuring out this nilReason handling
problem. Aren't you glad we Geonetwork users are out there pushing the
limits? :wink:

If you or anyone else implements this fix, please let us know so we can
download and rebuild.

PS: You have a very sharp eye; yes we are using ISO 19115-2. We've got
the XSDs and XSLs working pretty well, we think. I believe we can
contribute these to the 2.5 trunk if you wish. (Though I won't promise
that for certain w/o talking to some others here at NOAA).

Thanks,
--Rich

Richard Fozzard, Computer Scientist
  Geospatial Metadata at NGDC: http://www.ngdc.noaa.gov/metadata

Cooperative Institute for Research in Environmental Sciences (CIRES)
Univ. Colorado & NOAA National Geophysical Data Center, Enterprise Data Systems
325 S. Broadway, Skaggs 1B-305, Boulder, CO 80305
Office: 303-497-6487, Cell: 303-579-5615, Email: richard.fozzard@anonymised.com

Simon.Pigot@anonymised.com said the following on 10/03/2009 08:01 AM:

Hi Martin,

Your issue happens when you edit an XML document, so maybe some background might help: when you edit an XML metadata document in GeoNetwork extra elements are added to the document (with prefix geonet:) - this is done in the java code of EditLib. One of these extra elements (geonet:element) is added to each element of the XML metadata document and contains a numeric id (attribute ref). This id is used by the editor XSLTs to label the html form inputs it creates so that they can be associated with the appropriate elements of the metadata document when the form is serialized and sent back to the server.

So the hash table/name,value pairs you can see in the request are the XML version of the serialized html form - eg. _23 would refer to the metadata element that had been given an id of 23 (via the ref attribute of a geonet:element added to it on edit).

Looking at the scenarios, it would appear that the xslt template which handles gmd:editionDate in metadata-iso19139.xsl is assuming that a gco:Date or gco:DateTime element will always be present as a child of gmd:editionDate - because it doesn't find one (and consequently doesn't find the ref attribute of a geonet:element) it adds an input to the html form that doesn't have a numeric id, hence you end up with the <_/> element in your request and the exception. The gco:nilReason attribute is being ignored.

I'll open a ticket on the editor to check assumptions about presence/absence of gco: elements and handle gco:nilReason for elements other than gco:CharacterString in update-fixed-info.xsl

You could probably fix most of the problem (but not the gco:nilReason handling) by making the template that handles gmd:editionDate in metadata-iso19139.xsl only match gmd:editionDate when it has a gco:Date/gco:DateTime element - do that by changing gmd:editionDate to gmd:editionDate[gco:Date|gco:DateTime] and ditto for gmd:dateOfNextUpdate.

Cheers and thanks,
Simon

[Also just looking at your scenario and the XML you were inserting - it would seem that your record is based on an extension of ISO19115/19139 (ISO19115-2?). Can I ask whether you have added the XSDs that describe the extensions to one of the schema directories (likely iso19139 if not using a profile) in GeoNetwork? At present, just having a schemalocation attribute in the XML document is not sufficient. The reason is that the GeoNetwork editor is schema driven, so GeoNetwork needs to read the appropriate XSDs on startup for the editor to make sense of an XML document - if you were to use the extension elements in XSDs that were not readable by GeoNetwork, they would most likely disappear when editing.

Action: create an enhancement ticket to include ISO19115-2 schema extensions in GeoNetwork. I think these have been published (but can't see them on isotc211 site - why?), where are the official ones published if not on the tc211 site?]

________________________________________
From: Martin Aubrey [Martin.Aubrey@anonymised.com]
Sent: Saturday, 3 October 2009 7:46 AM
To: geonetwork-devel@lists.sourceforge.net
Subject: [GeoNetwork-devel] GeoNetwork 2.4.1 - java.lang.IllegalStateException: Element not found at ref =

My name is Martin Aubrey with NOAA NGDC.
I am inserting xml that is producing an IllegalStateException thrown
from the kernel DataManager.
This code calls org.fao.geonet.kernel.EditLib.findElement() and gets a
null value resulting in the
exception below.

---------------------------------------------------------------------------------------------------------------------------

Scenario:
1) insert xml
2) click id number and then Edit
3) click check to validate

Upon entry into the JeevesServlet engine, the request contains what
appears to be the original xml
being checked but transformed into a hash table...ex:

<request>
  <position>-1</position>
  <licenseurl />
  <type />
  <_23>fake abstract</_23>
  <_12_gmdCOLONidentifier>gmd:MD_Identifier</_12_gmdCOLONidentifier>
  <_25 />
  <version>2</version>
  <child />
  <id>12</id>

<_1_gmdCOLONidentificationInfo>gmd:MD_DataIdentification</_1_gmdCOLONidentificationInfo>
  <_20_codeListValue>creation</_20_codeListValue>
  <name />
  <_ />

<_1_gmdCOLONcontentInfo>gmd:MD_CoverageDescription</_1_gmdCOLONcontentInfo>
  <fname />
  <template>n</template>
  <_1_gmdCOLONseries>gmd:DS_Initiative</_1_gmdCOLONseries>
  <_6_gcoCOLONnilReason>missing</_6_gcoCOLONnilReason>
  <editing>12</editing>
  <_18>20091001</_18>

<_10_gmdCOLONresourceConstraints>gmd:MD_Constraints</_10_gmdCOLONresourceConstraints>
  <access />
  <_14>FAKE TITLE</_14>
  <showvalidationerrors>true</showvalidationerrors>

<_1_gmdCOLONspatialRepresentationInfo>gmd:MD_Georectified</_1_gmdCOLONspatialRepresentationInfo>
  <ref />

<_1_gmdCOLONmetadataConstraints>gmd:MD_Constraints</_1_gmdCOLONmetadataConstraints>
  <currTab>simple</currTab>
</request>

NOTE the <_ /> in this list. This hash table eventually makes its way
to EditUtils where the htChanges hash is
build...skipping the underscore and using the blank object as a
key...this hash makes its way to the DataManager
who iterates through this calling EditLib.findElement() passing a blank
reference to search on.
This findElement method is recurrsive with 3 return points which seems
odd but the net of this is that this code does
not handle a hash build from a list containing <_ /> and returns null.
The DataManager then throws the exception.

I would like to find out if the <_ /> coming into the JeevesServlet is
valid or not and what code produces this...!!
Is the htchanges hash table valid in this case. Maybe this table should
not be built and used unless an xsd validation
completes successfully...?
If valid then the findElement() may need some work.

---------------------------------------------------------------------------------------------------------------------------
2009-10-02 14:03:16,133 ERROR [jeeves.service] - Exception when
executing service
2009-10-02 14:03:16,133 ERROR [jeeves.service] - (C) Exc :
java.lang.IllegalStateException: Element not found at ref =
2009-10-02 14:03:16,134 DEBUG [jeeves.service] - Raised exception while
executing service
<error id="error">
  <message>Element not found at ref =</message>
  <class>IllegalStateException</class>
  <stack>
    <at class="org.fao.geonet.kernel.DataManager"
file="DataManager.java" line="1355" method="updateMetadataEmbedded" />
    <at class="org.fao.geonet.services.metadata.EditUtils"
file="EditUtils.java" line="140" method="updateContent" />
    <at class="org.fao.geonet.services.metadata.Update"
file="Update.java" line="103" method="exec" />
    <at class="jeeves.server.dispatchers.ServiceInfo"
file="ServiceInfo.java" line="256" method="execService" />
    <at class="jeeves.server.dispatchers.ServiceInfo"
file="ServiceInfo.java" line="159" method="execServices" />
    <at class="jeeves.server.dispatchers.ServiceManager"
file="ServiceManager.java" line="380" method="dispatch" />
    <at class="jeeves.server.JeevesEngine" file="JeevesEngine.java"
line="623" method="dispatch" />
    <at class="jeeves.server.sources.http.JeevesServlet"
file="JeevesServlet.java" line="204" method="execute" />
    <at class="jeeves.server.sources.http.JeevesServlet"
file="JeevesServlet.java" line="102" method="doPost" />
    <at class="javax.servlet.http.HttpServlet" file="HttpServlet.java"
line="727" method="service" />
  </stack>
  <request>
    <language>en</language>
    <service>metadata.update</service>
  </request>
</error>
---------------------------------------------------------------------------------------------------------------------------
Inserted xml: The xml that follows has 7 test scenarios of which 3
produce the exception above.

<gmd:MD_Metadata xmlns:gmi="http://www.isotc211.org/2005/gmi&quot;
xmlns:gts="http://www.isotc211.org/2005/gts&quot;
xmlns:gco="http://www.isotc211.org/2005/gco&quot;
xmlns:gmd="http://www.isotc211.org/2005/gmd&quot;
xmlns:srv="http://www.isotc211.org/2005/srv&quot;
xmlns:gmx="http://www.isotc211.org/2005/gmx&quot;
        xmlns:gss="http://www.isotc211.org/2005/gss&quot;
xmlns:gsr="http://www.isotc211.org/2005/gsr&quot;
xmlns:gml="http://www.opengis.net/gml&quot;
xmlns:xlink="http://www.w3.org/1999/xlink&quot;
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance&quot;
xsi:schemaLocation="GMD — Resource site for ISO/TC 211 Geographic information/Geomatics
        http://www.ngdc.noaa.gov/metadata/published/xsd/schema.xsd&quot;&gt;
        <gmd:contact>
                <gmd:CI_ResponsibleParty>
                        <gmd:role gco:nilReason="missing"/>
                </gmd:CI_ResponsibleParty>
        </gmd:contact>
        <gmd:dateStamp>
                <gco:Date>2009-10-01</gco:Date>

        </gmd:dateStamp>
        <gmd:identificationInfo>
                <gmd:MD_DataIdentification>
                        <gmd:citation>
                                <gmd:CI_Citation>
                                        <gmd:title>

<gco:CharacterString>FAKE TITLE</gco:CharacterString>
                                        </gmd:title>

                                        <gmd:date>
                                                <gmd:CI_Date>
                                                        <gmd:date>

<gco:Date>20091001</gco:Date>
                                                        </gmd:date>
                                                        <gmd:dateType>

<gmd:CI_DateTypeCode codeList="#fakeURL"
codeListValue="creation">creation</gmd:CI_DateTypeCode>
                                                        </gmd:dateType>

                                                </gmd:CI_Date>
                                        </gmd:date>
                                       <!-- 1. validate ok...no ref
error -->

<!--<gmd:editionDate><gco:Date>2009-10-02</gco:Date></gmd:editionDate> -->

                                        <!-- 2. validate ok with ref
error-->
                                        <!-- <gmd:editionDate
gco:nilReason="unknown"/> -->

                                        <!-- 3. validate ok...no ref
error -->
                                        <!--<gmd:editionDate
gco:nilReason="unknown">

<gco:Date>2009-10-02</gco:Date>
                                        </gmd:editionDate> -->

                                        <!-- 4. does not validate...no
ref error-->
                                        <!-- <gmd:editionDate
gco:nilReason="unknown">
                                                <gco:Date/>
                                                </gmd:editionDate>-->

                                        <!-- 5. should not validate OR
should autopopulate with 'gco:nilReason="missing" and then validate-->
                                        <!-- validate OK with ref
error-->
                                        <!-- <gmd:editionDate/> -->

                                        <!-- 6. does not validate with
ref error -->

<!--<gmd:editionDate><gco:CharacterString>2009-10-02</gco:CharacterString></gmd:editionDate>
-->

                                        <!-- 7. does not validate...no
ref error -->
                                        <!--<gmd:editionDate>
                                                <gco:Date/>
                                                </gmd:editionDate> -->

                                </gmd:CI_Citation>
                        </gmd:citation>
                        <gmd:abstract>
                                <gco:CharacterString>fake
abstract</gco:CharacterString>
                        </gmd:abstract>
                        <gmd:language>

<gco:CharacterString>esperante</gco:CharacterString>
                        </gmd:language>
                </gmd:MD_DataIdentification>
        </gmd:identificationInfo>
</gmd:MD_Metadata>

---------------------------------------------------------------------------------------------------------------------------

------------------------------------------------------------------------------
Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
Best Open Source Mac Front-Ends 2024
_______________________________________________
GeoNetwork-devel mailing list
GeoNetwork-devel@lists.sourceforge.net
geonetwork-devel List Signup and Options
GeoNetwork OpenSource is maintained at GeoNetwork - Geographic Metadata Catalog download | SourceForge.net

------------------------------------------------------------------------------
Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
Best Open Source Mac Front-Ends 2024
_______________________________________________
GeoNetwork-devel mailing list
GeoNetwork-devel@lists.sourceforge.net
geonetwork-devel List Signup and Options
GeoNetwork OpenSource is maintained at GeoNetwork - Geographic Metadata Catalog download | SourceForge.net

I am having this problem too. We are trying to import metadata created by
ArcGis. The metadata claims that it is ISO19115/DIS_ESRI1.0. We keep on
getting error messages with 'ref=<blank>' in them. Is it known that the
appropriate schema is missing from the 2.4.1/2 distribution?

Garey Mills
--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/GeoNetwork-2-4-1-java-lang-IllegalStateException-Element-not-found-at-ref-tp3757949p5086164.html
Sent from the GeoNetwork developer mailing list archive at Nabble.com.