Hi Zheng,
To decode a CRS code, you need access to the EPSG database, which it
seems it's not present.
* Make sure you add gt-epsg-hsql in your project, and its
depencencies, if any (you could use other EPSG factories as well, but
that's the most usual).
* To see what factories are available, you can iterate through
ReferencingFactoryFinder.getCRSAuthoriyFactories. See if
ThreadedEpsgHsqlFactory is there.
* Better use CRS.decode("EPSG:4326"), which will loop through all
available factories, and is a more compact code.
Hope this helps.
Oscar.
2012/4/16 Zheng Xudong <[email protected]>:
> Hi all,
>
> I employ GeoTools(8.0-M4) in my server code, and I use Tomcat 7 as the
> server application. However the server throws NoSuchAuthorityCodeException
> when I want to get a CRS. My code is just like:
>
> CRSAuthorityFactory crsFactory = CRS.getAuthorityFactory(true);
> CoordinateReferenceSystem crs =
> crsFactory.createCoordinateReferenceSystem("EPSG:4326");
>
> the exceptions information was:
> org.opengis.referencing.NoSuchAuthorityCodeException: No code
> "EPSG:4326" from authority "EPSG" found for object of type "EngineeringCRS".
> at
> org.geotools.referencing.factory.epsg.CartesianAuthorityFactory.noSuchAuthorityException(CartesianAuthorityFactory.java:136)
> at
> org.geotools.referencing.factory.epsg.CartesianAuthorityFactory.createEngineeringCRS(CartesianAuthorityFactory.java:130)
> at
> org.geotools.referencing.factory.epsg.CartesianAuthorityFactory.createCoordinateReferenceSystem(CartesianAuthorityFactory.java:121)
> at
> org.geotools.referencing.factory.AuthorityFactoryAdapter.createCoordinateReferenceSystem(AuthorityFactoryAdapter.java:800)
> at
> org.geotools.referencing.factory.ThreadedAuthorityFactory.createCoordinateReferenceSystem(ThreadedAuthorityFactory.java:731)
> at
> org.geotools.referencing.DefaultAuthorityFactory.createCoordinateReferenceSystem(DefaultAuthorityFactory.java:179)
> at edu.buaa.navigation.MapListener.contextInitialized(MapListener.java:90)
> at
> org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4779)
> at
> org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5273)
> at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
> at
> org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1566)
> at
> org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1556)
> at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
> at java.util.concurrent.FutureTask.run(FutureTask.java:166)
> at
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
> at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
> at java.lang.Thread.run(Thread.java:722)
>
> The strange thing was these code could execute without any problems if I run
> it as a local Java Application, but it failed when I run it on the server. I
> guess something wrong with the way of jar files deployed. I just use Eclipse
> to create a "dynamic web project" and run it on tomcat 7. All needed
> GeoTools library jar files seems deployed in the WEB-INF/lib folder.
>
> Who can tell me why this exception was thrown and how could I solve it?
>
> Thanks in advance.
>
> --
> Zheng Xudong
> State Key Laboratory of Software Development Environment
> School of Computer Science and Engineer, BeiHang University
>
> ------------------------------------------------------------------------------
> For Developers, A Lot Can Happen In A Second.
> Boundary is the first to Know...and Tell You.
> Monitor Your Applications in Ultra-Fine Resolution. Try it FREE!
> http://p.sf.net/sfu/Boundary-d2dvs2
>
> _______________________________________________
> GeoTools-GT2-Users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
>
------------------------------------------------------------------------------
For Developers, A Lot Can Happen In A Second.
Boundary is the first to Know...and Tell You.
Monitor Your Applications in Ultra-Fine Resolution. Try it FREE!
http://p.sf.net/sfu/Boundary-d2dvs2
_______________________________________________
GeoTools-GT2-Users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users