6 Replies Latest reply on Oct 11, 2012 4:16 PM by rodrigo viana

    Custom Hibernate Dialect - Jboss 7.1

    rathm1 Newbie

      Hi there,

      We are in the process of moving our application from Jboss 6 to Jboss7.1.

      We are using hibernate and DB2 and have created a Custom DB2 Dialect by extending org.hibernate.DB2Dialect.

      Our Custom DB2 Dialect is inside a jar that is inside our ear. 

      We define the hibernate.cfg.xml to use the custom dialect

       

      <property name="hibernate.dialect">myApp.custom.CustomDB2Dialect</property>

       

      The ear deploys successfully but when trying to launch the application and build the SessionFactory, it seems as though hibernate cannot access our Custom Dialect inside the ear.

      We have a dependency set up in our MANIFEST.MF on

      Dependencies: org.hibernate, org.hibernate.envers, org.javassist, javaee.api, org.apache.commons.lang

       

      My question is, how can I add a dependency to hibernate for our CustomDialect class?

       

      The stacktrace of the error thrown is:

      ...

      Caused by: org.hibernate.HibernateException: Dialect class not found: myApp.custom.CustomDB2Dialect

          at org.hibernate.service.jdbc.dialect.internal.DialectFactoryImpl.constructDialect(DialectFactoryImpl.java:76) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

          at org.hibernate.service.jdbc.dialect.internal.DialectFactoryImpl.buildDialect(DialectFactoryImpl.java:64) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

          at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:148) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

          at org.hibernate.service.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:75) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

          at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:159) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

          at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:131) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

          at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:71) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

          at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2270) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

          at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2266) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

          at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1735) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

          at myApp.custom.Utility.<clinit>(Utility.java:35) [myApp.jar:]

          ... 50 more

      Caused by: org.hibernate.service.classloading.spi.ClassLoadingException: Unable to load class [myApp.custom.CustomDB2Dialect]

          at org.hibernate.service.classloading.internal.ClassLoaderServiceImpl.classForName(ClassLoaderServiceImpl.java:141) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

          at org.hibernate.service.jdbc.dialect.internal.DialectFactoryImpl.constructDialect(DialectFactoryImpl.java:73) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

          ... 60 more

      Caused by: java.lang.ClassNotFoundException: Could not load requested class : myApp.custom.CustomDB2Dialect

          at org.hibernate.service.classloading.internal.ClassLoaderServiceImpl$1.findClass(ClassLoaderServiceImpl.java:99) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

          at java.lang.ClassLoader.loadClass(ClassLoader.java:306) [rt.jar:1.6.0_26]

          at java.lang.ClassLoader.loadClass(ClassLoader.java:247) [rt.jar:1.6.0_26]

          at org.hibernate.service.classloading.internal.ClassLoaderServiceImpl.classForName(ClassLoaderServiceImpl.java:138) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

          ... 61 more

       

      Thanks a lot.