3 Replies Latest reply on Jun 29, 2016 1:53 PM by Scott Marlow

    how to use hibernate3 with wildfly 9.2

    Himanshu Sharma Newbie

      HI,

       

      I am upgrading my application to widllfy 9.2  . The default hibernate version in wildfly 9.2 is 4.3.x , But I want to use hibernate3 in my application. I made the following change in persistence.xml to enable hibernate3 and copied hibernate3 jars in the lib directory:

       

       

      <?xml version="1.0" encoding="UTF-8"?>

      <persistence xmlns="http://java.sun.com/xml/ns/persistence"

      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

      xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"

      version="1.0">

      <persistence-unit name="ApplicationPersistence" transaction-type="JTA">

      <provider>org.hibernate.ejb.HibernatePersistence</provider>

      <jta-data-source>java:/jdbc/ApplicationDS</jta-data-source>

      <properties>

      <property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect" />

      <property name="hibernate.connection.driver_class" value="org.postgresql.Driver" />

      <property name="hibernate.max_fetch_depth" value="3" />

      <property name="hibernate.cache.provider_class" value="org.hibernate.cache.HashtableCacheProvider" />

      <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.JBossTransactionManagerLookup" />

      <property name="hibernate.jndi.java.naming.factory.initial" value="org.jnp.interfaces.NamingContextFactory" />

      <property name="hibernate.jndi.java.naming.factory.url.pkgs" value="org.jboss.naming:org.jnp.interfaces" />

      <property name="hibernate.bytecode.use_reflection_optimizer" value="false" />

      <property name="hibernate.bytecode.provider" value="javassist" />

      <property name="jboss.as.jpa.providerModule" value="hibernate3-bundled" />

      </properties>

      </persistence-unit>

      </persistence>

       

      But the above approach does not seem to work . I am getting the below error:

      21:25:49,719 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 63) MSC000001: Failed to start service jboss.persistenceunit."application.ear#ApplicationPersistence": org.jboss.msc.service.StartException in service jboss.persistenceunit."application.ear#ApplicationPersistence": java.lang.NoSuchMethodError: org.hibernate.cfg.AnnotationConfiguration.setProperty(Ljava/lang/String;Ljava/lang/String;)Lorg/hibernate/cfg/AnnotationConfiguration;

              at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:172)

              at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:117)

              at org.wildfly.security.manager.WildFlySecurityManager.doChecked(WildFlySecurityManager.java:665)

              at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1.run(PersistenceUnitServiceImpl.java:182)

              at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)

              at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)

              at java.lang.Thread.run(Thread.java:745)

              at org.jboss.threads.JBossThread.run(JBossThread.java:320)

      Caused by: java.lang.NoSuchMethodError: org.hibernate.cfg.AnnotationConfiguration.setProperty(Ljava/lang/String;Ljava/lang/String;)Lorg/hibernate/cfg/AnnotationConfiguration;

              at org.hibernate.ejb.Ejb3Configuration.setProperty(Ejb3Configuration.java:792)

              at org.hibernate.ejb.Ejb3Configuration.setDataSource(Ejb3Configuration.java:175)

              at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:659)

              at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:73)

              at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.createContainerEntityManagerFactory(PersistenceUnitServiceImpl.java:318)

              at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.access$1100(PersistenceUnitServiceImpl.java:67)

              at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:167)

      I checked the hibernate jars in lib and the above method does exist. Can anybody provide some suggestion if any setting is missing?

       

       

      Thanks in advance for your help.