Hibernate NoSuchFieldError INSTANCE but only with Struts 1?

前端 未结 3 759
野性不改
野性不改 2021-01-07 19:10

I\'m new to Java and Hibernate (being a Rails and C# developer). Anyway, I have a test program that works fine with Hibernate but my actual web app (Struts 1) crashes with:

相关标签:
3条回答
  • 2021-01-07 19:17

    It looks like you have several versions of Hibernate jars in the classpath.

    0 讨论(0)
  • 2021-01-07 19:34

    @axtavt says right. I know you already solved the problem, I post my comments as it might be helpful to other people.

    If you are using maven dependencies, say you already have your own hibernate dependency. And later, another dependency (like org.codehaus.jackson or drools-spring) is added to the pom. It might cause this error because org.codehaus.jackson and drools-spring have their own dependency on a different version hibernate. exclude hibernate when you add org.codehaus.jackson or drools-spring would solve the prob.

    0 讨论(0)
  • 2021-01-07 19:39

    Removing these two dependency worked for me.

       <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-commons-annotations</artifactId>
            <version>3.0.0.ga</version>
            <scope>runtime</scope>
        </dependency>
         <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-annotations</artifactId>
            <version>3.3.0.ga</version>
        </dependency> 
    

    These are my hibernate dependencies.

    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-core</artifactId>
        <version>3.6.3.Final</version>
    </dependency>
    <dependency>
        <groupId>org.javassist</groupId>
        <artifactId>javassist</artifactId>
        <version>3.17.1-GA</version>
    </dependency>
    <dependency>
        <groupId>asm</groupId>
        <artifactId>asm-all</artifactId>
        <version>2.2</version>
    </dependency>
    <dependency>
        <groupId>antlr</groupId>
        <artifactId>antlr</artifactId>
        <version>2.7.7</version>
    </dependency>
    <dependency>
    <groupId>org.hibernate</groupId>
        <artifactId>hibernate-entitymanager</artifactId>
        <version>3.6.3.Final</version>
    </dependency>
    
    0 讨论(0)
提交回复
热议问题