'Bad type on operand stack error when using hibernate

I am getting an error when using the hibernate. This is the stack trace:-

java.lang.VerifyError: Bad type on operand stack
Exception Details:
  Location:
    org/hibernate/type/BasicTypeRegistry.<init>()V @406: invokespecial
  Reason:
    Type 'org/hibernate/type/DateType' (current frame, stack[3]) is not assignable to 'org/hibernate/type/AbstractStandardBasicType'
  Current Frame:
    bci: @406
    flags: { }
    locals: { 'org/hibernate/type/BasicTypeRegistry' }
    stack: { 'org/hibernate/type/BasicTypeRegistry', uninitialized 399, uninitialized 399, 'org/hibernate/type/DateType' }
  Bytecode:
    0x0000000: 2ab7 0003 2abb 0004 5910 6412 0504 b700
    0x0000010: 06b5 0007 2ab2 0008 b600 092a b200 0ab6
    0x0000020: 0009 2ab2 000b b600 092a b200 0cb6 0009
    0x0000030: 2ab2 000d b600 092a b200 0eb6 0009 2ab2
    0x0000040: 000f b600 092a b200 10b6 0009 2ab2 0011
    0x0000050: b600 092a b200 12b6 0009 2ab2 0013 b600
    0x0000060: 092a b200 14b6 0009 2ab2 0015 b600 092a
    0x0000070: b200 16b6 0009 2ab2 0017 b600 092a b200
    0x0000080: 18b6 0009 2ab2 0019 b600 092a b200 1ab6
    0x0000090: 0009 2ab2 001b b600 092a b200 1cb6 0009
    0x00000a0: 2ab2 001d b600 092a b200 1eb6 0009 2ab2
    0x00000b0: 001f b600 092a b200 20b6 0009 2ab2 0021
    0x00000c0: b600 092a b200 22b6 0009 2ab2 0023 b600
    0x00000d0: 092a b200 24b6 0009 2ab2 0025 b600 092a
    0x00000e0: b200 26b6 0009 2ab2 0027 b600 092a b200
    0x00000f0: 28b6 0009 2ab2 0029 b600 092a b200 2ab6
    0x0000100: 0009 2ab2 002b b600 092a b200 2cb6 0009
    0x0000110: 2ab2 002d b600 092a b200 2eb6 0009 2ab2
    0x0000120: 002f b600 092a b200 30b6 0009 2ab2 0031
    0x0000130: b600 092a b200 32b6 0009 2ab2 0033 b600
    0x0000140: 092a b200 34b6 0009 2ab2 0035 b600 092a
    0x0000150: b200 36b6 0009 2ab2 0037 b600 092a b200
    0x0000160: 38b6 0009 2ab2 0039 b600 092a b200 3ab6
    0x0000170: 0009 2ab2 003b b600 092a b200 3cb6 0009
    0x0000180: 2ab2 003d b600 092a b200 3eb6 0009 2abb
    0x0000190: 003f 59b2 0022 b700 40b6 0009 2abb 003f
    0x00001a0: 59b2 0023 b700 40b6 0009 2abb 003f 59b2
    0x00001b0: 0024 b700 40b6 0009 2abb 003f 59b2 0025
    0x00001c0: b700 40b6 0009 2abb 003f 59b2 0026 b700
    0x00001d0: 40b6 0009 2abb 003f 59b2 0027 b700 40b6
    0x00001e0: 0009 2abb 003f 59b2 002f b700 40b6 0009
    0x00001f0: 2abb 003f 59b2 003d b700 40b6 0009 b1  

    org.hibernate.type.spi.TypeConfiguration.<init>(TypeConfiguration.java:88)
    org.hibernate.boot.internal.BootstrapContextImpl.<init>(BootstrapContextImpl.java:112)
    org.hibernate.boot.internal.MetadataBuilderImpl.<init>(MetadataBuilderImpl.java:123)
    org.hibernate.boot.internal.MetadataBuilderImpl.<init>(MetadataBuilderImpl.java:92)
    org.hibernate.boot.MetadataSources.getMetadataBuilder(MetadataSources.java:129)
    org.hibernate.boot.MetadataSources.buildMetadata(MetadataSources.java:185)
    com.sliit.musicstore.utils.HibernateUtil.getSessionFactory(HibernateUtil.java:58)
    com.sliit.musicstore.utils.HibernateUtil.openCurrentSession(HibernateUtil.java:23)
    com.sliit.musicstore.dao.UserDAO.findByEmail(UserDAO.java:13)
    com.sliit.musicstore.services.UserService.login(UserService.java:27)
    com.sliit.musicstore.controllers.UserLoginController.doPost(UserLoginController.java:35)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:660)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)

This is my getSessionFactory Method:-

 protected static SessionFactory getSessionFactory() {
        final StandardServiceRegistry registry = new StandardServiceRegistryBuilder()
                .configure()
                .build();

        return new MetadataSources( registry )
            .buildMetadata()
            .buildSessionFactory();
    }

This is the maven dependency tree:-

[INFO] com.sliit.musicstore:musicstore:war:1.0-SNAPSHOT
[INFO] +- junit:junit:jar:3.8.1:test
[INFO] +- javax.servlet:javax.servlet-api:jar:3.1.0:compile
[INFO] +- mysql:mysql-connector-java:jar:8.0.19:compile
[INFO] |  \- com.google.protobuf:protobuf-java:jar:3.6.1:compile
[INFO] +- org.hibernate.orm:hibernate-core:jar:6.0.0.Alpha5:compile
[INFO] |  +- org.jboss.logging:jboss-logging:jar:3.3.2.Final:compile
[INFO] |  +- javax.persistence:javax.persistence-api:jar:2.2:compile
[INFO] |  +- org.javassist:javassist:jar:3.24.0-GA:compile
[INFO] |  +- net.bytebuddy:byte-buddy:jar:1.10.7:compile
[INFO] |  +- org.antlr:antlr4:jar:4.8-1:compile
[INFO] |  |  +- org.antlr:antlr4-runtime:jar:4.8-1:compile
[INFO] |  |  +- org.antlr:antlr-runtime:jar:3.5.2:compile
[INFO] |  |  +- org.antlr:ST4:jar:4.3:compile
[INFO] |  |  +- org.abego.treelayout:org.abego.treelayout.core:jar:1.0.3:compile
[INFO] |  |  +- org.glassfish:javax.json:jar:1.0.4:compile
[INFO] |  |  \- com.ibm.icu:icu4j:jar:61.1:compile
[INFO] |  +- org.jboss.spec.javax.transaction:jboss-transaction-api_1.2_spec:jar:1.1.1.Final:compile
[INFO] |  +- org.jboss:jandex:jar:2.1.1.Final:compile
[INFO] |  +- com.fasterxml:classmate:jar:1.5.1:compile
[INFO] |  +- javax.activation:javax.activation-api:jar:1.2.0:compile
[INFO] |  +- org.dom4j:dom4j:jar:2.1.3:compile
[INFO] |  +- javax.xml.bind:jaxb-api:jar:2.3.1:compile
[INFO] |  \- org.glassfish.jaxb:jaxb-runtime:jar:2.3.1:compile
[INFO] |     +- org.glassfish.jaxb:txw2:jar:2.3.1:compile
[INFO] |     +- com.sun.istack:istack-commons-runtime:jar:3.0.7:compile
[INFO] |     +- org.jvnet.staxex:stax-ex:jar:1.8:compile
[INFO] |     \- com.sun.xml.fastinfoset:FastInfoset:jar:1.2.15:compile
[INFO] +- org.hibernate.common:hibernate-commons-annotations:jar:5.1.0.Final:compile
[INFO] +- javax.transaction:jta:jar:1.1:compile
[INFO] \- javax.servlet:jstl:jar:1.2:compile

I have googled it. But no luck. After that I have browsed the source code of the hibernate repository. They have already extended the DateType to AbstractStandardBasicType.

How to solve this issue?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source