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:
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" 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() {
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.
does exactly what it should do and returns the appropriate GML response. So does:
(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.)
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