5 Replies Latest reply on Oct 12, 2011 6:25 AM by Aymen Ben Hmida

    Bug?!! Caused by: java.lang.ClassNotFoundException: org.hibernate.LockOptions

    Aymen Ben Hmida Newbie

      hi all,

       

      i'm trying to query data from my custom revision table using the AuditReader Object but every time got this exception

       

      Exception in thread "main" java.lang.NoClassDefFoundError: org/hibernate/LockOptions

                at org.hibernate.envers.query.impl.AbstractAuditQuery.<init>(AbstractAuditQuery.java:150)

                at org.hibernate.envers.query.impl.RevisionsOfEntityQuery.<init>(RevisionsOfEntityQuery.java:50)

                at org.hibernate.envers.query.AuditQueryCreator.forRevisionsOfEntity(AuditQueryCreator.java:81)

                at Main.main(Main.java:103)

      Caused by: java.lang.ClassNotFoundException: org.hibernate.LockOptions

                at java.net.URLClassLoader$1.run(URLClassLoader.java:202)

                at java.security.AccessController.doPrivileged(Native Method)

                at java.net.URLClassLoader.findClass(URLClassLoader.java:190)

                at java.lang.ClassLoader.loadClass(ClassLoader.java:307)

                at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)

                at java.lang.ClassLoader.loadClass(ClassLoader.java:248)

                ... 4 more

        • 1. Re: Bug?!! Caused by: java.lang.ClassNotFoundException: org.hibernate.LockOptions
          Aymen Ben Hmida Newbie

          i'm using this simple code

           

          HistoryEntity historyEntity = reader.getCurrentRevision(

                                                  HistoryEntity.class, false);

           

           

                              if (historyEntity != null) {

                                        LOGGER.info("USERNAME " + historyEntity.getUsername());

                              }

          ****** the first one is working but the second, the one below throws the exception. Any one has an idea about the issue?

           

                              AuditQuery forRevisionsOfEntity = reader.createQuery()

                                                  .forRevisionsOfEntity(Brand.class, false, false);

                              List resultList = forRevisionsOfEntity.getResultList();

          • 2. Re: Bug?!! Caused by: java.lang.ClassNotFoundException: org.hibernate.LockOptions
            Adam Warski Master

            Maybe you are bundling whole hibernate-core with your app, and you don't have classloader isolation turned on? Which version of JBossAS are you using?

             

            Adam

            • 3. Re: Bug?!! Caused by: java.lang.ClassNotFoundException: org.hibernate.LockOptions
              Aymen Ben Hmida Newbie

              i'm not using any server, it's just a maven project and main class

               

              <dependency>

                                            <groupId>org.hibernate</groupId>

                                            <artifactId>hibernate-envers</artifactId>

                                            <version>3.5.0-Final</version>

                                            <scope>compile</scope>

                                            <exclusions>

                                                      <exclusion>

                                                                <groupId>org.hibernate</groupId>

                                                                <artifactId>hibernate-annotations</artifactId>

                                                      </exclusion>

                                            </exclusions>

                                  </dependency>

                                  <dependency>

                                            <groupId>org.hibernate</groupId>

                                            <artifactId>hibernate-core</artifactId>

                                            <version>3.3.1.GA</version>

                                  </dependency>

                                  <dependency>

                                            <groupId>org.hibernate</groupId>

                                            <artifactId>hibernate-annotations</artifactId>

                                            <version>3.4.0.GA</version>

                                  </dependency>

                                  <dependency>

                                            <groupId>log4j</groupId>

                                            <artifactId>log4j</artifactId>

                                            <version>1.2.16</version>

                                  </dependency>

                                  <dependency>

                                            <groupId>mysql</groupId>

                                            <artifactId>mysql-connector-java</artifactId>

                                            <version>5.1.17</version>

                                  </dependency>

                                  <dependency>

                                            <groupId>commons-collections</groupId>

                                            <artifactId>commons-collections</artifactId>

                                            <version>3.2.1</version>

                                  </dependency>

                                  <dependency>

                                            <groupId>commons-logging</groupId>

                                            <artifactId>commons-logging</artifactId>

                                            <version>1.1.1</version>

                                  </dependency>

                                  <dependency>

                                            <groupId>org.slf4j</groupId>

                                            <artifactId>slf4j-log4j12</artifactId>

                                            <version>1.5.8</version>

                                  </dependency>

                                  <dependency>

                                            <groupId>org.slf4j</groupId>

                                            <artifactId>slf4j-api</artifactId>

                                            <version>1.5.8</version>

                                  </dependency>

                        </dependencies>

                        <repositories>

                                  <repository>

                                            <id>JBOSS_NEXUS</id>

                                            <url>http://repository.jboss.org/nexus/content/groups/public</url>

                                  </repository>

                        </repositories>

                        <build>

                                  <plugins>

                                            <plugin>

                                                      <groupId>org.apache.maven.plugins</groupId>

                                                      <artifactId>maven-compiler-plugin</artifactId>

                                                      <version>2.3.2</version>

                                                      <configuration>

                                                                <source>1.6</source>

                                                                <target>1.6</target>

                                                      </configuration>

                                            </plugin>

                                  </plugins>

                        </build>

              • 4. Re: Bug?!! Caused by: java.lang.ClassNotFoundException: org.hibernate.LockOptions
                Adam Warski Master

                You are mixing hibernate-core and hibernate-envers versions. You have to use the same versions of both dependencies.

                 

                Adam