Details
Description
An error came up changing from geoserver 1.7.4 with the Old Oracle Datastore to the latest 1.7.6 with the Oracle NG Datastore.
The WFS that before was working fine, now is failing. It queries an Oracle table with some rows that don't have geometry:
--------------------------------------------------------
select count(1) from activitats;
COUNT(1)
----------------------
1691
1 rows selected
select count(1) from activitats where GEOM is null;
COUNT(1)
----------------------
17
1 rows selected
--------------------------------------------------------
I want to obtain the rows that don't have geometry, the WFS filter used is:
<ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">
<ogc:PropertyIsNull>
<ogc:PropertyName>GEOM</ogc:PropertyName>
</ogc:PropertyIsNull>
</ogc:Filter>
And at the attachment file you can see the logs produced at geoserver.
The solution is to edit the java Class: org.geotools.data.oracle.OracleDialect replacing the following method:
--------------------------------------------------------
public Geometry decodeGeometryValue(GeometryDescriptor descriptor,
ResultSet rs, String column, GeometryFactory factory, Connection cx )
throws IOException, SQLException {
//read the geometry
Geometry geom = readGeometry( rs, column, factory, cx );
//grab the binding
Class targetClazz = descriptor.getType().getBinding();
// in Oracle you can have polygons in a column declared to be multipolygon, and so on...
// so we better convert geometries, since our feature model is not so lenient
if(targetClazz.equals(MultiPolygon.class) && geom instanceof Polygon){
if (geom == null) return factory.createMultiPolygon(null);// added avalls to suppport null/empty geometries
else return factory.createMultiPolygon(new Polygon[] {(Polygon) geom});
}
else if(targetClazz.equals(MultiPoint.class) && geom instanceof Point) {
if (geom == null) return factory.createGeometryCollection(null);// added avalls to suppport null/empty geometries
else return factory.createMultiPoint(new Point[] {(Point) geom});
}
else if(targetClazz.equals(MultiLineString.class) && geom instanceof LineString) {
if (geom == null) return factory.createMultiLineString(null);// added avalls to suppport null/empty geometries
else return factory.createMultiLineString(new LineString[] {(LineString) geom});
}
else if(targetClazz.equals(GeometryCollection.class)) {
if (geom == null) return factory.createGeometryCollection(null);// added avalls to suppport null/empty geometries
else return factory.createGeometryCollection(new Geometry[] {geom});
}
return geom;
}
--------------------------------------------------------
If you need further information don't hesitate to ask.
albert
That seems odd... it would be better to fix the code upstream that's not handling the null geometries properly. Do you have a full copy of the original stack trace?