[Geoserver-users] app-schema query fails with org.geotools.feature.NameImpl cannot be cast to org.opengis.feature.type.AttributeDescriptor

I have been testing some queries to a complex feature service using app-schema and am getting the following exception report for one query:

<ows:ExceptionReport version="1.0.0"
  xsi:schemaLocation="http://www.opengis.net/ows http://xxxx.geosciml.org/xxxxxxxx/schemas/ows/1.0.0/owsExceptionReport.xsd&quot;
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance&quot; xmlns:ows="http://www.opengis.net/ows&quot;&gt;
  <ows:Exception exceptionCode="NoApplicableCode">
    <ows:ExceptionText>java.lang.ClassCastException: org.geotools.feature.NameImpl cannot be cast to org.opengis.feature.type.AttributeDescriptor
org.geotools.feature.NameImpl cannot be cast to org.opengis.feature.type.AttributeDescriptor</ows:ExceptionText>
  </ows:Exception>
</ows:ExceptionReport>

Details as below:

Tested versions v2.3.1 and nightly build of 2013-05-09

The source data is in PostGIS with the tables created by the scripts in https://www.seegrid.csiro.au/subversion/GeoSciML/cgi-reference-dataset/tags/2013-05-15/data/database/cgi-reference-postgis.sql

The GeoServer app-schema configuration files are as in the data directory https://www.seegrid.csiro.au/subversion/GeoSciML/cgi-reference-dataset/tags/2013-05-15/services/geoserver/postgis/data

app-schema joining has been switched on.

The query which fails with the above exception is:

Query 1 (fails)
---
<?xml version="1.0" encoding="UTF-8"?>
<wfs:GetFeature xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance&quot;
    xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.1.0/wfs.xsd&quot;
    xmlns:gsml="http://xmlns.geosciml.org/GeoSciML-Core/3.1&quot;
    xmlns:gsmlgu="http://xmlns.geosciml.org/GeologicUnit/3.1&quot; xmlns:ogc="http://www.opengis.net/ogc&quot;
    xmlns:wfs="http://www.opengis.net/wfs&quot;
    xmlns:gml="http://www.opengis.net/gml/3.2&quot; service="WFS"
    version="1.1.0"
    maxFeatures="100"
    outputFormat="gml32">
    <wfs:Query typeName="gsml:MappedFeature">
        <ogc:Filter>
            <ogc:PropertyIsEqualTo>
                <ogc:PropertyName>gsml:specification/gsmlgu:GeologicUnit/gsml:relatedFeature/gsmlga:GeologicHistory/gsml:relatedFeature/gsmlga:GeologicEvent/gsmlga:olderNamedAge/@xlink:href</ogc:PropertyName>
                <ogc:Literal>http://resource.geosciml.org/classifier/ics/ischart/Devonian&lt;/ogc:Literal&gt;
            </ogc:PropertyIsEqualTo>
        </ogc:Filter>
    </wfs:Query>
</wfs:GetFeature>

---

A similar query but which queries some element rather than attribute content below works correctly to retrieve the matching features.

Query 2 (succeeds)
---

<?xml version="1.0" encoding="UTF-8"?>
<wfs:GetFeature xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance&quot;
    xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.1.0/wfs.xsd&quot;
    xmlns:gsml="http://xmlns.geosciml.org/GeoSciML-Core/3.1&quot;
    xmlns:gsmlgu="http://xmlns.geosciml.org/GeologicUnit/3.1&quot; xmlns:ogc="http://www.opengis.net/ogc&quot;
    xmlns:wfs="http://www.opengis.net/wfs&quot;
    xmlns:gml="http://www.opengis.net/gml/3.2&quot; service="WFS"
    version="1.1.0"
    maxFeatures="100"
    outputFormat="gml32">
    <wfs:Query typeName="gsml:MappedFeature">
        <ogc:Filter>
            <ogc:PropertyIsEqualTo>
                <ogc:PropertyName>gsml:specification/gsmlgu:GeologicUnit/gsml:relatedFeature/gsmlga:GeologicHistory/gsml:relatedFeature/gsmlga:GeologicEvent/gsmlga:eventEnvironment/swe:Category/swe:label</ogc:PropertyName>
                <ogc:Literal>terrestrial setting</ogc:Literal>
            </ogc:PropertyIsEqualTo>
        </ogc:Filter>
    </wfs:Query>
</wfs:GetFeature>

---

Another query very similar to Query 1 that queries the contents of the same xlink:href attribute but queries on gsmlgu:GeologicUnit features rather than the parent gsml:MappedFeature features of Query 1 succeeds in retrieving the matching features:

Query 3 (succeeds)
---
<?xml version="1.0" encoding="UTF-8"?>
<wfs:GetFeature xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance&quot;
    xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.1.0/wfs.xsd&quot;
    xmlns:gsmlgu="http://xmlns.geosciml.org/GeologicUnit/3.1&quot; xmlns:ogc="http://www.opengis.net/ogc&quot;
    xmlns:wfs="http://www.opengis.net/wfs&quot;
    xmlns:gml="http://www.opengis.net/gml/3.2&quot; service="WFS"
    version="1.1.0"
    maxFeatures="100"
    outputFormat="gml32">
    <wfs:Query typeName="gsmlgu:GeologicUnit">
        <ogc:Filter>
            <ogc:PropertyIsEqualTo>
                <ogc:PropertyName>gsml:relatedFeature/gsmlga:GeologicHistory/gsml:relatedFeature/gsmlga:GeologicEvent/gsmlga:olderNamedAge/@xlink:href</ogc:PropertyName>
                <ogc:Literal>http://resource.geosciml.org/classifier/ics/ischart/Devonian&lt;/ogc:Literal&gt;
            </ogc:PropertyIsEqualTo>
        </ogc:Filter>
    </wfs:Query>
</wfs:GetFeature>

---

Any ideas? Should I report a bug?

Marcus Sen

This message (and any attachments) is for the recipient only. NERC is subject to the Freedom of Information Act 2000 and the contents of this email and any reply you make may be disclosed by NERC unless it is exempt from release under the Act. Any material supplied to NERC may be stored in an electronic records management system.

Hi Marcus,

This is a bug indeed. I have raised it here:
https://jira.codehaus.org/browse/GEOT-4471.
The bug only occurs when filtering by xpath attributes with types (i.e.
gsml:MappedFeature) that has a geometry attribute with native CRS (from the
database), i.e. gsml:shape. It doesn't occur with the 3rd query because the
underlying type doesn't have any geometry attribute.
I know removing gsml:shape from the mapping file is not an option.. so there
isn't really a workaround unfortunately.

Cheers
Rini

--
View this message in context: http://osgeo-org.1560.x6.nabble.com/app-schema-query-fails-with-org-geotools-feature-NameImpl-cannot-be-cast-to-org-opengis-feature-typer-tp5053444p5055874.html
Sent from the GeoServer - User mailing list archive at Nabble.com.

Marcus,

I think this failure should now be fixed on master:
https://jira.codehaus.org/browse/GEOT-4471

Please try a nightly build older than this email.

Kind regards,
Ben.

On 15/05/13 23:02, Sen, Marcus A. wrote:

I have been testing some queries to a complex feature service using app-schema and am getting the following exception report for one query:

<ows:ExceptionReport version="1.0.0"
   xsi:schemaLocation="http://www.opengis.net/ows http://xxxx.geosciml.org/xxxxxxxx/schemas/ows/1.0.0/owsExceptionReport.xsd&quot;
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance&quot; xmlns:ows="http://www.opengis.net/ows&quot;&gt;
   <ows:Exception exceptionCode="NoApplicableCode">
     <ows:ExceptionText>java.lang.ClassCastException: org.geotools.feature.NameImpl cannot be cast to org.opengis.feature.type.AttributeDescriptor
org.geotools.feature.NameImpl cannot be cast to org.opengis.feature.type.AttributeDescriptor</ows:ExceptionText>
   </ows:Exception>
</ows:ExceptionReport>

Details as below:

Tested versions v2.3.1 and nightly build of 2013-05-09

The source data is in PostGIS with the tables created by the scripts in https://www.seegrid.csiro.au/subversion/GeoSciML/cgi-reference-dataset/tags/2013-05-15/data/database/cgi-reference-postgis.sql

The GeoServer app-schema configuration files are as in the data directory https://www.seegrid.csiro.au/subversion/GeoSciML/cgi-reference-dataset/tags/2013-05-15/services/geoserver/postgis/data

app-schema joining has been switched on.

The query which fails with the above exception is:

Query 1 (fails)
---
<?xml version="1.0" encoding="UTF-8"?>
<wfs:GetFeature xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance&quot;
     xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.1.0/wfs.xsd&quot;
     xmlns:gsml="http://xmlns.geosciml.org/GeoSciML-Core/3.1&quot;
     xmlns:gsmlgu="http://xmlns.geosciml.org/GeologicUnit/3.1&quot; xmlns:ogc="http://www.opengis.net/ogc&quot;
     xmlns:wfs="http://www.opengis.net/wfs&quot;
     xmlns:gml="http://www.opengis.net/gml/3.2&quot; service="WFS"
     version="1.1.0"
     maxFeatures="100"
     outputFormat="gml32">
     <wfs:Query typeName="gsml:MappedFeature">
         <ogc:Filter>
             <ogc:PropertyIsEqualTo>
                 <ogc:PropertyName>gsml:specification/gsmlgu:GeologicUnit/gsml:relatedFeature/gsmlga:GeologicHistory/gsml:relatedFeature/gsmlga:GeologicEvent/gsmlga:olderNamedAge/@xlink:href</ogc:PropertyName>
                 <ogc:Literal>http://resource.geosciml.org/classifier/ics/ischart/Devonian&lt;/ogc:Literal&gt;
             </ogc:PropertyIsEqualTo>
         </ogc:Filter>
     </wfs:Query>
</wfs:GetFeature>

---

A similar query but which queries some element rather than attribute content below works correctly to retrieve the matching features.

Query 2 (succeeds)
---

<?xml version="1.0" encoding="UTF-8"?>
<wfs:GetFeature xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance&quot;
     xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.1.0/wfs.xsd&quot;
     xmlns:gsml="http://xmlns.geosciml.org/GeoSciML-Core/3.1&quot;
     xmlns:gsmlgu="http://xmlns.geosciml.org/GeologicUnit/3.1&quot; xmlns:ogc="http://www.opengis.net/ogc&quot;
     xmlns:wfs="http://www.opengis.net/wfs&quot;
     xmlns:gml="http://www.opengis.net/gml/3.2&quot; service="WFS"
     version="1.1.0"
     maxFeatures="100"
     outputFormat="gml32">
     <wfs:Query typeName="gsml:MappedFeature">
         <ogc:Filter>
             <ogc:PropertyIsEqualTo>
                 <ogc:PropertyName>gsml:specification/gsmlgu:GeologicUnit/gsml:relatedFeature/gsmlga:GeologicHistory/gsml:relatedFeature/gsmlga:GeologicEvent/gsmlga:eventEnvironment/swe:Category/swe:label</ogc:PropertyName>
                 <ogc:Literal>terrestrial setting</ogc:Literal>
             </ogc:PropertyIsEqualTo>
         </ogc:Filter>
     </wfs:Query>
</wfs:GetFeature>

---

Another query very similar to Query 1 that queries the contents of the same xlink:href attribute but queries on gsmlgu:GeologicUnit features rather than the parent gsml:MappedFeature features of Query 1 succeeds in retrieving the matching features:

Query 3 (succeeds)
---
<?xml version="1.0" encoding="UTF-8"?>
<wfs:GetFeature xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance&quot;
     xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.1.0/wfs.xsd&quot;
     xmlns:gsmlgu="http://xmlns.geosciml.org/GeologicUnit/3.1&quot; xmlns:ogc="http://www.opengis.net/ogc&quot;
     xmlns:wfs="http://www.opengis.net/wfs&quot;
     xmlns:gml="http://www.opengis.net/gml/3.2&quot; service="WFS"
     version="1.1.0"
     maxFeatures="100"
     outputFormat="gml32">
     <wfs:Query typeName="gsmlgu:GeologicUnit">
         <ogc:Filter>
             <ogc:PropertyIsEqualTo>
                 <ogc:PropertyName>gsml:relatedFeature/gsmlga:GeologicHistory/gsml:relatedFeature/gsmlga:GeologicEvent/gsmlga:olderNamedAge/@xlink:href</ogc:PropertyName>
                 <ogc:Literal>http://resource.geosciml.org/classifier/ics/ischart/Devonian&lt;/ogc:Literal&gt;
             </ogc:PropertyIsEqualTo>
         </ogc:Filter>
     </wfs:Query>
</wfs:GetFeature>

---

Any ideas? Should I report a bug?

Marcus Sen

This message (and any attachments) is for the recipient only. NERC is subject to the Freedom of Information Act 2000 and the contents of this email and any reply you make may be disclosed by NERC unless it is exempt from release under the Act. Any material supplied to NERC may be stored in an electronic records management system.
------------------------------------------------------------------------------
AlienVault Unified Security Management (USM) platform delivers complete
security visibility with the essential security capabilities. Easily and
efficiently configure, manage, and operate all of your security controls
from a single console and one unified framework. Download a free trial.
http://p.sf.net/sfu/alienvault_d2d
_______________________________________________
Geoserver-users mailing list
Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

--
Ben Caradoc-Davies <Ben.Caradoc-Davies@anonymised.com>
Software Engineer
CSIRO Earth Science and Resource Engineering
Australian Resources Research Centre

-----Original Message-----
From: Ben Caradoc-Davies [mailto:Ben.Caradoc-Davies@…367…]
Sent: 25 June 2013 10:33
To: Sen, Marcus A.
Cc: geoserver-users@lists.sourceforge.net
Subject: Re: [Geoserver-users] app-schema query fails with
org.geotools.feature.NameImpl cannot be cast to
org.opengis.feature.type.AttributeDescriptor

Marcus,

I think this failure should now be fixed on master:
https://jira.codehaus.org/browse/GEOT-4471

Please try a nightly build older than this email.

I assume you meant "newer" than this email :slight_smile:

Anyway, I've tried nightly build 2013-07-05 now and it seems to have fixed the problem.

Thanks,

Marcus Sen

This message (and any attachments) is for the recipient only. NERC is subject to the Freedom of Information Act 2000 and the contents of this email and any reply you make may be disclosed by NERC unless it is exempt from release under the Act. Any material supplied to NERC may be stored in an electronic records management system.

On 05/07/13 17:25, Sen, Marcus A. wrote:

Please try a nightly build older than this email.

I assume you meant "newer" than this email :slight_smile:

Oops, yes indeed.

Anyway, I've tried nightly build 2013-07-05 now and it seems to have fixed the problem.

Thanks for the confirmation.

Kind regards,

--
Ben Caradoc-Davies <Ben.Caradoc-Davies@anonymised.com>
Software Engineer
CSIRO Earth Science and Resource Engineering
Australian Resources Research Centre