Search code examples
usertype

Jadira, Hibernate, and JSR 310 - java.lang.TypeNotPresentException: Type org.threeten.bp.Duration not present


I'm trying to get Jadira, Hibernate 4, and JSR-310 working together and I'm getting a really odd exception that I can't find any info on through scanning the web.

POM elements (related to Jadira/Joda)

<dependency>
   <groupId>joda-time</groupId>
   <artifactId>joda-time</artifactId>
   <version>2.1</version>
</dependency>
<dependency>
    <groupId>org.jadira.usertype</groupId>
    <artifactId>usertype.core</artifactId>
    <version>3.1.0.CR2</version>
</dependency>
<dependency>
    <groupId>org.jadira.usertype</groupId>
    <artifactId>usertype.extended</artifactId>
    <version>3.1.0.CR2</version>
</dependency>
<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-testing</artifactId>
    <version>${hibernate.version}</version>
</dependency>
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-context-support</artifactId>
    <version>${spring.framework.version}</version>
</dependency>
<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-entitymanager</artifactId>
    <version>${hibernate.version}</version>
</dependency>

Here's my test code:

@Entity
@Table(name = "BUSINESS_DATES")
@BizDateValidatorI
public class BizDate {

    @Id
    @Column(name="BIZ_DATE_PK")
    private int bizDatePk = -1;

    @Column(name="BIZ_DATE")
    @Type(type="org.jadira.usertype.dateandtime.joda.jsr310.PersistentLocalDate")   
    @NotNull
    private LocalDate bizDate;

    @Column(name="BIZ_DATE_TYPE")
    @Enumerated(EnumType.STRING)
    @NotNull
    private BizDateTypeEnum bizDateTypeEnum;

    @Column(name="DATE_DESC")
    @NotBlank
    @Length(min = 5, max = 100)
    private String dateDesc;

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

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

<<Omitted getters/setters>>

Application Context:

<description>Application Context for Core Utilities</description>

<tx:annotation-driven transaction-manager="transactionManager" />

<context:component-scan base-package="org.jc.utils" />

<jpa:repositories base-package="org.jc.utils" />

<jdbc:embedded-database id="dataSource" type="H2">
    <jdbc:script location="classpath:/org/jc/utils/basetests/basetests.sql" />
</jdbc:embedded-database>

Does anyone have any idea why I keep getting java.lang.TypeNotPresentException: Type org.threeten.bp.Duration not present exceptions? Threeten isn't getting pulled in by the usertype declaration in Maven and there's not much out there about it's role in usertype.

Thanks!

John


Solution

  • Try after removing the following dependency in POM. It worked for me.

     <dependency>  
           <groupId>org.jadira.usertype</groupId>  
           <artifactId>usertype.extended</artifactId>  
           <version>3.1.0.CR2</version>  
     </dependency>