1

I have an application that uses Geotools. It works fine with tomcat, with glassfish however I get the following error. Here is a stacktrace:

org.opengis.referencing.FactoryException: Failed to connect to the EPSG database.
    at org.geotools.referencing.factory.epsg.ThreadedEpsgFactory.createBackingStore(ThreadedEpsgFactory.java:483)
    at org.geotools.referencing.factory.DeferredAuthorityFactory.getBackingStore(DeferredAuthorityFactory.java:138)
    at org.geotools.referencing.factory.BufferedAuthorityFactory.isAvailable(BufferedAuthorityFactory.java:232)
    at org.geotools.referencing.factory.DeferredAuthorityFactory.isAvailable(DeferredAuthorityFactory.java:126)
    at org.geotools.factory.FactoryRegistry.isAvailable(FactoryRegistry.java:681)
    at org.geotools.factory.FactoryRegistry.isAcceptable(FactoryRegistry.java:513)
    at org.geotools.factory.FactoryRegistry.getServiceImplementation(FactoryRegistry.java:447)
    at org.geotools.factory.FactoryRegistry.getServiceProvider(FactoryRegistry.java:376)
    at org.geotools.factory.FactoryCreator.getServiceProvider(FactoryCreator.java:137)
    at org.geotools.referencing.ReferencingFactoryFinder.getAuthorityFactory(ReferencingFactoryFinder.java:216)
    at org.geotools.referencing.ReferencingFactoryFinder.getCRSAuthorityFactory(ReferencingFactoryFinder.java:437)
    at org.geotools.referencing.factory.epsg.LongitudeFirstFactory.createBackingStore(LongitudeFirstFactory.java:188)
    at org.geotools.referencing.factory.DeferredAuthorityFactory.getBackingStore(DeferredAuthorityFactory.java:138)
    at org.geotools.referencing.factory.BufferedAuthorityFactory.isAvailable(BufferedAuthorityFactory.java:232)
    at org.geotools.referencing.factory.DeferredAuthorityFactory.isAvailable(DeferredAuthorityFactory.java:126)
    at org.geotools.factory.FactoryRegistry.isAvailable(FactoryRegistry.java:681)
    at org.geotools.factory.FactoryRegistry.isAcceptable(FactoryRegistry.java:513)
    at org.geotools.factory.FactoryRegistry.getServiceImplementation(FactoryRegistry.java:447)
    at org.geotools.factory.FactoryRegistry.getServiceProvider(FactoryRegistry.java:376)
    at org.geotools.factory.FactoryCreator.getServiceProvider(FactoryCreator.java:137)
    at org.geotools.referencing.ReferencingFactoryFinder.getAuthorityFactory(ReferencingFactoryFinder.java:216)
    at org.geotools.referencing.ReferencingFactoryFinder.getCoordinateOperationAuthorityFactory(ReferencingFactoryFinder.java:472)
    at org.geotools.referencing.operation.AuthorityBackedFactory.getAuthorityFactory(AuthorityBackedFactory.java:167)
    at org.geotools.referencing.operation.AuthorityBackedFactory.isAvailable(AuthorityBackedFactory.java:444)
    at org.geotools.factory.FactoryRegistry.isAvailable(FactoryRegistry.java:681)
    at org.geotools.factory.FactoryRegistry.isAcceptable(FactoryRegistry.java:513)
    at org.geotools.factory.FactoryCreator.getServiceProvider(FactoryCreator.java:213)
    at org.geotools.referencing.ReferencingFactoryFinder.getFactory(ReferencingFactoryFinder.java:192)
    at org.geotools.referencing.ReferencingFactoryFinder.getCoordinateOperationFactory(ReferencingFactoryFinder.java:319)
    at org.geotools.referencing.operation.BufferedCoordinateOperationFactory.getBackingFactory(BufferedCoordinateOperationFactory.java:204)
    at org.geotools.referencing.operation.BufferedCoordinateOperationFactory.<init>(BufferedCoordinateOperationFactory.java:163)
    at org.geotools.referencing.operation.BufferedCoordinateOperationFactory.<init>(BufferedCoordinateOperationFactory.java:151)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
    at org.geotools.factory.FactoryCreator.createServiceProvider(FactoryCreator.java:279)
    at org.geotools.factory.FactoryCreator.createSafe(FactoryCreator.java:247)
    at org.geotools.factory.FactoryCreator.getServiceProvider(FactoryCreator.java:198)
    at org.geotools.referencing.ReferencingFactoryFinder.getFactory(ReferencingFactoryFinder.java:192)
    at org.geotools.referencing.ReferencingFactoryFinder.getCoordinateOperationFactory(ReferencingFactoryFinder.java:319)
    at ravegeo.crs.impl.CrsManagerImpl.<init>(SourceFile:58)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    ...
    at org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:4690)
    at com.sun.enterprise.web.WebModule.contextListenerStart(WebModule.java:534)
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:5305)
    at com.sun.enterprise.web.WebModule.start(WebModule.java:500)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:917)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:901)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:755)
    at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1980)
    at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1630)
    at com.sun.enterprise.web.WebApplication.start(WebApplication.java:100)
    at org.glassfish.internal.data.EngineRef.start(EngineRef.java:130)
    at org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:269)
    at org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:286)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:461)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:240)
    at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:370)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:355)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:370)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1067)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1200(CommandRunnerImpl.java:96)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1247)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1235)
    at org.glassfish.admingui.common.util.LocalDeploymentFacility$LocalDFCommandRunner.run(LocalDeploymentFacility.java:143)
    at org.glassfish.deployment.client.AbstractDeploymentFacility.deploy(AbstractDeploymentFacility.java:406)
    at org.glassfish.admingui.common.util.DeployUtil.invokeDeploymentFacility(DeployUtil.java:100)
    at org.glassfish.admingui.common.handlers.DeploymentHandler.redeploy(DeploymentHandler.java:259)
    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 com.sun.jsftemplating.layout.descriptors.handler.Handler.invoke(Handler.java:442)
    at com.sun.jsftemplating.layout.descriptors.LayoutElementBase.dispatchHandlers(LayoutElementBase.java:420)
    at com.sun.jsftemplating.layout.descriptors.LayoutElementBase.dispatchHandlers(LayoutElementBase.java:394)
    at com.sun.jsftemplating.layout.event.CommandActionListener.invokeCommandHandlers(CommandActionListener.java:150)
    at com.sun.jsftemplating.layout.event.CommandActionListener.processAction(CommandActionListener.java:98)
    at javax.faces.event.ActionEvent.processListener(ActionEvent.java:88)
    at javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:769)
    at javax.faces.component.UICommand.broadcast(UICommand.java:300)
    at com.sun.webui.jsf.component.WebuiCommand.broadcast(WebuiCommand.java:166)
    at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:794)
    at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1259)
    at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
    at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:409)
    at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1534)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:343)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:215)
    at com.sun.webui.jsf.util.UploadFilter.doFilter(UploadFilter.java:223)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:215)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
    at org.apache.catalina.core.StandardPipeline.doChainInvoke(StandardPipeline.java:600)
    at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:96)
    at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:91)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:162)
    at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:326)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:227)
    at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:228)
    at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:822)
    at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:719)
    at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1013)
    at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
    at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
    at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
    at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
    at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
    at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
    at java.lang.Thread.run(Thread.java:662)
Caused by: java.sql.SQLException: Failed to get the data source for name "jdbc/EPSG".
    at org.geotools.referencing.factory.epsg.ThreadedEpsgFactory.createDataSource(ThreadedEpsgFactory.java:313)
    at org.geotools.referencing.factory.epsg.ThreadedEpsgFactory.createBackingStore0(ThreadedEpsgFactory.java:384)
    at org.geotools.referencing.factory.epsg.ThreadedEpsgFactory.createBackingStore(ThreadedEpsgFactory.java:476)
    ... 137 more
Caused by: javax.naming.NamingException: Lookup failed for 'jdbc/EPSG' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming} [Root exception is javax.naming.NameNotFoundException: EPSG not found]
    at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:518)
    at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:455)
    at javax.naming.InitialContext.lookup(InitialContext.java:392)
    at javax.naming.InitialContext.lookup(InitialContext.java:392)
    at org.geotools.referencing.factory.epsg.ThreadedEpsgFactory.createDataSource(ThreadedEpsgFactory.java:306)
    ... 139 more
Caused by: javax.naming.NameNotFoundException: EPSG not found
    at com.sun.enterprise.naming.impl.TransientContext.doLookup(TransientContext.java:248)
    at com.sun.enterprise.naming.impl.TransientContext.lookup(TransientContext.java:215)
    at com.sun.enterprise.naming.impl.TransientContext.lookup(TransientContext.java:219)
    at com.sun.enterprise.naming.impl.SerialContextProviderImpl.lookup(SerialContextProviderImpl.java:77)
    at com.sun.enterprise.naming.impl.LocalSerialContextProviderImpl.lookup(LocalSerialContextProviderImpl.java:119)
    at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:505)
    ... 143 more

I found a similar problem discussed here: http://osgeo-org.1803224.n2.nabble.com/Authority-EPSG-is-unknown-or-doesn-t-match-the-supplied-hints-td5650827.html. However I didnt find the solution. One thought is to upgrade to newer geotools.

Anyone ever faced the same problem? Any suggestions? Thanks!

Zhenya
  • 53
  • 2
  • 8

2 Answers2

2

I found this answer on another website :

"Hi Guys:

That error usually appears when you dump all the geotools jars into the mix; you can only have one epsg jar on your classpath; I recommend epsg-hsql - as the other ones you need to supply some connection parameters (or a JNDI binding in your application container) for them to function. "

davgut
  • 624
  • 6
  • 7
1

GeoTools uses the Java Service Provider Interface (SPI) plugin system that depends on look at the META_INF/services directory inside each jar.

So you have two things to check:

1) check that you have one epsg jar in your application.

Depending on the implementation you choose:

  • The jars will contain a copy of the epsg database and may require additional permissons to unpack the database into a temp folder). Examples are epsg-hsql
  • the jar will try and access an existing database (using JNDI as shown in your stack trace). This is useful if you have loaded the epsg database into oracle or something.

2) check your application server permissions to ensure it is not getting in the way of the SPI plugin system

For more information:

Jody Garnett
  • 503
  • 3
  • 10