The CLASSPATH still doesn't resolve GeoTools jars as explained in geoscript-py documentation "Usage" page. I was able to get this working once and can't reproduce it in new bash shells. See workflow below for examples of what I'm doing. If i run 'geoscript' from bash everything works fine in interpreter. But if I try to run jython script from bash using 'jython myscript.py' or run 'jython' interpreter, then the 'import geoscript' triggers "Error: Could not find GeoTools libraries on classpath" even though my classpath is set correctly (see workflow below). The only thing that works for resolving geoscript from jython is to use Eclipse 3.5.1 and PyDev plugin. Then I add external jars to project classpath and everything works. But i should be able to mimic the same thing in the jython interpreter using sys.path.append(all geotools jars). This doesn't work (see workflow below).
gerg ## export JYTHON_HOME=/usr/lib/jython
gerg ## export PATH=/$JYTHON_HOME/bin:$PATH
gerg ## export CLASSPATH='geoscript-classpath'
gerg ## sudo chmod ugo+rwx /usr/lib/jython/Lib/site-packages/geoscript-0.6-py2.5.egg/*
gerg ## geoscript
Jython 2.5.1 (Release_2_5_1:6813, Sep 26 2009, 13:47:54)
[Java HotSpot(TM) Client VM (Sun Microsystems Inc.)] on java1.6.0_20
Type "help", "copyright", "credits" or "license" for more information.
import geoscript
from geoscript.layer import Shapefile
shp = Shapefile('/home/gregcorradini/GeoTools/FILTERED/centroid_lots.shp')
Jun 13, 2010 9:22:38 AM org.geotools.factory.FactoryRegistry scanForPlugins
WARNING: Can't load a service for category "MathTransformProvider". Cause is "NoClassDefFoundError: javax/media/jai/WarpAffine".
shp
<geoscript.layer.shapefile.Shapefile object at 0x1>
print "Great. that works"
Great. that works
gerg ##
gerg ##
gerg ##
gerg ##
gerg ##
gerg ##
gerg ##
gerg ## jython
Jython 2.5.1 (Release_2_5_1:6813, Sep 26 2009, 13:47:54)
[Java HotSpot(TM) Client VM (Sun Microsystems Inc.)] on java1.6.0_20
Type "help", "copyright", "credits" or "license" for more information.
import geoscript
Error: Could not find GeoTools libraries on classpath.
gerg ##
gerg ##
gerg ## jython
Jython 2.5.1 (Release_2_5_1:6813, Sep 26 2009, 13:47:54)
[Java HotSpot(TM) Client VM (Sun Microsystems Inc.)] on java1.6.0_20
Type "help", "copyright", "credits" or "license" for more information.
import sys, glob
print "Let's add all jars to sys.path"
Let's add all jars to sys.path
[sys.path.append(i) for i in glob.glob("/usr/lib/jython/Lib/site-packages/geoscript-0.6-py2.5.egg/jars/*.jar")]
[None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None]
sys.path
['', '/usr/lib/jython/Lib/site-packages/setuptools-0.6c11-py2.5.egg', '/usr/lib/jython/Lib/site-packages/geoscript-0.6-py2.5.egg', '/usr/lib/jython/Lib', 'classpath', 'pyclasspath/', '/usr/lib/jython/Lib/site-packages', '/usr/lib/jython/Lib/site-packages/geoscript-0.6-py2.5.egg/jars/commons-collections-3.1.jar', '/usr/lib/jython/Lib/site-packages/geoscript-0.6-py2.5.egg/jars/common-2.2.1.jar', '/usr/lib/jython/Lib/site-packages/geoscript-0.6-py2.5.egg/jars/geodb-0.2.jar', '/usr/lib/jython/Lib/site-packages/geoscript-0.6-py2.5.egg/jars/gt-graph-2.7-SNAPSHOT.jar', '/usr/lib/jython/Lib/site-packages/geoscript-0.6-py2.5.egg/jars/gt-api-2.7-SNAPSHOT.jar', '/usr/lib/jython/Lib/site-packages/geoscript-0.6-py2.5.egg/jars/commons-dbcp-1.2.2.jar', '/usr/lib/jython/Lib/site-packages/geoscript-0.6-py2.5.egg/jars/gt-epsg-hsql-2.7-SNAPSHOT.jar', '/usr/lib/jython/Lib/site-packages/geoscript-0.6-py2.5.egg/jars/gt-jdbc-spatialite-2.7-SNAPSHOT.jar', '/usr/lib/jython/Lib/site-packages/geoscript-0.6-py2.5.egg/jars/gt-jdbc-2.7-SNAPSHOT.jar', '/usr/lib/jython/Lib/site-packages/geoscript-0.6-py2.5.egg/jars/xml-apis-1.0.b2.jar', '/usr/lib/jython/Lib/site-packages/geoscript-0.6-py2.5.egg/jars/ecore-2.2.2.jar', '/usr/lib/jython/Lib/site-packages/geoscript-0.6-py2.5.egg/jars/gt-xsd-ows-2.7-SNAPSHOT.jar', '/usr/lib/jython/Lib/site-packages/geoscript-0.6-py2.5.egg/jars/sqlite-jdbc-3.6.19.1-SNAPSHOT.jar', '/usr/lib/jython/Lib/site-packages/geoscript-0.6-py2.5.egg/jars/jsr-275-1.0-beta-2.jar', '/usr/lib/jython/Lib/site-packages/geoscript-0.6-py2.5.egg/jars/gt-jdbc-h2-2.7-SNAPSHOT.jar', '/usr/lib/jython/Lib/site-packages/geoscript-0.6-py2.5.egg/jars/picocontainer-1.2.jar', '/usr/lib/jython/Lib/site-packages/geoscript-0.6-py2.5.egg/jars/gt-main-2.7-SNAPSHOT.jar', '/usr/lib/jython/Lib/site-packages/geoscript-0.6-py2.5.egg/jars/postgresql-8.4-701.jdbc3.jar', '/usr/lib/jython/Lib/site-packages/geoscript-0.6-py2.5.egg/jars/commons-beanutils-1.7.0.jar', '/usr/lib/jython/Lib/site-packages/geoscript-0.6-py2.5.egg/jars/geoapi-2.3-M1.jar', '/usr/lib/jython/Lib/site-packages/geoscript-0.6-py2.5.egg/jars/jdom-1.0.jar', '/usr/lib/jython/Lib/site-packages/geoscript-0.6-py2.5.egg/jars/gt-xsd-wfs-2.7-SNAPSHOT.jar', '/usr/lib/jython/Lib/site-packages/geoscript-0.6-py2.5.egg/jars/jts-1.10.jar', '/usr/lib/jython/Lib/site-packages/geoscript-0.6-py2.5.egg/jars/gt-jdbc-mysql-2.7-SNAPSHOT.jar', '/usr/lib/jython/Lib/site-packages/geoscript-0.6-py2.5.egg/jars/gt-coverage-2.7-SNAPSHOT.jar', '/usr/lib/jython/Lib/site-packages/geoscript-0.6-py2.5.egg/jars/commons-pool-1.5.3.jar', '/usr/lib/jython/Lib/site-packages/geoscript-0.6-py2.5.egg/jars/gt-shapefile-2.7-SNAPSHOT.jar', '/usr/lib/jython/Lib/site-packages/geoscript-0.6-py2.5.egg/jars/gt-xsd-filter-2.7-SNAPSHOT.jar', '/usr/lib/jython/Lib/site-packages/geoscript-0.6-py2.5.egg/jars/org.w3.xlink-2.7-SNAPSHOT.jar', '/usr/lib/jython/Lib/site-packages/geoscript-0.6-py2.5.egg/jars/gt-cql-2.7-SNAPSHOT.jar', '/usr/lib/jython/Lib/site-packages/geoscript-0.6-py2.5.egg/jars/vecmath-1.3.2.jar', '/usr/lib/jython/Lib/site-packages/geoscript-0.6-py2.5.egg/jars/gt-xsd-core-2.7-SNAPSHOT.jar', '/usr/lib/jython/Lib/site-packages/geoscript-0.6-py2.5.egg/jars/gt-render-2.7-SNAPSHOT.jar', '/usr/lib/jython/Lib/site-packages/geoscript-0.6-py2.5.egg/jars/gt-directory-2.7-SNAPSHOT.jar', '/usr/lib/jython/Lib/site-packages/geoscript-0.6-py2.5.egg/jars/xml-apis-xerces-2.7.1.jar', '/usr/lib/jython/Lib/site-packages/geoscript-0.6-py2.5.egg/jars/net.opengis.wfs-2.7-SNAPSHOT.jar', '/usr/lib/jython/Lib/site-packages/geoscript-0.6-py2.5.egg/jars/gt-xsd-gml2-2.7-SNAPSHOT.jar', '/usr/lib/jython/Lib/site-packages/geoscript-0.6-py2.5.egg/jars/xercesImpl-2.7.1.jar', '/usr/lib/jython/Lib/site-packages/geoscript-0.6-py2.5.egg/jars/commons-logging-1.0.3.jar', '/usr/lib/jython/Lib/site-packages/geoscript-0.6-py2.5.egg/jars/mysql-connector-java-5.1.5.jar', '/usr/lib/jython/Lib/site-packages/geoscript-0.6-py2.5.egg/jars/xsd-2.2.2.jar', '/usr/lib/jython/Lib/site-packages/geoscript-0.6-py2.5.egg/jars/gt-data-2.7-SNAPSHOT.jar', '/usr/lib/jython/Lib/site-packages/geoscript-0.6-py2.5.egg/jars/gt-metadata-2.7-SNAPSHOT.jar', '/usr/lib/jython/Lib/site-packages/geoscript-0.6-py2.5.egg/jars/net.opengis.ows-2.7-SNAPSHOT.jar', '/usr/lib/jython/Lib/site-packages/geoscript-0.6-py2.5.egg/jars/ant-optional-1.5.1.jar', '/usr/lib/jython/Lib/site-packages/geoscript-0.6-py2.5.egg/jars/geoapi-pending-2.3-M1.jar', '/usr/lib/jython/Lib/site-packages/geoscript-0.6-py2.5.egg/jars/h2-1.1.104.jar', '/usr/lib/jython/Lib/site-packages/geoscript-0.6-py2.5.egg/jars/hatbox-1.0.b6.jar', '/usr/lib/jython/Lib/site-packages/geoscript-0.6-py2.5.egg/jars/gt-xsd-gml3-2.7-SNAPSHOT.jar', '/usr/lib/jython/Lib/site-packages/geoscript-0.6-py2.5.egg/jars/commons-jxpath-1.2.jar', '/usr/lib/jython/Lib/site-packages/geoscript-0.6-py2.5.egg/jars/gt-referencing-2.7-SNAPSHOT.jar', '/usr/lib/jython/Lib/site-packages/geoscript-0.6-py2.5.egg/jars/hsqldb-1.8.0.7.jar', '/usr/lib/jython/Lib/site-packages/geoscript-0.6-py2.5.egg/jars/gt-jdbc-postgis-2.7-SNAPSHOT.jar']
import geoscript
from geoscript.layer import Shapefile
shp = Shapefile('/home/gregcorradini/GeoTools/FILTERED/centroid_lots.shp')
Traceback (most recent call last):
File "", line 1, in
File "/usr/lib/jython/Lib/site-packages/geoscript-0.6-py2.5.egg/geoscript/layer/shapefile.py", line 21, in init
Layer.init(self, name, Directory(f.canonicalFile.parent))
File "/usr/lib/jython/Lib/site-packages/geoscript-0.6-py2.5.egg/geoscript/workspace/directory.py", line 21, in init
Workspace.init(self, DirectoryDataStoreFactory(), params)
File "/usr/lib/jython/Lib/site-packages/geoscript-0.6-py2.5.egg/geoscript/workspace/workspace.py", line 22, in init
self.ds = factory.createDataStore(params)
at org.geotools.data.directory.DirectoryDataStoreFactory.canProcess(DirectoryDataStoreFactory.java:91)
at org.geotools.data.directory.DirectoryDataStoreFactory.createDataStore(DirectoryDataStoreFactory.java:52)
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)
java.lang.ExceptionInInitializerError: java.lang.ExceptionInInitializerError