[Geoserver-users] [REST]

Hi all,

We are trying to understand how to use the REST API to add layers. Could you give us an example of the url we should enter to add a datastore with one of the sample files (let’s say states.shp) ?

All our tries have returned us a 405 error.

Thank you !

---------------------------------------------------------------------
Gilles Tasse
2, rue Antoine Becquerel
35700 RENNES
mailto:gilles.tasse@anonymised.com
Tél : 02.23.21.11.11 - Fax : 02.23.21.11.00

Hi,

There are some docs available here:

http://docs.geoserver.org/1.7.x/user/extensions/rest/index.html

In particular some examples that use curl here:

http://docs.geoserver.org/1.7.x/user/extensions/rest/rest-config-examples-curl.html

And finally there are some scripts which build up the regular geoserver release directory from scratch, including the states layer. YOu can find those here:

http://svn.codehaus.org/geoserver/branches/1.7.x/src/extension/restconfig/scripts/

Hope that helps.

-Justin

TASSE Gilles wrote:

Hi all,

We are trying to understand how to use the REST API to add layers. Could you give us an example of the url we should enter to add a datastore with one of the sample files (let's say states.shp) ?

All our tries have returned us a 405 error.

Thank you !

*---------------------------------------------------------------------*
*Gilles Tasse*
/2, rue Antoine Becquerel/
/35700 RENNES/
/mailto:gilles.tasse@anonymised.com <mailto:nelly.hascoet@anonymised.com>/
/Tél : 02.23.21.11.11 - Fax : 02.23.21.11.00/

------------------------------------------------------------------------

------------------------------------------------------------------------------

------------------------------------------------------------------------

_______________________________________________
Geoserver-users mailing list
Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

--
Justin Deoliveira
OpenGeo - http://opengeo.org
Enterprise support for open source geospatial.

Hello,

I'm still having problems with adding layers to Geoserver using REST API.
I'm triying to explain my problem.

First, I created the workspace with :

curl -u user:pwd -v -XPOST -H "Content-type: text/xml" -d "<workspace><name>test</name></workspace>" http://localhost:8081/geoserver/rest/workspaces

It looked to be OK !

Then, I tried to put the zip file (pamper.zip, containing all shp, prj and other required files) with the following command

curl -u admin:geoserver -XPUT -H 'Content-type: application/zip' --data-binary @c:/pampers.zip http://localhost:8081/geoserver/rest/workspaces/test/datastores/pampers/file.shp

But I got :

java.io.IOException: Wrong magic number, expected 9994, got 1347093252

It seems to be as if Geoserver has treated my zip file as a shape file, because a "pampers" directory was created in my " geoserver\data\data\" directory, but there is only one file in there : pampers.shp that has the same size of the original zip file.

What's wrong in my code ?

thanks in advance

-----Message d'origine-----
De : Justin Deoliveira [mailto:jdeolive@anonymised.com]
Envoyé : mercredi 1 juillet 2009 07:10
À : TASSE Gilles
Cc : geoserver-users@lists.sourceforge.net
Objet : Re: [Geoserver-users] [REST]

Hi,

There are some docs available here:

http://docs.geoserver.org/1.7.x/user/extensions/rest/index.html

In particular some examples that use curl here:

http://docs.geoserver.org/1.7.x/user/extensions/rest/rest-config-examples-curl.html

And finally there are some scripts which build up the regular geoserver
release directory from scratch, including the states layer. YOu can find
those here:

http://svn.codehaus.org/geoserver/branches/1.7.x/src/extension/restconfig/scripts/

Hope that helps.

-Justin

TASSE Gilles wrote:

Hi all,

We are trying to understand how to use the REST API to add layers. Could
you give us an example of the url we should enter to add a datastore
with one of the sample files (let's say states.shp) ?

All our tries have returned us a 405 error.

Thank you !

*---------------------------------------------------------------------*
*Gilles Tasse*
/2, rue Antoine Becquerel/
/35700 RENNES/
/mailto:gilles.tasse@anonymised.com <mailto:nelly.hascoet@anonymised.com>/
/Tél : 02.23.21.11.11 - Fax : 02.23.21.11.00/

------------------------------------------------------------------------

------------------------------------------------------------------------------

------------------------------------------------------------------------

_______________________________________________
Geoserver-users mailing list
Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

--
Justin Deoliveira
OpenGeo - http://opengeo.org
Enterprise support for open source geospatial.

Hi,

TASSE Gilles wrote:

Hello,

I'm still having problems with adding layers to Geoserver using REST API.
I'm triying to explain my problem.

First, I created the workspace with :

curl -u user:pwd -v -XPOST -H "Content-type: text/xml" -d "<workspace><name>test</name></workspace>" http://localhost:8081/geoserver/rest/workspaces

It looked to be OK !

Then, I tried to put the zip file (pamper.zip, containing all shp, prj and other required files) with the following command

curl -u admin:geoserver -XPUT -H 'Content-type: application/zip' --data-binary @c:/pampers.zip http://localhost:8081/geoserver/rest/workspaces/test/datastores/pampers/file.shp

But I got :

java.io.IOException: Wrong magic number, expected 9994, got 1347093252

Hmmm... do you have the entire stack trace? It would be helpful to know exactly where this is occuring. You may have to turn logging up, go to the web ui and turn up logging to GEOSERVER_DEVELOPER_LOGGING.

But yeah, seems something is getting mixed up trying to read a shapefile that is not actually a shapefile.

So you say that your data directory structure looks like:

<root>/data/pampers/pampers.shp?

Curious, what does the structure of the zip file look like? Are all the files at the root of the archive?

-Justin

It seems to be as if Geoserver has treated my zip file as a shape file, because a "pampers" directory was created in my " geoserver\data\data\" directory, but there is only one file in there : pampers.shp that has the same size of the original zip file.

What's wrong in my code ?

thanks in advance

-----Message d'origine-----
De : Justin Deoliveira [mailto:jdeolive@anonymised.com] Envoyé : mercredi 1 juillet 2009 07:10
À : TASSE Gilles
Cc : geoserver-users@lists.sourceforge.net
Objet : Re: [Geoserver-users] [REST]

Hi,

There are some docs available here:

http://docs.geoserver.org/1.7.x/user/extensions/rest/index.html

In particular some examples that use curl here:

http://docs.geoserver.org/1.7.x/user/extensions/rest/rest-config-examples-curl.html

And finally there are some scripts which build up the regular geoserver release directory from scratch, including the states layer. YOu can find those here:

http://svn.codehaus.org/geoserver/branches/1.7.x/src/extension/restconfig/scripts/

Hope that helps.

-Justin

TASSE Gilles wrote:

Hi all,

We are trying to understand how to use the REST API to add layers. Could you give us an example of the url we should enter to add a datastore with one of the sample files (let's say states.shp) ?

All our tries have returned us a 405 error.

Thank you !

*---------------------------------------------------------------------*
*Gilles Tasse*
/2, rue Antoine Becquerel/
/35700 RENNES/
/mailto:gilles.tasse@anonymised.com <mailto:nelly.hascoet@anonymised.com>/
/Tél : 02.23.21.11.11 - Fax : 02.23.21.11.00/

------------------------------------------------------------------------

------------------------------------------------------------------------------

------------------------------------------------------------------------

_______________________________________________
Geoserver-users mailing list
Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

--
Justin Deoliveira
OpenGeo - http://opengeo.org
Enterprise support for open source geospatial.

Hello Justin !

First, thanks a lot for your answer.
In there, you asked me for the entire stack trace.

So after this command :

E:\MyFolder\Outils\Curl\curl_7.18.2>curl -u admin:geoserver -XPUT -H 'Content-type: application/zip' --data-binary @c:/pampers.zip http://localhost:8081/geoserver/rest/workspaces/julien/datastores/pampers/file.shp

I got this stack trace :

02 juil. 09:30:13 INFO [catalog.rest] - PUT file, mimetype: application/x-www-form-urlencoded
02 juil. 09:30:13 INFO [catalog.rest] - Using existing datastore: pampers
02 juil. 09:30:13 WARN [shapefile.sh] - Could not open the .shx file, continuing assuming the .shp file is not sparse
java.io.FileNotFoundException: C:\Serveurs\apache-tomcat-6.0.18\webapps\geoserver\data\data\pampers\pampers.shx
        at org.geotools.data.shapefile.ShpFiles.getReadChannel(ShpFiles.java:821)
        at org.geotools.data.shapefile.shp.IndexFile.<init>(IndexFile.java:78)
        at org.geotools.data.shapefile.shp.ShapefileReader.<init>(ShapefileReader.java:162)
        at org.geotools.data.shapefile.ShapefileDataStore.openShapeReader(ShapefileDataStore.java:425)
        at org.geotools.data.shapefile.ShapefileDataStore.readAttributes(ShapefileDataStore.java:652)
        at org.geotools.data.shapefile.ShapefileDataStore.getSchema(ShapefileDataStore.java:610)
        at org.geotools.data.shapefile.ShapefileDataStore.getSchema(ShapefileDataStore.java:604)
        at org.geotools.data.shapefile.ShapefileDataStore.getFeatureSource(ShapefileDataStore.java:959)
        at org.geoserver.catalog.rest.DataStoreFileResource.handlePut(DataStoreFileResource.java:263)
        at org.restlet.Finder.handle(Finder.java:298)
        at org.geoserver.rest.BeanDelegatingRestlet.handle(BeanDelegatingRestlet.java:38)
        at org.restlet.Filter.doHandle(Filter.java:105)
        at org.restlet.Filter.handle(Filter.java:134)
        at org.restlet.Router.handle(Router.java:444)
        at com.noelios.restlet.ext.servlet.ServletConverter.service(ServletConverter.java:129)
        at org.geoserver.rest.RESTDispatcher.handleRequestInternal(RESTDispatcher.java:79)
        at org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:153)
        at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
        at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:875)
        at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:809)
        at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:571)
        at org.springframework.web.servlet.FrameworkServlet.doPut(FrameworkServlet.java:521)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:640)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.vfny.geoserver.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:108)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:265)
        at org.acegisecurity.intercept.web.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:107)
        at org.acegisecurity.intercept.web.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:72)
        at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
        at org.acegisecurity.ui.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:124)
        at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
        at org.acegisecurity.providers.anonymous.AnonymousProcessingFilter.doFilter(AnonymousProcessingFilter.java:125)
        at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
        at org.acegisecurity.ui.basicauth.BasicProcessingFilter.doFilter(BasicProcessingFilter.java:174)
        at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
        at org.acegisecurity.context.HttpSessionContextIntegrationFilter.doFilter(HttpSessionContextIntegrationFilter.java:249)
        at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
        at org.acegisecurity.util.FilterChainProxy.doFilter(FilterChainProxy.java:149)
        at org.acegisecurity.util.FilterToBeanProxy.doFilter(FilterToBeanProxy.java:98)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.geoserver.filters.LoggingFilter.doFilter(LoggingFilter.java:73)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.geoserver.filters.ReverseProxyFilter.doFilter(ReverseProxyFilter.java:163)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.geoserver.filters.GZIPFilter.doFilter(GZIPFilter.java:47)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
        at java.lang.Thread.run(Unknown Source)
02 juil. 09:30:13 ERROR [geoserver.rest] -
java.lang.RuntimeException: java.io.IOException: Wrong magic number, expected 9994, got 1347093252
        at org.geoserver.catalog.rest.DataStoreFileResource.handlePut(DataStoreFileResource.java:295)
        at org.restlet.Finder.handle(Finder.java:298)
        at org.geoserver.rest.BeanDelegatingRestlet.handle(BeanDelegatingRestlet.java:38)
        at org.restlet.Filter.doHandle(Filter.java:105)
        at org.restlet.Filter.handle(Filter.java:134)
        at org.restlet.Router.handle(Router.java:444)
        at com.noelios.restlet.ext.servlet.ServletConverter.service(ServletConverter.java:129)
        at org.geoserver.rest.RESTDispatcher.handleRequestInternal(RESTDispatcher.java:79)
        at org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:153)
        at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
        at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:875)
        at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:809)
        at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:571)
        at org.springframework.web.servlet.FrameworkServlet.doPut(FrameworkServlet.java:521)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:640)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.vfny.geoserver.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:108)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:265)
        at org.acegisecurity.intercept.web.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:107)
        at org.acegisecurity.intercept.web.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:72)
        at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
        at org.acegisecurity.ui.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:124)
        at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
        at org.acegisecurity.providers.anonymous.AnonymousProcessingFilter.doFilter(AnonymousProcessingFilter.java:125)
        at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
        at org.acegisecurity.ui.basicauth.BasicProcessingFilter.doFilter(BasicProcessingFilter.java:174)
        at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
        at org.acegisecurity.context.HttpSessionContextIntegrationFilter.doFilter(HttpSessionContextIntegrationFilter.java:249)
        at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
        at org.acegisecurity.util.FilterChainProxy.doFilter(FilterChainProxy.java:149)
        at org.acegisecurity.util.FilterToBeanProxy.doFilter(FilterToBeanProxy.java:98)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.geoserver.filters.LoggingFilter.doFilter(LoggingFilter.java:73)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.geoserver.filters.ReverseProxyFilter.doFilter(ReverseProxyFilter.java:163)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.geoserver.filters.GZIPFilter.doFilter(GZIPFilter.java:47)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
        at java.lang.Thread.run(Unknown Source)
Caused by: java.io.IOException: Wrong magic number, expected 9994, got 1347093252
        at org.geotools.data.shapefile.shp.ShapefileHeader.checkMagic(ShapefileHeader.java:53)
        at org.geotools.data.shapefile.shp.ShapefileHeader.read(ShapefileHeader.java:75)
        at org.geotools.data.shapefile.shp.ShapefileReader.readHeader(ShapefileReader.java:206)
        at org.geotools.data.shapefile.shp.ShapefileReader.init(ShapefileReader.java:255)
        at org.geotools.data.shapefile.shp.ShapefileReader.<init>(ShapefileReader.java:168)
        at org.geotools.data.shapefile.ShapefileDataStore.openShapeReader(ShapefileDataStore.java:425)
        at org.geotools.data.shapefile.ShapefileDataStore.readAttributes(ShapefileDataStore.java:652)
        at org.geotools.data.shapefile.ShapefileDataStore.getSchema(ShapefileDataStore.java:610)
        at org.geotools.data.shapefile.ShapefileDataStore.getSchema(ShapefileDataStore.java:604)
        at org.geotools.data.shapefile.ShapefileDataStore.getFeatureSource(ShapefileDataStore.java:959)
        at org.geoserver.catalog.rest.DataStoreFileResource.handlePut(DataStoreFileResource.java:263)
        ... 55 more

It seems GeoServer treat my zip file as a shape file, and does not unzip it.

My data directory structure looks like:
<root>/data/pampers/pampers.shp
but pampers.shp is actually a zip archive

All the files are at the root of the archive. The zip file look like :
- pampers.dbf
- pampers.fix
- pampers.prj
- pampers.qix
- pampers.shp
- pampers.shx

What's wrong in my code ?
Justin, have you got an example that works ???

Thanks in advance

Eric and Gilles

-----Message d'origine-----
De : Justin Deoliveira [mailto:jdeolive@anonymised.com]
Envoyé : jeudi 2 juillet 2009 07:40
À : TASSE Gilles
Cc : geoserver-users@lists.sourceforge.net
Objet : Re: [Geoserver-users] [REST]

Hi,

TASSE Gilles wrote:

Hello,

I'm still having problems with adding layers to Geoserver using REST API.
I'm triying to explain my problem.

First, I created the workspace with :

curl -u user:pwd -v -XPOST -H "Content-type: text/xml" -d "<workspace><name>test</name></workspace>" http://localhost:8081/geoserver/rest/workspaces

It looked to be OK !

Then, I tried to put the zip file (pamper.zip, containing all shp, prj and other required files) with the following command

curl -u admin:geoserver -XPUT -H 'Content-type: application/zip' --data-binary @c:/pampers.zip http://localhost:8081/geoserver/rest/workspaces/test/datastores/pampers/file.shp

But I got :

java.io.IOException: Wrong magic number, expected 9994, got 1347093252

Hmmm... do you have the entire stack trace? It would be helpful to know
exactly where this is occuring. You may have to turn logging up, go to
the web ui and turn up logging to GEOSERVER_DEVELOPER_LOGGING.

But yeah, seems something is getting mixed up trying to read a shapefile
that is not actually a shapefile.

So you say that your data directory structure looks like:

<root>/data/pampers/pampers.shp?

Curious, what does the structure of the zip file look like? Are all the
files at the root of the archive?

-Justin

It seems to be as if Geoserver has treated my zip file as a shape file, because a "pampers" directory was created in my " geoserver\data\data\" directory, but there is only one file in there : pampers.shp that has the same size of the original zip file.

What's wrong in my code ?

thanks in advance

-----Message d'origine-----
De : Justin Deoliveira [mailto:jdeolive@anonymised.com]
Envoyé : mercredi 1 juillet 2009 07:10
À : TASSE Gilles
Cc : geoserver-users@lists.sourceforge.net
Objet : Re: [Geoserver-users] [REST]

Hi,

There are some docs available here:

http://docs.geoserver.org/1.7.x/user/extensions/rest/index.html

In particular some examples that use curl here:

http://docs.geoserver.org/1.7.x/user/extensions/rest/rest-config-examples-curl.html

And finally there are some scripts which build up the regular geoserver
release directory from scratch, including the states layer. YOu can find
those here:

http://svn.codehaus.org/geoserver/branches/1.7.x/src/extension/restconfig/scripts/

Hope that helps.

-Justin

TASSE Gilles wrote:

Hi all,

We are trying to understand how to use the REST API to add layers. Could
you give us an example of the url we should enter to add a datastore
with one of the sample files (let's say states.shp) ?

All our tries have returned us a 405 error.

Thank you !

*---------------------------------------------------------------------*
*Gilles Tasse*
/2, rue Antoine Becquerel/
/35700 RENNES/
/mailto:gilles.tasse@anonymised.com <mailto:nelly.hascoet@anonymised.com>/
/Tél : 02.23.21.11.11 - Fax : 02.23.21.11.00/

------------------------------------------------------------------------

------------------------------------------------------------------------------

------------------------------------------------------------------------

_______________________________________________
Geoserver-users mailing list
Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

--
Justin Deoliveira
OpenGeo - http://opengeo.org
Enterprise support for open source geospatial.

------------------------------------------------------------------------------
_______________________________________________
Geoserver-users mailing list
Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

Thanks for the additional information. However it is not evident to me what exactly is wrong. The warnings from the log definitely point to something wrong with the shapefile. Is there any chance you can provide it to me (via private mail if you wish) or post it somewhere i can get at it. That way I can see here exactly what is going wrong.

-Justin

BOUSQUET Eric wrote:

Hello Justin !

First, thanks a lot for your answer.
In there, you asked me for the entire stack trace.

So after this command :

E:\MyFolder\Outils\Curl\curl_7.18.2>curl -u admin:geoserver -XPUT -H 'Content-type: application/zip' --data-binary @c:/pampers.zip http://localhost:8081/geoserver/rest/workspaces/julien/datastores/pampers/file.shp

I got this stack trace :

02 juil. 09:30:13 INFO [catalog.rest] - PUT file, mimetype: application/x-www-form-urlencoded
02 juil. 09:30:13 INFO [catalog.rest] - Using existing datastore: pampers
02 juil. 09:30:13 WARN [shapefile.sh] - Could not open the .shx file, continuing assuming the .shp file is not sparse
java.io.FileNotFoundException: C:\Serveurs\apache-tomcat-6.0.18\webapps\geoserver\data\data\pampers\pampers.shx
        at org.geotools.data.shapefile.ShpFiles.getReadChannel(ShpFiles.java:821)
        at org.geotools.data.shapefile.shp.IndexFile.<init>(IndexFile.java:78)
        at org.geotools.data.shapefile.shp.ShapefileReader.<init>(ShapefileReader.java:162)
        at org.geotools.data.shapefile.ShapefileDataStore.openShapeReader(ShapefileDataStore.java:425)
        at org.geotools.data.shapefile.ShapefileDataStore.readAttributes(ShapefileDataStore.java:652)
        at org.geotools.data.shapefile.ShapefileDataStore.getSchema(ShapefileDataStore.java:610)
        at org.geotools.data.shapefile.ShapefileDataStore.getSchema(ShapefileDataStore.java:604)
        at org.geotools.data.shapefile.ShapefileDataStore.getFeatureSource(ShapefileDataStore.java:959)
        at org.geoserver.catalog.rest.DataStoreFileResource.handlePut(DataStoreFileResource.java:263)
        at org.restlet.Finder.handle(Finder.java:298)
        at org.geoserver.rest.BeanDelegatingRestlet.handle(BeanDelegatingRestlet.java:38)
        at org.restlet.Filter.doHandle(Filter.java:105)
        at org.restlet.Filter.handle(Filter.java:134)
        at org.restlet.Router.handle(Router.java:444)
        at com.noelios.restlet.ext.servlet.ServletConverter.service(ServletConverter.java:129)
        at org.geoserver.rest.RESTDispatcher.handleRequestInternal(RESTDispatcher.java:79)
        at org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:153)
        at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
        at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:875)
        at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:809)
        at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:571)
        at org.springframework.web.servlet.FrameworkServlet.doPut(FrameworkServlet.java:521)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:640)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.vfny.geoserver.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:108)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:265)
        at org.acegisecurity.intercept.web.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:107)
        at org.acegisecurity.intercept.web.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:72)
        at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
        at org.acegisecurity.ui.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:124)
        at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
        at org.acegisecurity.providers.anonymous.AnonymousProcessingFilter.doFilter(AnonymousProcessingFilter.java:125)
        at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
        at org.acegisecurity.ui.basicauth.BasicProcessingFilter.doFilter(BasicProcessingFilter.java:174)
        at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
        at org.acegisecurity.context.HttpSessionContextIntegrationFilter.doFilter(HttpSessionContextIntegrationFilter.java:249)
        at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
        at org.acegisecurity.util.FilterChainProxy.doFilter(FilterChainProxy.java:149)
        at org.acegisecurity.util.FilterToBeanProxy.doFilter(FilterToBeanProxy.java:98)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.geoserver.filters.LoggingFilter.doFilter(LoggingFilter.java:73)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.geoserver.filters.ReverseProxyFilter.doFilter(ReverseProxyFilter.java:163)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.geoserver.filters.GZIPFilter.doFilter(GZIPFilter.java:47)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
        at java.lang.Thread.run(Unknown Source)
02 juil. 09:30:13 ERROR [geoserver.rest] -
java.lang.RuntimeException: java.io.IOException: Wrong magic number, expected 9994, got 1347093252
        at org.geoserver.catalog.rest.DataStoreFileResource.handlePut(DataStoreFileResource.java:295)
        at org.restlet.Finder.handle(Finder.java:298)
        at org.geoserver.rest.BeanDelegatingRestlet.handle(BeanDelegatingRestlet.java:38)
        at org.restlet.Filter.doHandle(Filter.java:105)
        at org.restlet.Filter.handle(Filter.java:134)
        at org.restlet.Router.handle(Router.java:444)
        at com.noelios.restlet.ext.servlet.ServletConverter.service(ServletConverter.java:129)
        at org.geoserver.rest.RESTDispatcher.handleRequestInternal(RESTDispatcher.java:79)
        at org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:153)
        at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
        at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:875)
        at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:809)
        at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:571)
        at org.springframework.web.servlet.FrameworkServlet.doPut(FrameworkServlet.java:521)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:640)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.vfny.geoserver.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:108)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:265)
        at org.acegisecurity.intercept.web.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:107)
        at org.acegisecurity.intercept.web.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:72)
        at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
        at org.acegisecurity.ui.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:124)
        at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
        at org.acegisecurity.providers.anonymous.AnonymousProcessingFilter.doFilter(AnonymousProcessingFilter.java:125)
        at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
        at org.acegisecurity.ui.basicauth.BasicProcessingFilter.doFilter(BasicProcessingFilter.java:174)
        at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
        at org.acegisecurity.context.HttpSessionContextIntegrationFilter.doFilter(HttpSessionContextIntegrationFilter.java:249)
        at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
        at org.acegisecurity.util.FilterChainProxy.doFilter(FilterChainProxy.java:149)
        at org.acegisecurity.util.FilterToBeanProxy.doFilter(FilterToBeanProxy.java:98)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.geoserver.filters.LoggingFilter.doFilter(LoggingFilter.java:73)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.geoserver.filters.ReverseProxyFilter.doFilter(ReverseProxyFilter.java:163)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.geoserver.filters.GZIPFilter.doFilter(GZIPFilter.java:47)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
        at java.lang.Thread.run(Unknown Source)
Caused by: java.io.IOException: Wrong magic number, expected 9994, got 1347093252
        at org.geotools.data.shapefile.shp.ShapefileHeader.checkMagic(ShapefileHeader.java:53)
        at org.geotools.data.shapefile.shp.ShapefileHeader.read(ShapefileHeader.java:75)
        at org.geotools.data.shapefile.shp.ShapefileReader.readHeader(ShapefileReader.java:206)
        at org.geotools.data.shapefile.shp.ShapefileReader.init(ShapefileReader.java:255)
        at org.geotools.data.shapefile.shp.ShapefileReader.<init>(ShapefileReader.java:168)
        at org.geotools.data.shapefile.ShapefileDataStore.openShapeReader(ShapefileDataStore.java:425)
        at org.geotools.data.shapefile.ShapefileDataStore.readAttributes(ShapefileDataStore.java:652)
        at org.geotools.data.shapefile.ShapefileDataStore.getSchema(ShapefileDataStore.java:610)
        at org.geotools.data.shapefile.ShapefileDataStore.getSchema(ShapefileDataStore.java:604)
        at org.geotools.data.shapefile.ShapefileDataStore.getFeatureSource(ShapefileDataStore.java:959)
        at org.geoserver.catalog.rest.DataStoreFileResource.handlePut(DataStoreFileResource.java:263)
        ... 55 more

It seems GeoServer treat my zip file as a shape file, and does not unzip it..

My data directory structure looks like:
<root>/data/pampers/pampers.shp
but pampers.shp is actually a zip archive

All the files are at the root of the archive. The zip file look like :
- pampers.dbf
- pampers.fix
- pampers.prj
- pampers.qix
- pampers.shp
- pampers.shx

What's wrong in my code ?
Justin, have you got an example that works ???

Thanks in advance

Eric and Gilles

-----Message d'origine-----
De : Justin Deoliveira [mailto:jdeolive@anonymised.com]
Envoyé : jeudi 2 juillet 2009 07:40
À : TASSE Gilles
Cc : geoserver-users@lists.sourceforge.net
Objet : Re: [Geoserver-users] [REST]

Hi,

TASSE Gilles wrote:

Hello,

I'm still having problems with adding layers to Geoserver using REST API.
I'm triying to explain my problem.

First, I created the workspace with :

curl -u user:pwd -v -XPOST -H "Content-type: text/xml" -d "<workspace><name>test</name></workspace>" http://localhost:8081/geoserver/rest/workspaces

It looked to be OK !

Then, I tried to put the zip file (pamper.zip, containing all shp, prj and other required files) with the following command

curl -u admin:geoserver -XPUT -H 'Content-type: application/zip' --data-binary @c:/pampers.zip http://localhost:8081/geoserver/rest/workspaces/test/datastores/pampers/file.shp

But I got :

java.io.IOException: Wrong magic number, expected 9994, got 1347093252

Hmmm... do you have the entire stack trace? It would be helpful to know
exactly where this is occuring. You may have to turn logging up, go to
the web ui and turn up logging to GEOSERVER_DEVELOPER_LOGGING.

But yeah, seems something is getting mixed up trying to read a shapefile
that is not actually a shapefile.

So you say that your data directory structure looks like:

<root>/data/pampers/pampers.shp?

Curious, what does the structure of the zip file look like? Are all the
files at the root of the archive?

-Justin

It seems to be as if Geoserver has treated my zip file as a shape file, because a "pampers" directory was created in my " geoserver\data\data\" directory, but there is only one file in there : pampers.shp that has the same size of the original zip file.

What's wrong in my code ?

thanks in advance

-----Message d'origine-----
De : Justin Deoliveira [mailto:jdeolive@anonymised.com]
Envoyé : mercredi 1 juillet 2009 07:10
À : TASSE Gilles
Cc : geoserver-users@lists.sourceforge.net
Objet : Re: [Geoserver-users] [REST]

Hi,

There are some docs available here:

http://docs.geoserver.org/1.7.x/user/extensions/rest/index.html

In particular some examples that use curl here:

http://docs.geoserver.org/1.7.x/user/extensions/rest/rest-config-examples-curl.html

And finally there are some scripts which build up the regular geoserver
release directory from scratch, including the states layer. YOu can find
those here:

http://svn.codehaus.org/geoserver/branches/1.7.x/src/extension/restconfig/scripts/

Hope that helps.

-Justin

TASSE Gilles wrote:

Hi all,

We are trying to understand how to use the REST API to add layers. Could
you give us an example of the url we should enter to add a datastore
with one of the sample files (let's say states.shp) ?

All our tries have returned us a 405 error.

Thank you !

*---------------------------------------------------------------------*
*Gilles Tasse*
/2, rue Antoine Becquerel/
/35700 RENNES/
/mailto:gilles.tasse@anonymised.com <mailto:nelly.hascoet@anonymised.com>/
/Tél : 02.23.21.11.11 - Fax : 02.23.21.11.00/

------------------------------------------------------------------------

------------------------------------------------------------------------------

------------------------------------------------------------------------

_______________________________________________
Geoserver-users mailing list
Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

--
Justin Deoliveira
OpenGeo - http://opengeo.org
Enterprise support for open source geospatial.

------------------------------------------------------------------------------
_______________________________________________
Geoserver-users mailing list
Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

--
Justin Deoliveira
OpenGeo - http://opengeo.org
Enterprise support for open source geospatial.

Thanks for sending the data.

I tried the zip file you sent and it worked perfectly, so i am not sure what is going on. Have you tried removing the directory <GEOSERVER_DATA_DIR>/data/pampers and trying gain?

I executed the command exactly as you did and with the same zip file and got the expected results. The contents of my <GEOSERVER_DATA_DIR>/pampers directory looks like:

pampers.dbf
pampers.fix
pampers.prj
pampers.qix
pampers.shp
pampers.shx

I wonder if this could be a windows thing. I will try to round up a windows machine to test it out on.

-Justin

BOUSQUET Eric wrote:

Thanks for your answer !
I'm not sure that the problem is comming from the archive, because it is basically a copy of the State shapefiles. Furthermore, when i put the archive manually in the right data directory, unzip it, and load the shapefile from the web ui, it works perfectly !!!
Anyway, I provide the archive as an attachement of this mail, if you want to have a look.

As far as I'm concerned, I would think that the "unzip" is never done.
Are you sure that the following command activate an unzip of the file (pampers.zip) which is given as a parameter ???

curl -u admin:geoserver -XPUT -H 'Content-type: application/zip' --data-binary @c:/pampers.zip http://localhost:8081/geoserver/rest/workspaces/julien/datastores/pampers/file.shp

-----Message d'origine-----
De : Justin Deoliveira [mailto:jdeolive@anonymised.com]
Envoyé : samedi 4 juillet 2009 07:20
À : BOUSQUET Eric
Cc : TASSE Gilles; geoserver-users@lists.sourceforge.net
Objet : Re: [Geoserver-users] [REST]

Thanks for the additional information. However it is not evident to me
what exactly is wrong. The warnings from the log definitely point to
something wrong with the shapefile. Is there any chance you can provide
it to me (via private mail if you wish) or post it somewhere i can get
at it. That way I can see here exactly what is going wrong.

-Justin

BOUSQUET Eric wrote:

Hello Justin !

First, thanks a lot for your answer.
In there, you asked me for the entire stack trace.

So after this command :

E:\MyFolder\Outils\Curl\curl_7.18.2>curl -u admin:geoserver -XPUT -H 'Content-type: application/zip' --data-binary @c:/pampers.zip http://localhost:8081/geoserver/rest/workspaces/julien/datastores/pampers/file.shp

I got this stack trace :

02 juil. 09:30:13 INFO [catalog.rest] - PUT file, mimetype: application/x-www-form-urlencoded
02 juil. 09:30:13 INFO [catalog.rest] - Using existing datastore: pampers
02 juil. 09:30:13 WARN [shapefile.sh] - Could not open the .shx file, continuing assuming the .shp file is not sparse
java.io.FileNotFoundException: C:\Serveurs\apache-tomcat-6.0.18\webapps\geoserver\data\data\pampers\pampers.shx
        at org.geotools.data.shapefile.ShpFiles.getReadChannel(ShpFiles.java:821)
        at org.geotools.data.shapefile.shp.IndexFile.<init>(IndexFile.java:78)
        at org.geotools.data.shapefile.shp.ShapefileReader.<init>(ShapefileReader.java:162)
        at org.geotools.data.shapefile.ShapefileDataStore.openShapeReader(ShapefileDataStore.java:425)
        at org.geotools.data.shapefile.ShapefileDataStore.readAttributes(ShapefileDataStore.java:652)
        at org.geotools.data.shapefile.ShapefileDataStore.getSchema(ShapefileDataStore.java:610)
        at org.geotools.data.shapefile.ShapefileDataStore.getSchema(ShapefileDataStore.java:604)
        at org.geotools.data.shapefile.ShapefileDataStore.getFeatureSource(ShapefileDataStore.java:959)
        at org.geoserver.catalog.rest.DataStoreFileResource.handlePut(DataStoreFileResource.java:263)
        at org.restlet.Finder.handle(Finder.java:298)
        at org.geoserver.rest.BeanDelegatingRestlet.handle(BeanDelegatingRestlet.java:38)
        at org.restlet.Filter.doHandle(Filter.java:105)
        at org.restlet.Filter.handle(Filter.java:134)
        at org.restlet.Router.handle(Router.java:444)
        at com.noelios.restlet.ext.servlet.ServletConverter.service(ServletConverter.java:129)
        at org.geoserver.rest.RESTDispatcher.handleRequestInternal(RESTDispatcher.java:79)
        at org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:153)
        at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
        at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:875)
        at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:809)
        at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:571)
        at org.springframework.web.servlet.FrameworkServlet.doPut(FrameworkServlet.java:521)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:640)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.vfny.geoserver.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:108)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:265)
        at org.acegisecurity.intercept.web.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:107)
        at org.acegisecurity.intercept.web.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:72)
        at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
        at org.acegisecurity.ui.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:124)
        at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
        at org.acegisecurity.providers.anonymous.AnonymousProcessingFilter.doFilter(AnonymousProcessingFilter.java:125)
        at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
        at org.acegisecurity.ui.basicauth.BasicProcessingFilter.doFilter(BasicProcessingFilter.java:174)
        at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
        at org.acegisecurity.context.HttpSessionContextIntegrationFilter.doFilter(HttpSessionContextIntegrationFilter.java:249)
        at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
        at org.acegisecurity.util.FilterChainProxy.doFilter(FilterChainProxy.java:149)
        at org.acegisecurity.util.FilterToBeanProxy.doFilter(FilterToBeanProxy.java:98)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.geoserver.filters.LoggingFilter.doFilter(LoggingFilter.java:73)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.geoserver.filters.ReverseProxyFilter.doFilter(ReverseProxyFilter.java:163)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.geoserver.filters.GZIPFilter.doFilter(GZIPFilter.java:47)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
        at java.lang.Thread.run(Unknown Source)
02 juil. 09:30:13 ERROR [geoserver.rest] -
java.lang.RuntimeException: java.io.IOException: Wrong magic number, expected 9994, got 1347093252
        at org.geoserver.catalog.rest.DataStoreFileResource.handlePut(DataStoreFileResource.java:295)
        at org.restlet.Finder.handle(Finder.java:298)
        at org.geoserver.rest.BeanDelegatingRestlet.handle(BeanDelegatingRestlet.java:38)
        at org.restlet.Filter.doHandle(Filter.java:105)
        at org.restlet.Filter.handle(Filter.java:134)
        at org.restlet.Router.handle(Router.java:444)
        at com.noelios.restlet.ext.servlet.ServletConverter.service(ServletConverter.java:129)
        at org.geoserver.rest.RESTDispatcher.handleRequestInternal(RESTDispatcher.java:79)
        at org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:153)
        at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
        at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:875)
        at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:809)
        at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:571)
        at org.springframework.web.servlet.FrameworkServlet.doPut(FrameworkServlet.java:521)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:640)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.vfny.geoserver.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:108)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:265)
        at org.acegisecurity.intercept.web.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:107)
        at org.acegisecurity.intercept.web.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:72)
        at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
        at org.acegisecurity.ui.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:124)
        at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
        at org.acegisecurity.providers.anonymous.AnonymousProcessingFilter.doFilter(AnonymousProcessingFilter.java:125)
        at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
        at org.acegisecurity.ui.basicauth.BasicProcessingFilter.doFilter(BasicProcessingFilter.java:174)
        at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
        at org.acegisecurity.context.HttpSessionContextIntegrationFilter.doFilter(HttpSessionContextIntegrationFilter.java:249)
        at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
        at org.acegisecurity.util.FilterChainProxy.doFilter(FilterChainProxy.java:149)
        at org.acegisecurity.util.FilterToBeanProxy.doFilter(FilterToBeanProxy.java:98)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.geoserver.filters.LoggingFilter.doFilter(LoggingFilter.java:73)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.geoserver.filters.ReverseProxyFilter.doFilter(ReverseProxyFilter.java:163)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.geoserver.filters.GZIPFilter.doFilter(GZIPFilter.java:47)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
        at java.lang.Thread.run(Unknown Source)
Caused by: java.io.IOException: Wrong magic number, expected 9994, got 1347093252
        at org.geotools.data.shapefile.shp.ShapefileHeader.checkMagic(ShapefileHeader.java:53)
        at org.geotools.data.shapefile.shp.ShapefileHeader.read(ShapefileHeader.java:75)
        at org.geotools.data.shapefile.shp.ShapefileReader.readHeader(ShapefileReader.java:206)
        at org.geotools.data.shapefile.shp.ShapefileReader.init(ShapefileReader.java:255)
        at org.geotools.data.shapefile.shp.ShapefileReader.<init>(ShapefileReader.java:168)
        at org.geotools.data.shapefile.ShapefileDataStore.openShapeReader(ShapefileDataStore.java:425)
        at org.geotools.data.shapefile.ShapefileDataStore.readAttributes(ShapefileDataStore.java:652)
        at org.geotools.data.shapefile.ShapefileDataStore.getSchema(ShapefileDataStore.java:610)
        at org.geotools.data.shapefile.ShapefileDataStore.getSchema(ShapefileDataStore.java:604)
        at org.geotools.data.shapefile.ShapefileDataStore.getFeatureSource(ShapefileDataStore.java:959)
        at org.geoserver.catalog.rest.DataStoreFileResource.handlePut(DataStoreFileResource.java:263)
        ... 55 more

It seems GeoServer treat my zip file as a shape file, and does not unzip it..

My data directory structure looks like:
<root>/data/pampers/pampers.shp
but pampers.shp is actually a zip archive

All the files are at the root of the archive. The zip file look like :
- pampers.dbf
- pampers.fix
- pampers.prj
- pampers.qix
- pampers.shp
- pampers.shx

What's wrong in my code ?
Justin, have you got an example that works ???

Thanks in advance

Eric and Gilles

-----Message d'origine-----
De : Justin Deoliveira [mailto:jdeolive@anonymised.com]
Envoyé : jeudi 2 juillet 2009 07:40
À : TASSE Gilles
Cc : geoserver-users@lists.sourceforge.net
Objet : Re: [Geoserver-users] [REST]

Hi,

TASSE Gilles wrote:

Hello,

I'm still having problems with adding layers to Geoserver using REST API..
I'm triying to explain my problem.

First, I created the workspace with :

curl -u user:pwd -v -XPOST -H "Content-type: text/xml" -d "<workspace><name>test</name></workspace>" http://localhost:8081/geoserver/rest/workspaces

It looked to be OK !

Then, I tried to put the zip file (pamper.zip, containing all shp, prj and other required files) with the following command

curl -u admin:geoserver -XPUT -H 'Content-type: application/zip' --data-binary @c:/pampers.zip http://localhost:8081/geoserver/rest/workspaces/test/datastores/pampers/file.shp

But I got :

java.io.IOException: Wrong magic number, expected 9994, got 1347093252

Hmmm... do you have the entire stack trace? It would be helpful to know
exactly where this is occuring. You may have to turn logging up, go to
the web ui and turn up logging to GEOSERVER_DEVELOPER_LOGGING.

But yeah, seems something is getting mixed up trying to read a shapefile
that is not actually a shapefile.

So you say that your data directory structure looks like:

<root>/data/pampers/pampers.shp?

Curious, what does the structure of the zip file look like? Are all the
files at the root of the archive?

-Justin

It seems to be as if Geoserver has treated my zip file as a shape file, because a "pampers" directory was created in my " geoserver\data\data\" directory, but there is only one file in there : pampers.shp that has the same size of the original zip file.
What's wrong in my code ?

thanks in advance

-----Message d'origine-----
De : Justin Deoliveira [mailto:jdeolive@anonymised.com]
Envoyé : mercredi 1 juillet 2009 07:10
À : TASSE Gilles
Cc : geoserver-users@lists.sourceforge.net
Objet : Re: [Geoserver-users] [REST]

Hi,

There are some docs available here:

http://docs.geoserver.org/1.7.x/user/extensions/rest/index.html

In particular some examples that use curl here:

http://docs.geoserver.org/1.7.x/user/extensions/rest/rest-config-examples-curl.html

And finally there are some scripts which build up the regular geoserver
release directory from scratch, including the states layer. YOu can find
those here:

http://svn.codehaus.org/geoserver/branches/1.7.x/src/extension/restconfig/scripts/

Hope that helps.

-Justin

TASSE Gilles wrote:

Hi all,

We are trying to understand how to use the REST API to add layers. Could
you give us an example of the url we should enter to add a datastore
with one of the sample files (let's say states.shp) ?

All our tries have returned us a 405 error.

Thank you !

*---------------------------------------------------------------------*
*Gilles Tasse*
/2, rue Antoine Becquerel/
/35700 RENNES/
/mailto:gilles.tasse@anonymised.com <mailto:nelly.hascoet@anonymised.com>/
/Tél : 02.23.21.11.11 - Fax : 02.23.21.11.00/

------------------------------------------------------------------------

------------------------------------------------------------------------------

------------------------------------------------------------------------

_______________________________________________
Geoserver-users mailing list
Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

--
Justin Deoliveira
OpenGeo - http://opengeo.org
Enterprise support for open source geospatial.

------------------------------------------------------------------------------
_______________________________________________
Geoserver-users mailing list
Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

--
Justin Deoliveira
OpenGeo - http://opengeo.org
Enterprise support for open source geospatial.

--
Justin Deoliveira
OpenGeo - http://opengeo.org
Enterprise support for open source geospatial.

I wonder if this could be a windows thing. I will try to round up a windows machine to test it out on.

I reproduced this on windows too. And the problem turned out to be
in the use of quotes in the command. Basically I had to change:

  -H 'Content-type: application/zip'

to:

  -H "Content-type: application/zip"

And it works. Hopefully it is the same problem. We should also update
the documentation to use double quotes since linux can handle both.

  -Justin

-Justin

BOUSQUET Eric wrote:

Thanks for your answer !
I'm not sure that the problem is comming from the archive, because it is basically a copy of the State shapefiles. Furthermore, when i put the archive manually in the right data directory, unzip it, and load the shapefile from the web ui, it works perfectly !!!
Anyway, I provide the archive as an attachement of this mail, if you want to have a look.

As far as I'm concerned, I would think that the "unzip" is never done.
Are you sure that the following command activate an unzip of the file (pampers.zip) which is given as a parameter ???

curl -u admin:geoserver -XPUT -H 'Content-type: application/zip' --data-binary @c:/pampers.zip http://localhost:8081/geoserver/rest/workspaces/julien/datastores/pampers/file.shp

-----Message d'origine-----
De : Justin Deoliveira [mailto:jdeolive@anonymised.com]
Envoyé : samedi 4 juillet 2009 07:20
À : BOUSQUET Eric
Cc : TASSE Gilles; geoserver-users@lists.sourceforge.net
Objet : Re: [Geoserver-users] [REST]

Thanks for the additional information. However it is not evident to me
what exactly is wrong. The warnings from the log definitely point to
something wrong with the shapefile. Is there any chance you can provide
it to me (via private mail if you wish) or post it somewhere i can get
at it. That way I can see here exactly what is going wrong.

-Justin

BOUSQUET Eric wrote:

Hello Justin !

First, thanks a lot for your answer.
In there, you asked me for the entire stack trace.

So after this command :

E:\MyFolder\Outils\Curl\curl_7.18.2>curl -u admin:geoserver -XPUT -H 'Content-type: application/zip' --data-binary @c:/pampers.zip http://localhost:8081/geoserver/rest/workspaces/julien/datastores/pampers/file.shp

I got this stack trace :

02 juil. 09:30:13 INFO [catalog.rest] - PUT file, mimetype: application/x-www-form-urlencoded
02 juil. 09:30:13 INFO [catalog.rest] - Using existing datastore: pampers
02 juil. 09:30:13 WARN [shapefile.sh] - Could not open the .shx file, continuing assuming the .shp file is not sparse
java.io.FileNotFoundException: C:\Serveurs\apache-tomcat-6.0.18\webapps\geoserver\data\data\pampers\pampers.shx
        at org.geotools.data.shapefile.ShpFiles.getReadChannel(ShpFiles.java:821)
        at org.geotools.data.shapefile.shp.IndexFile.<init>(IndexFile.java:78)
        at org.geotools.data.shapefile.shp.ShapefileReader.<init>(ShapefileReader.java:162)
        at org.geotools.data.shapefile.ShapefileDataStore.openShapeReader(ShapefileDataStore.java:425)
        at org.geotools.data.shapefile.ShapefileDataStore.readAttributes(ShapefileDataStore.java:652)
        at org.geotools.data.shapefile.ShapefileDataStore.getSchema(ShapefileDataStore.java:610)
        at org.geotools.data.shapefile.ShapefileDataStore.getSchema(ShapefileDataStore.java:604)
        at org.geotools.data.shapefile.ShapefileDataStore.getFeatureSource(ShapefileDataStore.java:959)
        at org.geoserver.catalog.rest.DataStoreFileResource.handlePut(DataStoreFileResource.java:263)
        at org.restlet.Finder.handle(Finder.java:298)
        at org.geoserver.rest.BeanDelegatingRestlet.handle(BeanDelegatingRestlet.java:38)
        at org.restlet.Filter.doHandle(Filter.java:105)
        at org.restlet.Filter.handle(Filter.java:134)
        at org.restlet.Router.handle(Router.java:444)
        at com.noelios.restlet.ext.servlet.ServletConverter.service(ServletConverter.java:129)
        at org.geoserver.rest.RESTDispatcher.handleRequestInternal(RESTDispatcher.java:79)
        at org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:153)
        at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
        at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:875)
        at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:809)
        at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:571)
        at org.springframework.web.servlet.FrameworkServlet.doPut(FrameworkServlet.java:521)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:640)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.vfny.geoserver.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:108)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:265)
        at org.acegisecurity.intercept.web.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:107)
        at org.acegisecurity.intercept.web.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:72)
        at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
        at org.acegisecurity.ui.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:124)
        at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
        at org.acegisecurity.providers.anonymous.AnonymousProcessingFilter.doFilter(AnonymousProcessingFilter.java:125)
        at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
        at org.acegisecurity.ui.basicauth.BasicProcessingFilter.doFilter(BasicProcessingFilter.java:174)
        at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
        at org.acegisecurity.context.HttpSessionContextIntegrationFilter.doFilter(HttpSessionContextIntegrationFilter.java:249)
        at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
        at org.acegisecurity.util.FilterChainProxy.doFilter(FilterChainProxy.java:149)
        at org.acegisecurity.util.FilterToBeanProxy.doFilter(FilterToBeanProxy.java:98)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.geoserver.filters.LoggingFilter.doFilter(LoggingFilter.java:73)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.geoserver.filters.ReverseProxyFilter.doFilter(ReverseProxyFilter.java:163)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.geoserver.filters.GZIPFilter.doFilter(GZIPFilter.java:47)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
        at java.lang.Thread.run(Unknown Source)
02 juil. 09:30:13 ERROR [geoserver.rest] -
java.lang.RuntimeException: java.io.IOException: Wrong magic number, expected 9994, got 1347093252
        at org.geoserver.catalog.rest.DataStoreFileResource.handlePut(DataStoreFileResource.java:295)
        at org.restlet.Finder.handle(Finder.java:298)
        at org.geoserver.rest.BeanDelegatingRestlet.handle(BeanDelegatingRestlet.java:38)
        at org.restlet.Filter.doHandle(Filter.java:105)
        at org.restlet.Filter.handle(Filter.java:134)
        at org.restlet.Router.handle(Router.java:444)
        at com.noelios.restlet.ext.servlet.ServletConverter.service(ServletConverter.java:129)
        at org.geoserver.rest.RESTDispatcher.handleRequestInternal(RESTDispatcher.java:79)
        at org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:153)
        at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
        at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:875)
        at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:809)
        at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:571)
        at org.springframework.web.servlet.FrameworkServlet.doPut(FrameworkServlet.java:521)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:640)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.vfny.geoserver.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:108)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:265)
        at org.acegisecurity.intercept.web.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:107)
        at org.acegisecurity.intercept.web.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:72)
        at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
        at org.acegisecurity.ui.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:124)
        at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
        at org.acegisecurity.providers.anonymous.AnonymousProcessingFilter.doFilter(AnonymousProcessingFilter.java:125)
        at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
        at org.acegisecurity.ui.basicauth.BasicProcessingFilter.doFilter(BasicProcessingFilter.java:174)
        at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
        at org.acegisecurity.context.HttpSessionContextIntegrationFilter.doFilter(HttpSessionContextIntegrationFilter.java:249)
        at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
        at org.acegisecurity.util.FilterChainProxy.doFilter(FilterChainProxy.java:149)
        at org.acegisecurity.util.FilterToBeanProxy.doFilter(FilterToBeanProxy.java:98)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.geoserver.filters.LoggingFilter.doFilter(LoggingFilter.java:73)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.geoserver.filters.ReverseProxyFilter.doFilter(ReverseProxyFilter.java:163)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.geoserver.filters.GZIPFilter.doFilter(GZIPFilter.java:47)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
        at java.lang.Thread.run(Unknown Source)
Caused by: java.io.IOException: Wrong magic number, expected 9994, got 1347093252
        at org.geotools.data.shapefile.shp.ShapefileHeader.checkMagic(ShapefileHeader.java:53)
        at org.geotools.data.shapefile.shp.ShapefileHeader.read(ShapefileHeader.java:75)
        at org.geotools.data.shapefile.shp.ShapefileReader.readHeader(ShapefileReader.java:206)
        at org.geotools.data.shapefile.shp.ShapefileReader.init(ShapefileReader.java:255)
        at org.geotools.data.shapefile.shp.ShapefileReader.<init>(ShapefileReader.java:168)
        at org.geotools.data.shapefile.ShapefileDataStore.openShapeReader(ShapefileDataStore.java:425)
        at org.geotools.data.shapefile.ShapefileDataStore.readAttributes(ShapefileDataStore.java:652)
        at org.geotools.data.shapefile.ShapefileDataStore.getSchema(ShapefileDataStore.java:610)
        at org.geotools.data.shapefile.ShapefileDataStore.getSchema(ShapefileDataStore.java:604)
        at org.geotools.data.shapefile.ShapefileDataStore.getFeatureSource(ShapefileDataStore.java:959)
        at org.geoserver.catalog.rest.DataStoreFileResource.handlePut(DataStoreFileResource.java:263)
        ... 55 more

It seems GeoServer treat my zip file as a shape file, and does not unzip it..

My data directory structure looks like:
<root>/data/pampers/pampers.shp
but pampers.shp is actually a zip archive

All the files are at the root of the archive. The zip file look like :
- pampers.dbf
- pampers.fix
- pampers.prj
- pampers.qix
- pampers.shp
- pampers.shx

What's wrong in my code ?
Justin, have you got an example that works ???

Thanks in advance

Eric and Gilles

-----Message d'origine-----
De : Justin Deoliveira [mailto:jdeolive@anonymised.com]
Envoyé : jeudi 2 juillet 2009 07:40
À : TASSE Gilles
Cc : geoserver-users@lists.sourceforge.net
Objet : Re: [Geoserver-users] [REST]

Hi,

TASSE Gilles wrote:

Hello,

I'm still having problems with adding layers to Geoserver using REST API..
I'm triying to explain my problem.

First, I created the workspace with :

curl -u user:pwd -v -XPOST -H "Content-type: text/xml" -d "<workspace><name>test</name></workspace>" http://localhost:8081/geoserver/rest/workspaces

It looked to be OK !

Then, I tried to put the zip file (pamper.zip, containing all shp, prj and other required files) with the following command

curl -u admin:geoserver -XPUT -H 'Content-type: application/zip' --data-binary @c:/pampers.zip http://localhost:8081/geoserver/rest/workspaces/test/datastores/pampers/file.shp

But I got :

java.io.IOException: Wrong magic number, expected 9994, got 1347093252

Hmmm... do you have the entire stack trace? It would be helpful to know
exactly where this is occuring. You may have to turn logging up, go to
the web ui and turn up logging to GEOSERVER_DEVELOPER_LOGGING.

But yeah, seems something is getting mixed up trying to read a shapefile
that is not actually a shapefile.

So you say that your data directory structure looks like:

<root>/data/pampers/pampers.shp?

Curious, what does the structure of the zip file look like? Are all the
files at the root of the archive?

-Justin

It seems to be as if Geoserver has treated my zip file as a shape file, because a "pampers" directory was created in my " geoserver\data\data\" directory, but there is only one file in there : pampers.shp that has the same size of the original zip file.
What's wrong in my code ?

thanks in advance

-----Message d'origine-----
De : Justin Deoliveira [mailto:jdeolive@anonymised.com]
Envoyé : mercredi 1 juillet 2009 07:10
À : TASSE Gilles
Cc : geoserver-users@lists.sourceforge.net
Objet : Re: [Geoserver-users] [REST]

Hi,

There are some docs available here:

http://docs.geoserver.org/1.7.x/user/extensions/rest/index.html

In particular some examples that use curl here:

http://docs.geoserver.org/1.7.x/user/extensions/rest/rest-config-examples-curl.html

And finally there are some scripts which build up the regular geoserver
release directory from scratch, including the states layer. YOu can find
those here:

http://svn.codehaus.org/geoserver/branches/1.7.x/src/extension/restconfig/scripts/

Hope that helps.

-Justin

TASSE Gilles wrote:

Hi all,

We are trying to understand how to use the REST API to add layers. Could
you give us an example of the url we should enter to add a datastore
with one of the sample files (let's say states.shp) ?

All our tries have returned us a 405 error.

Thank you !

*---------------------------------------------------------------------*
*Gilles Tasse*
/2, rue Antoine Becquerel/
/35700 RENNES/
/mailto:gilles.tasse@anonymised.com <mailto:nelly.hascoet@anonymised.com>/
/Tél : 02.23.21.11.11 - Fax : 02.23.21.11.00/

------------------------------------------------------------------------

------------------------------------------------------------------------------

------------------------------------------------------------------------

_______________________________________________
Geoserver-users mailing list
Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

--
Justin Deoliveira
OpenGeo - http://opengeo.org
Enterprise support for open source geospatial.

------------------------------------------------------------------------------
_______________________________________________
Geoserver-users mailing list
Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

--
Justin Deoliveira
OpenGeo - http://opengeo.org
Enterprise support for open source geospatial.

--
Justin Deoliveira
OpenGeo - http://opengeo.org
Enterprise support for open source geospatial.