Okay, I found an issue with some libraries, but am still getting an
error. Here is a slightly updated version of the code:

    public void processShapefile(String shapefileName) throws ServiceException {
        String tmpFileDir = System.getProperty("java.io.tmpdir");

        File shapeFile = new File(tmpFileDir, shapefileName);

        if (!shapeFile.exists()) {
            throw new ServiceException("Shapefile " + shapefileName +
" not found!");
        }

        FileDataStore dataStore = null;
        try {
            dataStore = FileDataStoreFinder.getDataStore(shapeFile);
        } catch (IOException e) {
            e.printStackTrace();
        }

        // snip
     }

Here is the current stacktrace:

[ERROR] WARNING: Could not aquire ESRI(tm) Shapefiles (*.shp):java.lang.Exceptio
nInInitializerError
[ERROR] java.lang.ExceptionInInitializerError
[ERROR]         at
org.geotools.data.shapefile.ShapefileDataStoreFactory.createDataStore(ShapefileDataStoreFactory.java:355)
[ERROR]         at
org.geotools.data.FileDataStoreFinder.getDataStore(FileDataStoreFinder.java:93)
[ERROR]         at
org.geotools.data.FileDataStoreFinder.getDataStore(FileDataStoreFinder.java:67)
[ERROR]         at
org.jason.mapmaker.server.service.ShapefileServiceImpl.processShapefile(ShapefileServiceImpl.java:74)
[ERROR]         at
org.jason.mapmaker.server.servlet.ShapefileUploadServlet.doPost(ShapefileUploadServlet.java:91)
[ERROR]         at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
[ERROR]         at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
[ERROR]         at
org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
[ERROR]         at
org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:362)
[ERROR]         at
org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
[ERROR]         at
org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
[ERROR]         at
org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:729)
[ERROR]         at
org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
[ERROR]         at
org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
[ERROR]         at
org.mortbay.jetty.handler.RequestLogHandler.handle(RequestLogHandler.java:49)
[ERROR]         at
org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
[ERROR]         at org.mortbay.jetty.Server.handle(Server.java:324)
[ERROR]         at
org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
[ERROR]         at
org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:843)
[ERROR]         at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:647)
[ERROR]         at
org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
[ERROR]         at
org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
[ERROR]         at
org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
[ERROR]         at
org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:488)
[ERROR] Caused by: java.lang.ClassCastException: class
org.geotools.filter.FilterFactoryImpl
[ERROR]         at java.lang.Class.asSubclass(Class.java:3018)
[ERROR]         at
org.geotools.factory.FactoryRegistry.register(FactoryRegistry.java:866)
[ERROR]         at
org.geotools.factory.FactoryRegistry.scanForPlugins(FactoryRegistry.java:773)
[ERROR]         at
org.geotools.factory.FactoryRegistry.scanForPluginsIfNeeded(FactoryRegistry.java:808)
[ERROR]         at
org.geotools.factory.FactoryRegistry.getUnfilteredProviders(FactoryRegistry.java:229)
[ERROR]         at
org.geotools.factory.FactoryRegistry.getServiceImplementation(FactoryRegistry.java:429)
[ERROR]         at
org.geotools.factory.FactoryRegistry.getServiceProvider(FactoryRegistry.java:364)
[ERROR]         at
org.geotools.factory.FactoryCreator.getServiceProvider(FactoryCreator.java:143)
[ERROR]         at
org.geotools.factory.CommonFactoryFinder.lookup(CommonFactoryFinder.java:314)
[ERROR]         at
org.geotools.factory.CommonFactoryFinder.getFilterFactory(CommonFactoryFinder.java:285)
[ERROR]         at
org.geotools.data.DataUtilities.<clinit>(DataUtilities.java:138)
[ERROR]         ... 24 more
[ERROR] Mar 30, 2011 7:23:28 PM org.geotools.data.FileDataStoreFinder getDataSto
re
[ERROR] WARNING: Could not aquire ESRI(tm) Shapefiles
(*.shp):java.lang.NoClassDefFoundError: Could not initialize class
org.geotools.data.DataUtilities
[ERROR] java.lang.NoClassDefFoundError: Could not initialize class
org.geotools.data.DataUtilities
[ERROR]         at
org.geotools.data.shapefile.ShapefileDataStoreFactory.createDataStore(ShapefileDataStoreFactory.java:355)
[ERROR]         at
org.geotools.data.FileDataStoreFinder.getDataStore(FileDataStoreFinder.java:93)
[ERROR]         at
org.geotools.data.FileDataStoreFinder.getDataStore(FileDataStoreFinder.java:67)
[ERROR]         at
org.jason.mapmaker.server.service.ShapefileServiceImpl.processShapefile(ShapefileServiceImpl.java:96)
[ERROR]         at
org.jason.mapmaker.server.servlet.ShapefileUploadServlet.doPost(ShapefileUploadServlet.java:91)
[ERROR]         at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
[ERROR]         at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
[ERROR]         at
org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
[ERROR]         at
org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:362)
[ERROR]         at
org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
[ERROR]         at
org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
[ERROR]         at
org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:729)
[ERROR]         at
org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
[ERROR]         at
org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
[ERROR]         at
org.mortbay.jetty.handler.RequestLogHandler.handle(RequestLogHandler.java:49)
[ERROR]         at
org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
[ERROR]         at org.mortbay.jetty.Server.handle(Server.java:324)
[ERROR]         at
org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
[ERROR]         at
org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:843)
[ERROR]         at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:647)
[ERROR]         at
org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
[ERROR]         at
org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
[ERROR]         at
org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
[ERROR]         at
org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:488)

I still really need help with this.

Jason

On Wed, Mar 30, 2011 at 12:27 PM, Jason Ferguson
<[email protected]> wrote:
> I'm having an issue processing a Shapefile and can't get past the
> initialization of the datastore. Here's the code (up to the error):
>
>    public void processShapefile(String shapefileName) throws ServiceException 
> {
>        String tmpFileDir = System.getProperty("java.io.tmpdir");
>
>        File shapeFile = new File(tmpFileDir, shapefileName);
>
>        if (!shapeFile.exists()) {
>            throw new ServiceException("Shapefile " + shapefileName +
> " not found!");
>        }
>
>        ShapefileDataStore dataStore = null;
>        try {
>            dataStore = new ShapefileDataStore(shapeFile.toURI().toURL());
>        } catch (MalformedURLException e) {
>            throw new ServiceException("processShapefile() throw
> MalformedURLExeception: ", e);
>        } catch (Throwable ex) {
>            ex.printStackTrace();
>        }
>
>        if (dataStore==null) {
>            throw new ServiceException("ShapefileDataStore was null");
>        }
>
>        // snip
>    }
>
> Unfortunately, this throws a java.lang.ExceptionInInitializerError,
> caused by a java.lang.ClassCastException. I'm a noob, so any help is
> appreciated. I updated from 2.6.5 to 2.7.0 with no change.
>
> [ERROR] java.lang.ExceptionInInitializerError
> [ERROR]         at
> org.geotools.data.shapefile.ShpFiles.exists(ShpFiles.java:981)
> [ERROR]         at 
> org.geotools.data.shapefile.ShpFiles.init(ShpFiles.java:172)
> [ERROR]         at
> org.geotools.data.shapefile.ShpFiles.<init>(ShpFiles.java:129)
> [ERROR]         at
> org.geotools.data.shapefile.ShapefileDataStore.<init>(ShapefileDataStore.java:178)
> [ERROR]         at
> org.geotools.data.shapefile.ShapefileDataStore.<init>(ShapefileDataStore.java:150)
> [ERROR]         at
> org.geotools.data.shapefile.ShapefileDataStore.<init>(ShapefileDataStore.java:140)
> [ERROR]         at
> org.jason.mapmaker.server.service.ShapefileServiceImpl.processShapefile(ShapefileServiceImpl.java:74)
> [ERROR]         at
> org.jason.mapmaker.server.servlet.ShapefileUploadServlet.doPost(ShapefileUploadServlet.java:91)
> [ERROR]         at 
> javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
> [ERROR]         at 
> javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
> [ERROR]         at
> org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
> [ERROR]         at
> org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:362)
> [ERROR]         at
> org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
> [ERROR]         at
> org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
> [ERROR]         at
> org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:729)
> [ERROR]         at
> org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
> [ERROR]         at
> org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
> [ERROR]         at
> org.mortbay.jetty.handler.RequestLogHandler.handle(RequestLogHandler.java:49)
> [ERROR]         at
> org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
> [ERROR]         at org.mortbay.jetty.Server.handle(Server.java:324)
> [ERROR]         at
> org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
> [ERROR]         at
> org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:843)
> [ERROR]         at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:647)
> [ERROR]         at
> org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
> [ERROR]         at
> org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
> [ERROR]         at
> org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
> [ERROR]         at
> org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:488)
> [ERROR] Caused by: java.lang.ClassCastException: class
> org.geotools.filter.FilterFactoryImpl
> [ERROR]         at java.lang.Class.asSubclass(Class.java:3018)
> [ERROR]         at
> org.geotools.factory.FactoryRegistry.register(FactoryRegistry.java:866)
> [ERROR]         at
> org.geotools.factory.FactoryRegistry.scanForPlugins(FactoryRegistry.java:773)
> [ERROR]         at
> org.geotools.factory.FactoryRegistry.scanForPluginsIfNeeded(FactoryRegistry.java:808)
> [ERROR]         at
> org.geotools.factory.FactoryRegistry.getUnfilteredProviders(FactoryRegistry.java:229)
> [ERROR]         at
> org.geotools.factory.FactoryRegistry.getServiceImplementation(FactoryRegistry.java:429)
> [ERROR]         at
> org.geotools.factory.FactoryRegistry.getServiceProvider(FactoryRegistry.java:364)
> [ERROR]         at
> org.geotools.factory.FactoryCreator.getServiceProvider(FactoryCreator.java:143)
> [ERROR]         at
> org.geotools.factory.CommonFactoryFinder.lookup(CommonFactoryFinder.java:314)
> [ERROR]         at
> org.geotools.factory.CommonFactoryFinder.getFilterFactory(CommonFactoryFinder.java:285)
> [ERROR]         at
> org.geotools.data.DataUtilities.<clinit>(DataUtilities.java:138)
> [ERROR]         ... 27 more
>

------------------------------------------------------------------------------
Create and publish websites with WebMatrix
Use the most popular FREE web apps or write code yourself; 
WebMatrix provides all the features you need to develop and 
publish your website. http://p.sf.net/sfu/ms-webmatrix-sf
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to