[postgis-users] Unable to load the class org.postgis.PGbox3d

Greg Ederer greg at ergonosis.com
Thu Feb 7 10:56:04 PST 2008


Hi,

I am running PostgreSQL 8.2.5-3 and PostGIS 1.3.2-1a from kyngchaos.  
Since I could not locate a postgis.jar in these distributions, I grabbed 
the source for PostGIS 1.3.2, and built one.

I am working off of the Hibernate Spatial tutorial at 
http://www.hibernatespatial.org/tutorial.html.  I have switched to 
org.postgis.DriverWrapper with the JDBC connect string 
jdbc:postgresql_postGIS://localhost:5432/testdb.  I am using 
postgresql-8.2-508.jdbc3.jar, and I have confirmed that postgis.jar is 
in my classpath.

I have managed to insert a row into the database, as shown below:

testdb=# select title, astext(loc) from events;
  title   |    astext   
----------+--------------
 My Event | POINT(10 15)
(1 row)

However, when I try to run a query, I get the following stacktrace:

13:18:49,373  INFO Environment:514 - Hibernate 3.2.5
13:18:49,382  INFO Environment:547 - hibernate.properties not found
13:18:49,384  INFO Environment:681 - Bytecode provider name : cglib
13:18:49,387  INFO Environment:598 - using JDK 1.4 java.sql.Timestamp 
handling
13:18:49,439  INFO Configuration:1426 - configuring from resource: 
/hibernate.cfg.xml
13:18:49,439  INFO Configuration:1403 - Configuration resource: 
/hibernate.cfg.xml
13:18:49,535  INFO Configuration:553 - Reading mappings from resource : 
org/earthserve/model/Event.hbm.xml
13:18:49,630  INFO HbmBinder:300 - Mapping class: 
org.earthserve.model.Event -> EVENTS
13:18:49,647  INFO Configuration:1541 - Configured SessionFactory: null
13:18:49,702  INFO HBSpatialExtension:76 - Initializing HBSpatialExtension
13:18:49,706  INFO HBSpatialExtension:95 - Attempting to load Hibernate 
Spatial Provider org.hibernatespatial.postgis.DialectProvider
13:18:49,721  INFO Dialect:152 - Using dialect: 
org.hibernatespatial.postgis.PostgisDialect
13:18:49,732  INFO HBSpatialExtension:140 - Hibernate Spatial 
configured. Using dialect: org.hibernatespatial.postgis.PostgisDialect
13:18:49,739  INFO DriverManagerConnectionProvider:41 - Using Hibernate 
built-in connection pool (not for production use!)
13:18:49,739  INFO DriverManagerConnectionProvider:42 - Hibernate 
connection pool size: 1
13:18:49,739  INFO DriverManagerConnectionProvider:45 - autocommit mode: 
false
13:18:49,746  INFO DriverManagerConnectionProvider:80 - using driver: 
org.postgis.DriverWrapper at URL: 
jdbc:postgresql_postGIS://localhost:5432/testdb
13:18:49,748  INFO DriverManagerConnectionProvider:86 - connection 
properties: {user=postgres, password=****}
13:18:49,834  WARN SettingsFactory:117 - Could not obtain connection 
metadata
org.postgresql.util.PSQLException: Unable to load the class 
org.postgis.PGbox3d responsible for the datatype box3d
    at 
org.postgresql.jdbc2.AbstractJdbc2Connection.initObjectTypes(AbstractJdbc2Connection.java:462)
    at 
org.postgresql.jdbc2.AbstractJdbc2Connection.<init>(AbstractJdbc2Connection.java:136)
    at 
org.postgresql.jdbc3.AbstractJdbc3Connection.<init>(AbstractJdbc3Connection.java:30)
    at org.postgresql.jdbc3.Jdbc3Connection.<init>(Jdbc3Connection.java:24)
    at org.postgresql.Driver.makeConnection(Driver.java:369)
    at org.postgresql.Driver.connect(Driver.java:245)
    at org.postgis.DriverWrapper.connect(DriverWrapper.java:155)
    at java.sql.DriverManager.getConnection(DriverManager.java:525)
    at java.sql.DriverManager.getConnection(DriverManager.java:140)
    at 
org.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:110)
    at 
org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:84)
    at 
org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2009)
    at 
org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1292)
    at org.earthserve.model.HibernateUtil.<clinit>(HibernateUtil.java:16)
    at org.earthserve.model.EventManager.find(EventManager.java:98)
    at org.earthserve.model.EventManager.main(EventManager.java:42)
Caused by: java.lang.ClassNotFoundException: org.postgis.PGbox3d
    at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:316)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:374)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:164)
    at 
org.postgresql.jdbc2.AbstractJdbc2Connection.initObjectTypes(AbstractJdbc2Connection.java:458)
    ... 15 more
13:18:49,846  INFO Dialect:152 - Using dialect: 
org.hibernatespatial.postgis.PostgisDialect
13:18:49,851  INFO TransactionFactoryFactory:31 - Using default 
transaction strategy (direct JDBC transactions)
13:18:49,856  INFO TransactionManagerLookupFactory:33 - No 
TransactionManagerLookup configured (in JTA environment, use of 
read-write or transactional second-level cache is not recommended)
13:18:49,856  INFO SettingsFactory:143 - Automatic flush during 
beforeCompletion(): disabled
13:18:49,857  INFO SettingsFactory:147 - Automatic session close at end 
of transaction: disabled
13:18:49,858  INFO SettingsFactory:162 - Scrollable result sets: disabled
13:18:49,859  INFO SettingsFactory:170 - JDBC3 getGeneratedKeys(): disabled
13:18:49,859  INFO SettingsFactory:178 - Connection release mode: auto
13:18:49,860  INFO SettingsFactory:205 - Default batch fetch size: 1
13:18:49,860  INFO SettingsFactory:209 - Generate SQL with comments: 
disabled
13:18:49,860  INFO SettingsFactory:213 - Order SQL updates by primary 
key: disabled
13:18:49,860  INFO SettingsFactory:217 - Order SQL inserts for batching: 
disabled
13:18:49,860  INFO SettingsFactory:386 - Query translator: 
org.hibernate.hql.ast.ASTQueryTranslatorFactory
13:18:49,865  INFO ASTQueryTranslatorFactory:24 - Using 
ASTQueryTranslatorFactory
13:18:49,865  INFO SettingsFactory:225 - Query language substitutions: {}
13:18:49,866  INFO SettingsFactory:230 - JPA-QL strict compliance: disabled
13:18:49,866  INFO SettingsFactory:235 - Second-level cache: enabled
13:18:49,868  INFO SettingsFactory:239 - Query cache: disabled
13:18:49,868  INFO SettingsFactory:373 - Cache provider: 
org.hibernate.cache.NoCacheProvider
13:18:49,869  INFO SettingsFactory:254 - Optimize cache for minimal 
puts: disabled
13:18:49,869  INFO SettingsFactory:263 - Structured second-level cache 
entries: disabled
13:18:49,873  INFO SettingsFactory:283 - Echoing all SQL to stdout
13:18:49,873  INFO SettingsFactory:290 - Statistics: disabled
13:18:49,874  INFO SettingsFactory:294 - Deleted entity synthetic 
identifier rollback: disabled
13:18:49,874  INFO SettingsFactory:309 - Default entity-mode: pojo
13:18:49,874  INFO SettingsFactory:313 - Named query checking : enabled
13:18:49,904  INFO SessionFactoryImpl:161 - building session factory
13:18:50,147  INFO SessionFactoryObjectFactory:82 - Not binding factory 
to JNDI, no JNDI name configured
13:18:50,240  WARN JDBCExceptionReporter:77 - SQL Error: 0, SQLState: 60000
Exception in thread "main" 13:18:50,241 ERROR JDBCExceptionReporter:78 - 
Unable to load the class org.postgis.PGbox3d responsible for the 
datatype box3d
org.hibernate.exception.GenericJDBCException: Cannot open connection
    at 
org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103)
    at 
org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91)
    at 
org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
    at 
org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:29)
    at 
org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:426)
    at 
org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:144)
    at org.hibernate.jdbc.JDBCContext.connection(JDBCContext.java:119)
    at 
org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:57)
    at 
org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1326)
    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:585)
    at 
org.hibernate.context.ThreadLocalSessionContext$TransactionProtectionWrapper.invoke(ThreadLocalSessionContext.java:301)
    at $Proxy0.beginTransaction(Unknown Source)
    at org.earthserve.model.EventManager.find(EventManager.java:99)
    at org.earthserve.model.EventManager.main(EventManager.java:42)
Caused by: org.postgresql.util.PSQLException: Unable to load the class 
org.postgis.PGbox3d responsible for the datatype box3d
    at 
org.postgresql.jdbc2.AbstractJdbc2Connection.initObjectTypes(AbstractJdbc2Connection.java:462)
    at 
org.postgresql.jdbc2.AbstractJdbc2Connection.<init>(AbstractJdbc2Connection.java:136)
    at 
org.postgresql.jdbc3.AbstractJdbc3Connection.<init>(AbstractJdbc3Connection.java:30)
    at org.postgresql.jdbc3.Jdbc3Connection.<init>(Jdbc3Connection.java:24)
    at org.postgresql.Driver.makeConnection(Driver.java:369)
    at org.postgresql.Driver.connect(Driver.java:245)
    at org.postgis.DriverWrapper.connect(DriverWrapper.java:155)
    at java.sql.DriverManager.getConnection(DriverManager.java:525)
    at java.sql.DriverManager.getConnection(DriverManager.java:140)
    at 
org.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:110)
    at 
org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:423)
    ... 12 more
Caused by: java.lang.ClassNotFoundException: org.postgis.PGbox3d
    at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:316)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:374)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:164)
    at 
org.postgresql.jdbc2.AbstractJdbc2Connection.initObjectTypes(AbstractJdbc2Connection.java:458)
    ... 22 more

Apparently, the classes in postgis.jar are not available to the jdbc driver.

Any suggestions greatly appreciated.

Thanks!

Greg

-- 
| E R G O N O S I S
| Greg Ederer
| Lead Developer
| greg at ergonosis.com
| 360.774.6848
|




More information about the postgis-users mailing list