It works, Thank you Jody!

Now, I come to another problem : Date parsing fails when I add a feature to 
Geoserver.

here is my code :

String startDateString = "28/04/2009";
String endDateString = "29/04/2009";
DateFormat formatter = new SimpleDateFormat("dd/MM/yyyy");
java.util.Date startDate = null;
java.util.Date endDate = null;

try
{
 startDate = (Date)formatter.parse(startDateString);
 endDate = (Date)formatter.parse(endDateString);
}
catch (ParseException e)
{
 e.printStackTrace();
}

FeatureStore<SimpleFeatureType,SimpleFeature> fs = getFeatureStore("roads");
GeometryFactory geomFactory = new GeometryFactory();
Point point = geomFactory.createPoint( new Coordinate(0, 0));
FeatureCollection<SimpleFeatureType, SimpleFeature> collection = 
FeatureCollections.newCollection("internal");
final SimpleFeature feature = SimpleFeatureBuilder.build( fs.getSchema(), new 
Object[] {new java.sql.Timestamp(startDate.getTime()), new 
java.sql.Timestamp(endDate.getTime()), "bla bla", point}, null );
collection.add(feature);
fs.addFeatures(collection);


and here is the stack trace :

17 avr. 2009 11:02:22 org.geotools.xml.XMLSAXHandler processException
GRAVE: java.lang.RuntimeException: Parsing failed for date_debut: 
java.lang.IllegalArgumentException: Failed to parse dateTime 2009-04-28 
00:00:00.0 at: 00:00:00.0
Parsing failed for date_debut: java.lang.IllegalArgumentException: Failed to 
parse dateTime 2009-04-28 00:00:00.0 at: 00:00:00.0
Failed to parse dateTime 2009-04-28 00:00:00.0 at: 00:00:00.0    
org.geotools.xml.filter.FilterComplexTypes$ServiceExceptionType.getValue(FilterComplexTypes.java:1669)
    
org.geotools.xml.handlers.ComplexElementHandler.endElement(ComplexElementHandler.java:157)
    org.geotools.xml.XMLSAXHandler.endElement(XMLSAXHandler.java:266)
    org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)
    org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement(Unknown 
Source)
    
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown
 Source)
    org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown 
Source)
    org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
    org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
    org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
    org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
    org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
    javax.xml.parsers.SAXParser.parse(SAXParser.java:395)
    javax.xml.parsers.SAXParser.parse(SAXParser.java:198)
    org.geotools.xml.DocumentFactory.getInstance(DocumentFactory.java:140)
    
org.geotools.data.wfs.v1_0_0.WFSTransactionState.commitPost(WFSTransactionState.java:298)
    
org.geotools.data.wfs.v1_0_0.WFSTransactionState.commit(WFSTransactionState.java:152)
    
org.geotools.data.wfs.v1_0_0.WFSFeatureStore.addFeatures(WFSFeatureStore.java:178)
    mypackage.CommandHandler.handleCommand(CommandHandler.java:230)
    mypackage.CommandHandler.doPost(CommandHandler.java:87)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
    
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
    
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
    
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
    
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:172)
    
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
    
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
    org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)
    org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:875)
    
org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
    
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
    
org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
    
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
    java.lang.Thread.run(Thread.java:619)

17 avr. 2009 11:02:22 org.geotools.xml.XMLSAXHandler endElement
ATTENTION: java.lang.RuntimeException: Parsing failed for date_debut: 
java.lang.IllegalArgumentException: Failed to parse dateTime 2009-04-28 
00:00:00.0 at: 00:00:00.0
Parsing failed for date_debut: java.lang.IllegalArgumentException: Failed to 
parse dateTime 2009-04-28 00:00:00.0 at: 00:00:00.0
Failed to parse dateTime 2009-04-28 00:00:00.0 at: 00:00:00.0
17 avr. 2009 11:02:22 org.geotools.xml.XMLSAXHandler endElement
ATTENTION: Line 11 Col 20
17 avr. 2009 11:02:22 org.geotools.data.wfs.v1_0_0.WFSTransactionState commit
ATTENTION: org.geotools.ows.ServiceException: java.lang.RuntimeException: 
Parsing failed for date_debut: java.lang.IllegalArgumentException: Failed to 
parse dateTime 2009-04-28 00:00:00.0 at: 00:00:00.0
Parsing failed for date_debut: java.lang.IllegalArgumentException: Failed to 
parse dateTime 2009-04-28 00:00:00.0 at: 00:00:00.0
Failed to parse dateTime 2009-04-28 00:00:00.0 at: 00:00:00.0


> Date: Fri, 17 Apr 2009 12:47:03 +1000
> Subject: Re: [Geotools-gt2-users] (no subject)
> From: [email protected]
> To: [email protected]
> CC: [email protected]
> 
> Because you connected using WFS-1.1; and GeoTools does not support
> WFS-T using 1.1.
> 
> If you add VERSION=1.0 to your capabilities URL you should be good to go.
> 
> Jody
> 
> On Thu, Apr 16, 2009 at 11:01 PM, yako yako <[email protected]> wrote:
> > Hi,
> >
> > I don't understand why my FeaturesSources linked to a WFS-T Server
> > (Geoserver) are not FeatureStores.
> >
> > Here is my code
> >
> >   Map<String, Object> connectionParameters = new HashMap<String, Object>();
> >   connectionParameters.put("WFSDataStoreFactory:GET_CAPABILITIES_URL",
> > "http://localhost:8090/geoserver/wfs?REQUEST=GetCapabilities";);
> >   DataStore ds = DataStoreFinder.getDataStore(connectionParameters);
> >   FeatureSource fs = ds.getFeatureSource("mynamespace:roads");
> >   if(fs == null)
> >   {
> >      System.out.println("is null");
> >   }
> >   else if(fs instanceof FeatureStore)
> >   {
> >      System.out.println("is instance of FeatureStore");
> >   }
> >   else
> >   {
> >      System.out.println("is not instance of FeatureStore");
> >   }
> >
> > It displays "is not instance of FeatureStore".
> >
> > Can somebody helps me?
> >
> > Thank you,
> >
> > Yako Bak
> >
> > Geotools-gt2-users mailing list
> > [email protected]
> > https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
> >


_________________________________________________________________
Vous voulez savoir ce que vous pouvez faire avec le nouveau Windows Live ? 
Lancez-vous !
http://www.microsoft.com/windows/windowslive/default.aspx
------------------------------------------------------------------------------
Stay on top of everything new and different, both inside and 
around Java (TM) technology - register by April 22, and save
$200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco.
300 plus technical and hands-on sessions. Register today. 
Use priority code J9JMT32. http://p.sf.net/sfu/p
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to