[Geoserver-users] peculiar exception: Type with same name already exists in cache. (namespace issue?)

It's possible that I'm doing something boneheaded here, and I hope that someone will notice if that's so and tell me, but I've found a peculiar behavior as follows:

Running Geoserver 1.6.4 on our production platform, I'm getting a repeatable and consistent exception as follows:

Requesting any feature set like so:

http://lat.lib.virginia.edu:8080/geoserver/wfs?request=GetFeature&version=1.1.0&typeName=Albemarle:Railroads

returns a

<ows:ExceptionReport version="1.0.0"
   xsi:schemaLocation="http://www.opengis.net/ows http://lat.lib.virginia.edu:8080/geoserver/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.IllegalArgumentException: Type with same name already exists in cache.
Type with same name already exists in cache.</ows:ExceptionText>
   </ows:Exception>
</ows:ExceptionReport>

which is certainly an odd exception. When I check the stack trace at the point at which the request is made, I see:

15 Aug 11:26:43 DEBUG [data.postgis] - get Feature source called on Railroads
15 Aug 11:26:43 DEBUG [data.postgis] - returning pg feature locking
15 Aug 11:26:43 DEBUG [geoserver.requests] - Query is net.opengis.wfs.impl.QueryTypeImpl@anonymised.com (group: null, propertyName: , function: null, filter: null, sortBy: , featureVersion: null, handle: null, srsName: null, typeName: [{http://gisweb.albemarle.org}Railroads])
  To gt2: Query:
    feature type: Railroads
    filter: Filter.INCLUDE
    [properties: ALL ]
15 Aug 11:26:43 DEBUG [data.jdbc] - SQL: SELECT COUNT(*) as cnt FROM "public"."Railroads"
15 Aug 11:26:43 INFO [geoserver.wfs] -
Request: getFeature
  handle = null
  service = WFS
  version = 1.1.0
  baseUrl = http://lat.lib.virginia.edu:8080/geoserver/
  query = [net.opengis.wfs.impl.QueryTypeImpl@anonymised.com (group: null, propertyName: null, function: null, filter: null, sortBy: null, featureVersion: null, handle: null, srsName: null, typeName: [{http://gisweb.albemarle.org}Railroads])]
  maxFeatures = null
  outputFormat = text/xml; subtype=gml/3.1.1
  resultType = results
  traverseXlinkDepth = null
  traverseXlinkExpiry = null

<skipping>

java.lang.IllegalArgumentException: Type with same name already exists in cache.
  at org.geotools.gml2.FeatureTypeCache.put(FeatureTypeCache.java:58)
  at org.geoserver.wfs.xml.v1_1_0.WFSConfiguration.configureContext(WFSConfiguration.java:123)

When I check through that code, I see the following thing:

WFSConfiguration.configureContext

(which I found at
http://svn.codehaus.org/geoserver/tags/1.6.4/geoserver/wfs/src/main/java/org/geoserver/wfs/xml/v1_1_0/WFSConfiguration.java)

is doing this:

FeatureTypeCache featureTypeCache = (FeatureTypeCache) context
             .getComponentInstanceOfType(FeatureTypeCache.class);

         try {
             Collection featureTypes = catalog.getFeatureTypeInfos().values();

             for (Iterator f = featureTypes.iterator(); f.hasNext():wink: {
                 FeatureTypeInfo meta = (FeatureTypeInfo) f.next();
                 FeatureType featureType = meta.getFeatureType();

                 featureTypeCache.put(featureType);
             }
         } catch (IOException e) {
             throw new RuntimeException(e);
         }

and when I look at FeatureTypeInfo. getFeatureType()
(which I found at
http://svn.codehaus.org/geoserver/tags/1.6.4/geoserver/main/src/main/java/org/vfny/geoserver/global/FeatureTypeInfo.java )

I see:

private FeatureType getFeatureType(FeatureSource fs)
         throws IOException {
         if (ft == null) {
             int count = 0;
             ft = fs.getSchema();
             URI namespace = ft.getNamespace(); //DJB:: change to #getNamespace() due to API change

             String baseNames = DataTransferObjectFactory.getRequiredBaseAttributes(schemaBase);
             AttributeType attributes = new AttributeType[schema.size() + baseNames.length];

<skipped>

Notice the comment "//DJB:: change to #getNamespace() due to API change". Is it possible that this chain of calls is dropping the namespaces of feature types and thereby causing conflict? I saw a JIRA bug:

http://jira.codehaus.org/browse/GEOS-1403

for this issue, but it's a bit old and does not seem to have been worked on. It references GS 1.5 as not showing this problem. Perhaps a different version of GeoTools without the #getNamespace() / getNamespace() confusion?

What's truly odd is that other similar GetFeature requests work fine, e.g.

http://lat.lib.virginia.edu:8080/geoserver/wfs?request=GetFeature&version=1.1.0&typeName=Albemarle:Railroads&outputformat=GML2

does exactly what it should do and returns the appropriate GML response. So does:

http://lat.lib.virginia.edu:8080/geoserver/wfs?request=GetFeature&version=1.0.0&typeName=Albemarle:Railroads

(Note the different version number, but no outputFormat= this time.)

But:

http://lat.lib.virginia.edu:8080/geoserver/wfs?request=GetFeature&version=1.1.0&typeName=Albemarle:Railroads&outputformat=GML3
and
http://lat.lib.virginia.edu:8080/geoserver/wfs?request=GetFeature&version=1.0.0&typeName=Albemarle:Railroads&outputformat=GML3

fail the same way (at:

java.lang.IllegalArgumentException: Type with same name already exists in cache.
  at org.geotools.gml2.FeatureTypeCache.put(FeatureTypeCache.java:58)
  at org.geoserver.wfs.xml.v1_1_0.WFSConfiguration.configureContext(WFSConfiguration.java:123)

etc.)

http://lat.lib.virginia.edu:8080/geoserver/wfs?request=GetFeature&version=1.1.0&typeName=Albemarle:Railroads&outputformat=json

works as well, which is less surprising.

I'm planning on attaching btrace code to my instance to find out why these requests work, but if anyone has seen this behavior or sees something obvious I'm doing wrong, please let me know.

Thanks!

---
A. Soroka / Digital Scholarship Services R & D
the University of Virginia Library

Hi,

So i think you stumbled upon a bug... seems that when you have multiple types of the same name (in this case Railroads) in multiple namespaces seeding the cache will bomb out.

The reason being the cache does not take into account namespace. I am opening a jira issue on this:

http://jira.codehaus.org/browse/GEOS-2126

Thanks for the bug report.

-Justin

ajs6f wrote:

It's possible that I'm doing something boneheaded here, and I hope that someone will notice if that's so and tell me, but I've found a peculiar behavior as follows:

Running Geoserver 1.6.4 on our production platform, I'm getting a repeatable and consistent exception as follows:

Requesting any feature set like so:

http://lat.lib.virginia.edu:8080/geoserver/wfs?request=GetFeature&version=1.1.0&typeName=Albemarle:Railroads

returns a

<ows:ExceptionReport version="1.0.0"
   xsi:schemaLocation="http://www.opengis.net/ows http://lat.lib.virginia.edu:8080/geoserver/schemas/ows/1.0.0/owsExceptionReport.xsd "
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance&quot; xmlns:ows="http://www.opengis.net/ows ">
   <ows:Exception exceptionCode="NoApplicableCode">
     <ows:ExceptionText>java.lang.IllegalArgumentException: Type with same name already exists in cache.
Type with same name already exists in cache.</ows:ExceptionText>
   </ows:Exception>
</ows:ExceptionReport>

which is certainly an odd exception. When I check the stack trace at the point at which the request is made, I see:

15 Aug 11:26:43 DEBUG [data.postgis] - get Feature source called on Railroads
15 Aug 11:26:43 DEBUG [data.postgis] - returning pg feature locking
15 Aug 11:26:43 DEBUG [geoserver.requests] - Query is net.opengis.wfs.impl.QueryTypeImpl@anonymised.com (group: null, propertyName: , function: null, filter: null, sortBy: , featureVersion: null, handle: null, srsName: null, typeName: [{http://gisweb.albemarle.org }Railroads])
  To gt2: Query:
    feature type: Railroads
    filter: Filter.INCLUDE
    [properties: ALL ]
15 Aug 11:26:43 DEBUG [data.jdbc] - SQL: SELECT COUNT(*) as cnt FROM "public"."Railroads"
15 Aug 11:26:43 INFO [geoserver.wfs] -
Request: getFeature
  handle = null
  service = WFS
  version = 1.1.0
  baseUrl = http://lat.lib.virginia.edu:8080/geoserver/
  query = [net.opengis.wfs.impl.QueryTypeImpl@anonymised.com (group: null, propertyName: null, function: null, filter: null, sortBy: null, featureVersion: null, handle: null, srsName: null, typeName: [{http://gisweb.albemarle.org }Railroads])]
  maxFeatures = null
  outputFormat = text/xml; subtype=gml/3.1.1
  resultType = results
  traverseXlinkDepth = null
  traverseXlinkExpiry = null

<skipping>

java.lang.IllegalArgumentException: Type with same name already exists in cache.
  at org.geotools.gml2.FeatureTypeCache.put(FeatureTypeCache.java:58)
  at org .geoserver .wfs .xml.v1_1_0.WFSConfiguration.configureContext(WFSConfiguration.java:123)

When I check through that code, I see the following thing:

WFSConfiguration.configureContext

(which I found at
http://svn.codehaus.org/geoserver/tags/1.6.4/geoserver/wfs/src/main/java/org/geoserver/wfs/xml/v1_1_0/WFSConfiguration.java)

is doing this:

FeatureTypeCache featureTypeCache = (FeatureTypeCache) context
             .getComponentInstanceOfType(FeatureTypeCache.class);

         try {
             Collection featureTypes = catalog.getFeatureTypeInfos().values();

             for (Iterator f = featureTypes.iterator(); f.hasNext():wink: {
                 FeatureTypeInfo meta = (FeatureTypeInfo) f.next();
                 FeatureType featureType = meta.getFeatureType();

                 featureTypeCache.put(featureType);
             }
         } catch (IOException e) {
             throw new RuntimeException(e);
         }

and when I look at FeatureTypeInfo. getFeatureType()
(which I found at
http://svn.codehaus.org/geoserver/tags/1.6.4/geoserver/main/src/main/java/org/vfny/geoserver/global/FeatureTypeInfo.java )

I see:

private FeatureType getFeatureType(FeatureSource fs)
         throws IOException {
         if (ft == null) {
             int count = 0;
             ft = fs.getSchema();
             URI namespace = ft.getNamespace(); //DJB:: change to #getNamespace() due to API change

             String baseNames = DataTransferObjectFactory.getRequiredBaseAttributes(schemaBase);
             AttributeType attributes = new AttributeType[schema.size() + baseNames.length];

<skipped>

Notice the comment "//DJB:: change to #getNamespace() due to API change". Is it possible that this chain of calls is dropping the namespaces of feature types and thereby causing conflict? I saw a JIRA bug:

http://jira.codehaus.org/browse/GEOS-1403

for this issue, but it's a bit old and does not seem to have been worked on. It references GS 1.5 as not showing this problem. Perhaps a different version of GeoTools without the #getNamespace() / getNamespace() confusion?

What's truly odd is that other similar GetFeature requests work fine, e.g.

http://lat.lib.virginia.edu:8080/geoserver/wfs?request=GetFeature&version=1.1.0&typeName=Albemarle:Railroads&outputformat=GML2

does exactly what it should do and returns the appropriate GML response. So does:

http://lat.lib.virginia.edu:8080/geoserver/wfs?request=GetFeature&version=1.0.0&typeName=Albemarle:Railroads

(Note the different version number, but no outputFormat= this time.)

But:

http://lat.lib.virginia.edu:8080/geoserver/wfs?request=GetFeature&version=1.1.0&typeName=Albemarle:Railroads&outputformat=GML3
and
http://lat.lib.virginia.edu:8080/geoserver/wfs?request=GetFeature&version=1.0.0&typeName=Albemarle:Railroads&outputformat=GML3

fail the same way (at:

java.lang.IllegalArgumentException: Type with same name already exists in cache.
  at org.geotools.gml2.FeatureTypeCache.put(FeatureTypeCache.java:58)
  at org .geoserver .wfs .xml.v1_1_0.WFSConfiguration.configureContext(WFSConfiguration.java:123)

etc.)

http://lat.lib.virginia.edu:8080/geoserver/wfs?request=GetFeature&version=1.1.0&typeName=Albemarle:Railroads&outputformat=json

works as well, which is less surprising.

I'm planning on attaching btrace code to my instance to find out why these requests work, but if anyone has seen this behavior or sees something obvious I'm doing wrong, please let me know.

Thanks!

---
A. Soroka / Digital Scholarship Services R & D
the University of Virginia Library

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Geoserver-users mailing list
Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

--
Justin Deoliveira
Software Engineer, OpenGeo
http://opengeo.org

Hi,

We are having a bit of trouble reproducing this on GeoServer 1.7.x. Do you think it would be possible for you to try out 1.7.0-RC1 with your data and see if the problem persists. See the bug report for discussions:

http://jira.codehaus.org/browse/GEOS-2126

-Justin

ajs6f wrote:

It's possible that I'm doing something boneheaded here, and I hope that someone will notice if that's so and tell me, but I've found a peculiar behavior as follows:

Running Geoserver 1.6.4 on our production platform, I'm getting a repeatable and consistent exception as follows:

Requesting any feature set like so:

http://lat.lib.virginia.edu:8080/geoserver/wfs?request=GetFeature&version=1.1.0&typeName=Albemarle:Railroads

returns a

<ows:ExceptionReport version="1.0.0"
   xsi:schemaLocation="http://www.opengis.net/ows http://lat.lib.virginia.edu:8080/geoserver/schemas/ows/1.0.0/owsExceptionReport.xsd "
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance&quot; xmlns:ows="http://www.opengis.net/ows ">
   <ows:Exception exceptionCode="NoApplicableCode">
     <ows:ExceptionText>java.lang.IllegalArgumentException: Type with same name already exists in cache.
Type with same name already exists in cache.</ows:ExceptionText>
   </ows:Exception>
</ows:ExceptionReport>

which is certainly an odd exception. When I check the stack trace at the point at which the request is made, I see:

15 Aug 11:26:43 DEBUG [data.postgis] - get Feature source called on Railroads
15 Aug 11:26:43 DEBUG [data.postgis] - returning pg feature locking
15 Aug 11:26:43 DEBUG [geoserver.requests] - Query is net.opengis.wfs.impl.QueryTypeImpl@anonymised.com (group: null, propertyName: , function: null, filter: null, sortBy: , featureVersion: null, handle: null, srsName: null, typeName: [{http://gisweb.albemarle.org }Railroads])
  To gt2: Query:
    feature type: Railroads
    filter: Filter.INCLUDE
    [properties: ALL ]
15 Aug 11:26:43 DEBUG [data.jdbc] - SQL: SELECT COUNT(*) as cnt FROM "public"."Railroads"
15 Aug 11:26:43 INFO [geoserver.wfs] -
Request: getFeature
  handle = null
  service = WFS
  version = 1.1.0
  baseUrl = http://lat.lib.virginia.edu:8080/geoserver/
  query = [net.opengis.wfs.impl.QueryTypeImpl@anonymised.com (group: null, propertyName: null, function: null, filter: null, sortBy: null, featureVersion: null, handle: null, srsName: null, typeName: [{http://gisweb.albemarle.org }Railroads])]
  maxFeatures = null
  outputFormat = text/xml; subtype=gml/3.1.1
  resultType = results
  traverseXlinkDepth = null
  traverseXlinkExpiry = null

<skipping>

java.lang.IllegalArgumentException: Type with same name already exists in cache.
  at org.geotools.gml2.FeatureTypeCache.put(FeatureTypeCache.java:58)
  at org .geoserver .wfs .xml.v1_1_0.WFSConfiguration.configureContext(WFSConfiguration.java:123)

When I check through that code, I see the following thing:

WFSConfiguration.configureContext

(which I found at
http://svn.codehaus.org/geoserver/tags/1.6.4/geoserver/wfs/src/main/java/org/geoserver/wfs/xml/v1_1_0/WFSConfiguration.java)

is doing this:

FeatureTypeCache featureTypeCache = (FeatureTypeCache) context
             .getComponentInstanceOfType(FeatureTypeCache.class);

         try {
             Collection featureTypes = catalog.getFeatureTypeInfos().values();

             for (Iterator f = featureTypes.iterator(); f.hasNext():wink: {
                 FeatureTypeInfo meta = (FeatureTypeInfo) f.next();
                 FeatureType featureType = meta.getFeatureType();

                 featureTypeCache.put(featureType);
             }
         } catch (IOException e) {
             throw new RuntimeException(e);
         }

and when I look at FeatureTypeInfo. getFeatureType()
(which I found at
http://svn.codehaus.org/geoserver/tags/1.6.4/geoserver/main/src/main/java/org/vfny/geoserver/global/FeatureTypeInfo.java )

I see:

private FeatureType getFeatureType(FeatureSource fs)
         throws IOException {
         if (ft == null) {
             int count = 0;
             ft = fs.getSchema();
             URI namespace = ft.getNamespace(); //DJB:: change to #getNamespace() due to API change

             String baseNames = DataTransferObjectFactory.getRequiredBaseAttributes(schemaBase);
             AttributeType attributes = new AttributeType[schema.size() + baseNames.length];

<skipped>

Notice the comment "//DJB:: change to #getNamespace() due to API change". Is it possible that this chain of calls is dropping the namespaces of feature types and thereby causing conflict? I saw a JIRA bug:

http://jira.codehaus.org/browse/GEOS-1403

for this issue, but it's a bit old and does not seem to have been worked on. It references GS 1.5 as not showing this problem. Perhaps a different version of GeoTools without the #getNamespace() / getNamespace() confusion?

What's truly odd is that other similar GetFeature requests work fine, e.g.

http://lat.lib.virginia.edu:8080/geoserver/wfs?request=GetFeature&version=1.1.0&typeName=Albemarle:Railroads&outputformat=GML2

does exactly what it should do and returns the appropriate GML response. So does:

http://lat.lib.virginia.edu:8080/geoserver/wfs?request=GetFeature&version=1.0.0&typeName=Albemarle:Railroads

(Note the different version number, but no outputFormat= this time.)

But:

http://lat.lib.virginia.edu:8080/geoserver/wfs?request=GetFeature&version=1.1.0&typeName=Albemarle:Railroads&outputformat=GML3
and
http://lat.lib.virginia.edu:8080/geoserver/wfs?request=GetFeature&version=1.0.0&typeName=Albemarle:Railroads&outputformat=GML3

fail the same way (at:

java.lang.IllegalArgumentException: Type with same name already exists in cache.
  at org.geotools.gml2.FeatureTypeCache.put(FeatureTypeCache.java:58)
  at org .geoserver .wfs .xml.v1_1_0.WFSConfiguration.configureContext(WFSConfiguration.java:123)

etc.)

http://lat.lib.virginia.edu:8080/geoserver/wfs?request=GetFeature&version=1.1.0&typeName=Albemarle:Railroads&outputformat=json

works as well, which is less surprising.

I'm planning on attaching btrace code to my instance to find out why these requests work, but if anyone has seen this behavior or sees something obvious I'm doing wrong, please let me know.

Thanks!

---
A. Soroka / Digital Scholarship Services R & D
the University of Virginia Library

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Geoserver-users mailing list
Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

--
Justin Deoliveira
Software Engineer, OpenGeo
http://opengeo.org