Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I try to setup an Java Application with Hibernate and PostGIS but I always get nasty exceptions like :

java.lang.NoSuchMethodError: org.hibernate.type.CustomType.<init>
  (Lorg/hibernate/usertype/UserType;[Ljava/lang/String;)V ....

After looking around I got the impression that the PostGIS JDBC driver is not compatible with Hibernate, which would be strange.

I'm using :

  • hibernate-spatial 1.1.1
  • PostGIS JDBC 2.0 (the link for 2.1 is dead ...)
  • postgresql-8.4-702.jdbc4
  • Hibernate 3.2.5

The table I try to map is

CREATE TABLE "cRef" (
    "id" SERIAL NOT NULL,
    "contenttype" varchar(200),
    "contentid" varchar(200) NOT NULL,
  PRIMARY KEY("id")
);
SELECT AddGeometryColumn ('cRef','geom',4326,'POINT',2);

from my hibernate.cfg.xml:

<hibernate-configuration>
    <session-factory>
        <property name="hibernate.dialect">org.hibernatespatial.postgis.PostgisDialect
        </property>

and my classpath contains:

hibernate-spatial-1.1.1.jar and 
hibernate-spatial-postgis-1.1.1.jar

Can anyone recommend me a working setup? Or give me some hints, how to get this setup running?

Best Regards

Andreas

The complete stacktrace:

java.lang.NoSuchMethodError: org.hibernate.type.CustomType.<init>(Lorg/hibernate/usertype/UserType;[Ljava/lang/String;)V
    at org.hibernatespatial.postgis.PostgisDialect.<clinit>(PostgisDialect.java:51)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
    at java.lang.Class.newInstance0(Class.java:372)
    at java.lang.Class.newInstance(Class.java:325)
    at org.hibernate.dialect.DialectFactory.buildDialect(DialectFactory.java:78)
    at org.hibernate.dialect.DialectFactory.buildDialect(DialectFactory.java:42)
    at org.hibernate.cfg.SettingsFactory.determineDialect(SettingsFactory.java:426)
    at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:128)
    at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2005)
    at org.hibernate.cfg.JDBCMetaDataConfiguration.readFromJDBC(JDBCMetaDataConfiguration.java:40)
    at org.netbeans.modules.hibernate.wizards.HibernateCodeGenWizard.generateClasses(HibernateCodeGenWizard.java:338)
    at org.netbeans.modules.hibernate.wizards.HibernateCodeGenWizard.instantiate(HibernateCodeGenWizard.java:442)
    at org.openide.loaders.TemplateWizard$InstantiatingIteratorBridge.instantiate(TemplateWizard.java:1022)
    at org.openide.loaders.TemplateWizard.handleInstantiate(TemplateWizard.java:589)
    at org.openide.loaders.TemplateWizard.instantiateNewObjects(TemplateWizard.java:432)
    at org.openide.loaders.TemplateWizardIterImpl.instantiate(TemplateWizardIterImpl.java:253)
    at org.openide.loaders.TemplateWizardIteratorWrapper$ProgressInstantiatingIterator.instantiate(TemplateWizardIteratorWrapper.java:180)
    at org.openide.WizardDescriptor.callInstantiateOpen(WizardDescriptor.java:1597)
    at org.openide.WizardDescriptor.callInstantiate(WizardDescriptor.java:1541)
    at org.openide.WizardDescriptor.access$2000(WizardDescriptor.java:139)
    at org.openide.WizardDescriptor$Listener$2$1.run(WizardDescriptor.java:2165)
    at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1452)
    at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:2032)
Caused: org.openide.util.RequestProcessor$SlowItem: task failed due to
    at org.openide.util.RequestProcessor.post(RequestProcessor.java:424)
    at org.openide.WizardDescriptor$Listener$2.run(WizardDescriptor.java:2211)
    at org.openide.WizardDescriptor.lazyValidate(WizardDescriptor.java:1516)
    at org.openide.WizardDescriptor.access$1600(WizardDescriptor.java:139)
    at org.openide.WizardDescriptor$Listener.actionPerformed(WizardDescriptor.java:2229)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at org.openide.util.WeakListenerImpl$ProxyListener.invoke(WeakListenerImpl.java:457)
    at $Proxy48.actionPerformed(Unknown Source)
    at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018)
    at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2341)
    at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
    at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
    at java.awt.Component.processMouseEvent(Component.java:6504)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3321)
    at java.awt.Component.processEvent(Component.java:6269)
    at java.awt.Container.processEvent(Container.java:2229)
    at java.awt.Component.dispatchEventImpl(Component.java:4860)
    at java.awt.Container.dispatchEventImpl(Container.java:2287)
    at java.awt.Component.dispatchEvent(Component.java:4686)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4492)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422)
    at java.awt.Container.dispatchEventImpl(Container.java:2273)
    at java.awt.Window.dispatchEventImpl(Window.java:2713)
    at java.awt.Component.dispatchEvent(Component.java:4686)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:707)
    at java.awt.EventQueue.access$000(EventQueue.java:101)
    at java.awt.EventQueue$3.run(EventQueue.java:666)
    at java.awt.EventQueue$3.run(EventQueue.java:664)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
    at java.awt.EventQueue$4.run(EventQueue.java:680)
    at java.awt.EventQueue$4.run(EventQueue.java:678)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:677)
    at org.netbeans.core.TimableEventQueue.dispatchEvent(TimableEventQueue.java:158)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:211)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:121)
    at java.awt.WaitDispatchSupport$2.run(WaitDispatchSupport.java:182)
    at java.awt.WaitDispatchSupport$4.run(WaitDispatchSupport.java:221)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.awt.WaitDispatchSupport.enter(WaitDispatchSupport.java:219)
    at java.awt.Dialog.show(Dialog.java:1072)
    at org.netbeans.core.windows.services.NbPresenter.superShow(NbPresenter.java:1072)
    at org.netbeans.core.windows.services.NbPresenter.doShow(NbPresenter.java:1106)
    at org.netbeans.core.windows.services.NbPresenter.run(NbPresenter.java:1094)
    at org.netbeans.core.windows.services.NbPresenter.run(NbPresenter.java:126)
    at org.openide.util.Mutex.doEventAccess(Mutex.java:1363)
    at org.openide.util.Mutex.readAccess(Mutex.java:273)
    at org.netbeans.core.windows.services.NbPresenter.show(NbPresenter.java:1079)
    at java.awt.Component.show(Component.java:1650)
    at java.awt.Component.setVisible(Component.java:1602)
    at java.awt.Window.setVisible(Window.java:1013)
    at java.awt.Dialog.setVisible(Dialog.java:1003)
    at org.netbeans.core.windows.services.DialogDisplayerImpl$1AWTQuery.showDialog(DialogDisplayerImpl.java:260)
    at org.netbeans.core.windows.services.DialogDisplayerImpl$1AWTQuery.run(DialogDisplayerImpl.java:186)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:251)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:705)
    at java.awt.EventQueue.access$000(EventQueue.java:101)
    at java.awt.EventQueue$3.run(EventQueue.java:666)
    at java.awt.EventQueue$3.run(EventQueue.java:664)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:675)
    at org.netbeans.core.TimableEventQueue.dispatchEvent(TimableEventQueue.java:158)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:211)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:117)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:113)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105)
[catch] at java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
share|improve this question
    
Did you include the postgis provider for hibernate-spatial listed here hibernatespatial.org/download.html –  unicoletti Jun 9 '12 at 7:50
    
Yes, it is in my classpath, I extended the description in the original question –  dodiddone Jun 9 '12 at 12:49
    
Could you include or provide a link to the full exception stacktrace? –  unicoletti Jun 9 '12 at 15:51
    
I just included the stacktrace –  dodiddone Jun 9 '12 at 16:13
add comment

2 Answers 2

I have found a reference to an error similar to yours (that's why I needed the full stacktrace):

http://hibernate-spatial.1140993.n2.nabble.com/bytea-type-instead-of-geometry-tp6304943p6305521.html

and follow the discussion from that point. It seems you have all correct dependencies setup, but maybe in the thread you will find something that I missed.

share|improve this answer
add comment

Here is the full code of hibernate spatial tutorial for Hibernate 3.x. It's based on maven, so dependencies should not be a problem since they were defined as described in tutorial.

Just git clone the repository and update src/main/resources/hibernate.cfg.xml with your database connection info.

To run:

mvn clean compile 
mvn exec:java -Dexec.mainClass="event.EventManager" -Dexec.args="store POINT(10 5)"
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.