[Geoserver-devel] How to run GeoServer with WPS module

Hi Andrea

thanks, it works. I was able to add a process.
Is there an easy way to use the datastores and featuretypes defined in GeoServer? I tried to connect to a postgis database in the execute method of my process:

Map params= new HashMap();
params.put(“dbtype”, “postgis”);
params.put(“host”, “localhost”);
params.put(“port”, 5432);
params.put(“database”, “xanadu”);
params.put(“schema”, “chenyx06”);
params.put(“user”, “stefan”);
params.put(“passwd”, “XXXXX”);

DataStore datastore = DataStoreFinder.getDataStore( params );

String tableNameLV03 = “chenyx06-lv03”;
FeatureSource<SimpleFeatureType, SimpleFeature> source = datastore.getFeatureSource( tableNameLV03 );

This works in a standalone GeoTools project but throws some error here:

Running org.geoserver.wps.CataisFreeFrameTest
21 Feb 21:08:23 ERROR [geoserver.ows] -
org.geoserver.wps.WPSException: InternalError: java.lang.NullPointerException
at org.geoserver.wps.Execute.run(Execute.java:168)
at org.geoserver.wps.DefaultWebProcessingService.execute(DefaultWebProcessingService.java:69)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.geoserver.ows.Dispatcher.execute(Dispatcher.java:649)
at org.geoserver.ows.Dispatcher.handleRequestInternal(Dispatcher.java:230)
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.doPost(FrameworkServlet.java:511)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.geoserver.test.GeoServerAbstractTestSupport.dispatch(GeoServerAbstractTestSupport.java:1054)
at org.geoserver.test.GeoServerAbstractTestSupport.dispatch(GeoServerAbstractTestSupport.java:1021)
at org.geoserver.test.GeoServerAbstractTestSupport.postAsServletResponse(GeoServerAbstractTestSupport.java:648)
at org.geoserver.test.GeoServerAbstractTestSupport.postAsServletResponse(GeoServerAbstractTestSupport.java:595)
at org.geoserver.test.GeoServerAbstractTestSupport.post(GeoServerAbstractTestSupport.java:575)
at org.geoserver.test.GeoServerAbstractTestSupport.postAsDOM(GeoServerAbstractTestSupport.java:784)
at org.geoserver.test.GeoServerAbstractTestSupport.postAsDOM(GeoServerAbstractTestSupport.java:767)
at org.geoserver.wps.CataisFreeFrameTest.testFeatureCollectionInline21781Raw(CataisFreeFrameTest.java:67)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at junit.framework.TestCase.runTest(TestCase.java:164)
at org.geoserver.test.GeoServerAbstractTestSupport.runTest(GeoServerAbstractTestSupport.java:126)
at junit.framework.TestCase.runBare(TestCase.java:130)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:120)
at junit.framework.TestSuite.runTest(TestSuite.java:230)
at junit.framework.TestSuite.run(TestSuite.java:225)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.maven.surefire.junit.JUnitTestSet.execute(JUnitTestSet.java:213)
at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:140)
at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:127)
at org.apache.maven.surefire.Surefire.run(Surefire.java:177)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:338)
at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:997)
Caused by: java.lang.NullPointerException
at org.geoserver.wps.catais.CataisFreeFrameProcess.execute(CataisFreeFrameProcess.java:115)
at org.geoserver.wps.Execute.run(Execute.java:162)
… 50 more

regards
Stefan

-----Ursprüngliche Nachricht-----
Von: Andrea Aime [mailto:aaime@anonymised.com]
Gesendet am: Freitag, 19. Februar 2010 19:31
An: Ziegler Stefan
Cc: geoserver-devel
Betreff: Re: [Geoserver-devel] How to run GeoServer with WPS module

Ziegler Stefan ha scritto:

Hi

I have problems to get GeoServer running with the WPS module:

  • I checked out today’s trunk
  • Built GS with 'mvn clean install -Pwps
  • WPS tests seem to work
  • deployed the resulting geoserver.war file in Tomcat

Looked on trunk, I could make things work in the IDE but not
in the geoserver.war

I think I fixed the issues. Try svn updating, rebuilding both
the wps module and web/app with -Pwps, it should be working
(I checked the capabilities was returned, nothing more than that)

Cheers
Andrea


Andrea Aime
OpenGeo - http://opengeo.org
Expert service straight from the developers.

Ziegler Stefan wrote:

Hi Andrea

thanks, it works. I was able to add a process.
Is there an easy way to use the datastores and featuretypes defined in GeoServer? I tried to connect to a postgis database in the execute method of my process:

Map params= new HashMap();
params.put("dbtype", "postgis");
params.put("host", "localhost");
params.put("port", 5432);
params.put("database", "xanadu");
params.put("schema", "chenyx06");
params.put("user", "stefan");
params.put("passwd", "XXXXX");

DataStore datastore = DataStoreFinder.getDataStore( params );

String tableNameLV03 = "chenyx06-lv03";
FeatureSource<SimpleFeatureType, SimpleFeature> source = datastore.getFeatureSource( tableNameLV03 );

This works in a standalone GeoTools project but throws some error here:

Running org.geoserver.wps.CataisFreeFrameTest
21 Feb 21:08:23 ERROR [geoserver.ows] -
org.geoserver.wps.WPSException: InternalError: java.lang.NullPointerException

It's difficult to say what the NPE is due to without seeing the code,
my guess is that you're not getting any datastore back from the datastorefinder (no idea why).

Yes, once you're running from within GeoServer you can have your
process use the catalog and get a datastore.

Try with something like this:

Catalog catalog = GeoServerExtensions.getBean("catalog");
FeatureTypeInfo fti = catalog.getFeatureTypeByName(namespace, name);
fti.getFeatureSource();

(not tested).

However, I'd say it's bad practice for a process to connect to a data
source, it should receive whatever it needs from its inputs instead
(a FeatureCollection with the data you need might be a good idea, not
sure, don't know exactly what you're trying to do).

Cheers
Andrea