Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AbstractMethodError when using Jadiru Joda/Hibernate persistent user types

I've introduced a "created" column to my user's database of MySQL TIMESTAMP type. I'm attempting to map this to a Joda LocalDateTime using Jadiru's UserType Hibernate mappers. I'm using v2.0 of the UserType classes and I've tried with v 3.6.0 and 3.6.7 of Hibernate. I'm using JDK 1.6. This data access layer is being used as part of a Spring 3 web application.

Here's the relevant bit of my persistence object -

@Column(name = "created")
@Type(type="org.jadira.usertype.dateandtime.joda.PersistentLocalDateTime") 
private LocalDateTime created;

Nothing too complicated, but I get the following exception whenever my UserDAO tries to query the table -

java.lang.AbstractMethodError: org.jadira.usertype.dateandtime.joda.PersistentLocalDateTime.nullSafeGet(Ljava/sql/ResultSet;[Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/Object;
        at org.hibernate.type.CustomType.nullSafeGet(CustomType.java:109)
        at org.hibernate.type.AbstractType.hydrate(AbstractType.java:104)
        at org.hibernate.persister.entity.AbstractEntityPersister.hydrate(AbstractEntityPersister.java:2283)
        at org.hibernate.loader.Loader.loadFromResultSet(Loader.java:1527)
        at org.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:1455)
        at org.hibernate.loader.Loader.getRow(Loader.java:1355)
        at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:611)
        at org.hibernate.loader.Loader.doQuery(Loader.java:829)
        at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:274)
        at org.hibernate.loader.Loader.doList(Loader.java:2533)
        at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2276)
        at org.hibernate.loader.Loader.list(Loader.java:2271)
        at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:452)
        at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:363)
        at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:196)
        at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1268)
        at org.hibernate.impl.QueryImpl.list(QueryImpl.java:102)
        at org.springframework.orm.hibernate3.HibernateTemplate$30.doInHibernate(HibernateTemplate.java:921)
        at org.springframework.orm.hibernate3.HibernateTemplate$30.doInHibernate(HibernateTemplate.java:1)
        at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:406)
        at org.springframework.orm.hibernate3.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:374)
        at org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:912)
        at org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:908)
        at com.vox.dao.UserDAO.getUser(UserDAO.java:27)
        at com.vox.security.DashboardAuthenticationProcessingFilter.successfulAuthentication(DashboardAuthenticationProcessingFilter.java:30)
        at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:218)
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
        at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:105)
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
        at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:79)
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
        at org.springframework.security.web.session.ConcurrentSessionFilter.doFilter(ConcurrentSessionFilter.java:109)
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
        at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:149)
        at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:237)
        at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
        at java.lang.Thread.run(Thread.java:637)

I've tried placing all annotations on the methods instead of fields, but same issue.

I've also tried mapping different column types, like DATE to a LocalDate and TIME to a LocalTIME but each gives a similar error.

Another thing I tried was using a criteria query instead of a template based query. This didn't affect the problem.

I've checked the classpath for duplicate libraries, which there do not appear to be.

Something is clearly wrong with my setup, as the UserType documentation says this should just work. No google hits for this error whatsoever. Please can someone point me in the right direction ?

Thanks,

Dan

like image 267
danw Avatar asked Sep 20 '11 08:09

danw


2 Answers

Not a solution but a pointer/hint: the signature of nullSafeGet looks strange. It should be

public T nullSafeGet(ResultSet resultSet,
                 String[] strings,
                 org.hibernate.engine.spi.SessionImplementor session,
                 Object object)
          throws SQLException

but hibernate calls a nullSafeGet without the SessionImplementor parameter. So the actual CustomType class might define an abstract nullSafeGet method which isn't implemented in the actual implementor PersistentLocalDateTime (which simply implements a method with different parameters)

Maybe your versions of joda and hibernate are not compatible. I'd investigate in that direction again.

like image 88
Andreas Dolk Avatar answered Oct 31 '22 00:10

Andreas Dolk


in reply to "What piece of code did you put inside your pom.xml in order do import the 1.9 version correctly?" by Renato Gama, try

<dependency>
  <groupId>org.jadira.usertype</groupId>
  <artifactId>usertype.jodatime</artifactId>
  <version>1.9.1</version>
</dependency>
like image 33
Tilman Kolks Avatar answered Oct 30 '22 22:10

Tilman Kolks