3 Replies Latest reply on Feb 7, 2014 4:07 AM by koen.aers

    Reverse Engineer Entities using customer Hibernate Dialect

    blaine.mincey

      Hi all.

       

      I am attempting to reverse engineer a virtual database from Teiid and generate entities using Forge.  However, when I enter the ‘generate-entities’ command, I get a NoClassFound error for the Teiid Dialect.  Now, I am trying to figure out how to get the Teiid Hibernate Dialect jar file on the class path.  I have tried a couple of different things:  dropping the jar in the <forge home>/lib directory as well as adding it as a module.  However, I am still getting the same error.

       

      Any pointers would be greatly appreciated. 

      Thanks!

      Blaine Mincey

       

      Specifically, this is what I am doing:

       

      $ new-project --named FinancialsWeb --topLevelPackage com.jboss.teiid


      $ persistence setup --provider HIBERNATE --container JBOSS_EAP6


      $ generate-entities --dialect org.teiid.dialect.TeiidDialect --driver org.teiid.jdbc.TeiidDriver --url jdbc:teiid:Financials --pathToDriver /Users/bmincey/RedHat/jdv/jdv6/jboss-eap-6.1/dataVirtualization/jdbc/teiid-8.4.1-redhat-7-jdbc.jar --user user --password user


      This final command throws the following exception which makes sense to me.  I just cannot figure out how to make Forge find the dialect.

       

      org.hibernate.HibernateException: Dialect class not found: org.teiid.dialect.TeiidDialect
      [
      FinancialsWeb] FinancialsWeb $ at org.hibernate.dialect.resolver.DialectFactory.constructDialect(DialectFactory.java:160)
      at org.hibernate.dialect.resolver.DialectFactory.buildDialect(DialectFactory.java:109)
      at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:138)
      at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2163)
      at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2155)
      at org.hibernate.cfg.JDBCMetaDataConfiguration.readFromJDBC(JDBCMetaDataConfiguration.java:41)
      at org.hibernate.forge.generate.GenerateEntitiesPlugin$1.run(GenerateEntitiesPlugin.java:179)
      at org.hibernate.forge.common.UrlClassLoaderExecutor.execute(UrlClassLoaderExecutor.java:13)
      at org.hibernate.forge.generate.GenerateEntitiesPlugin.doReverseEngineering(GenerateEntitiesPlugin.java:171)
      at org.hibernate.forge.generate.GenerateEntitiesPlugin.generateEntities(GenerateEntitiesPlugin.java:78)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:606)
      at org.jboss.forge.shell.command.Execution.perform(Execution.java:160)
      at org.jboss.forge.shell.command.fshparser.FSHRuntime.run(FSHRuntime.java:109)
      at org.jboss.forge.shell.command.fshparser.FSHRuntime.run(FSHRuntime.java:47)
      at org.jboss.forge.shell.ShellImpl$ExecutorThread.run(ShellImpl.java:796)
      at org.jboss.forge.shell.ShellImpl.execute(ShellImpl.java:819)
      at org.jboss.forge.shell.ShellImpl.doShell(ShellImpl.java:609)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:606)
      at org.jboss.weld.bean.proxy.AbstractBeanInstance.invoke(AbstractBeanInstance.java:48)
      at org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:125)
      at org.jboss.forge.shell.ShellImpl$Proxy$_$$_WeldClientProxy.doShell(ShellImpl$Proxy$_$$_WeldClientProxy.java)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:606)
      at org.jboss.weld.util.reflection.SecureReflections$13.work(SecureReflections.java:305)
      at org.jboss.weld.util.reflection.SecureReflectionAccess.run(SecureReflectionAccess.java:54)
      at org.jboss.weld.util.reflection.SecureReflectionAccess.runAsInvocation(SecureReflectionAccess.java:163)
      at org.jboss.weld.util.reflection.SecureReflections.invoke(SecureReflections.java:299)
      at org.jboss.weld.introspector.jlr.WeldMethodImpl.invokeOnInstance(WeldMethodImpl.java:188)
      at org.jboss.weld.introspector.ForwardingWeldMethod.invokeOnInstance(ForwardingWeldMethod.java:59)
      at org.jboss.weld.injection.MethodInjectionPoint.invokeOnInstanceWithSpecialValue(MethodInjectionPoint.java:198)
      at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:282)
      at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:265)
      at org.jboss.weld.event.ObserverMethodImpl.notify(ObserverMethodImpl.java:234)
      at org.jboss.weld.manager.BeanManagerImpl.notifyObservers(BeanManagerImpl.java:635)
      at org.jboss.weld.manager.BeanManagerImpl.fireEvent(BeanManagerImpl.java:622)
      at org.jboss.weld.manager.BeanManagerImpl.fireEvent(BeanManagerImpl.java:616)
      at org.jboss.forge.shell.Bootstrap$1.run(Bootstrap.java:186)
      at java.lang.Thread.run(Thread.java:744)
      Caused by: java.lang.ClassNotFoundException: org.teiid.dialect.TeiidDialect from [Module "org.jboss.hibernate.forge.hibernate-tools-plugin:1.2.0-SNAPSHOT-aa91c2fc-bbc0-4865-b3a7-17aee99fd144" from local module loader @6744719c (roots: /Users/bmincey/Java/forge-distribution-1.4.4.Final/modules,/Users/bmincey/.forge/plugins,/Users/bmincey/RedHat/jbds/jbds7.1/studio/plugins/org.jboss.tools.forge.runtime.ext_1.2.1.Final-v20131205-0921-B140/modules)]
      at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190)
      at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468)
      at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456)
      at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)
      at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120)
      at java.lang.Class.forName0(Native Method)
      at java.lang.Class.forName(Class.java:190)
      at org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:192)
      at org.hibernate.dialect.resolver.DialectFactory.constructDialect(DialectFactory.java:157)

      ... 45 more


        • 1. Re: Reverse Engineer Entities using customer Hibernate Dialect
          koen.aers

          Hi Blaine,

           

          When the Forge plugin generates entities, the jar with the JDBC driver is dynamically added to a new class loader that is used for that task. Since the Teiid dialect is probably not in the standard Hibernate distribution, you would need to also add this dialect to this class loader. I have never tried such a scenario but I think that you could do what you want to do by repackaging the jar containing the JDBC driver and adding the Teiid dialect related classes to this new jar.

           

          Let us know if this works.

           

          Cheers,

          Koen

          • 2. Re: Reverse Engineer Entities using customer Hibernate Dialect
            blaine.mincey

            Hi Koen.

             

            Thanks for the reply.  I did as you suggested and added the dialect to the Teiid JDBC driver JAR and it appears to have found it.  However, now I am getting the following exception.  I am not sure if this is something to do with Hibernate or the Teiid Dialect class.  Do you have any ideas?  For what it is worth, you at least helped me figure out my ClassNotFoundException and thanks for that!

             

            ***ERROR*** An unexpected error happened during reverse engineering.

            java.lang.NoSuchFieldError: INSTANCE

              at org.teiid.dialect.TeiidDialect.<clinit>(TeiidDialect.java:38)

              at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

              at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)

              at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)

              at java.lang.reflect.Constructor.newInstance(Constructor.java:526)

              at java.lang.Class.newInstance(Class.java:374)

              at org.hibernate.dialect.resolver.DialectFactory.constructDialect(DialectFactory.java:157)

              at org.hibernate.dialect.resolver.DialectFactory.buildDialect(DialectFactory.java:109)

              at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:138)

              at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2163)

              at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2155)

              at org.hibernate.cfg.JDBCMetaDataConfiguration.readFromJDBC(JDBCMetaDataConfiguration.java:41)

              at org.hibernate.forge.generate.GenerateEntitiesPlugin$1.run(GenerateEntitiesPlugin.java:179)

              at org.hibernate.forge.common.UrlClassLoaderExecutor.execute(UrlClassLoaderExecutor.java:13)

              at org.hibernate.forge.generate.GenerateEntitiesPlugin.doReverseEngineering(GenerateEntitiesPlugin.java:171)

              at org.hibernate.forge.generate.GenerateEntitiesPlugin.generateEntities(GenerateEntitiesPlugin.java:78)

              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

              at java.lang.reflect.Method.invoke(Method.java:606)

              at org.jboss.forge.shell.command.Execution.perform(Execution.java:160)

              at org.jboss.forge.shell.command.fshparser.FSHRuntime.run(FSHRuntime.java:109)

              at org.jboss.forge.shell.command.fshparser.FSHRuntime.run(FSHRuntime.java:47)

              at org.jboss.forge.shell.ShellImpl$ExecutorThread.run(ShellImpl.java:796)

              at org.jboss.forge.shell.ShellImpl.execute(ShellImpl.java:819)

              at org.jboss.forge.shell.ShellImpl.doShell(ShellImpl.java:609)

              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

              at java.lang.reflect.Method.invoke(Method.java:606)

              at org.jboss.weld.bean.proxy.AbstractBeanInstance.invoke(AbstractBeanInstance.java:48)

              at org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:125)

              at org.jboss.forge.shell.ShellImpl$Proxy$_$$_WeldClientProxy.doShell(ShellImpl$Proxy$_$$_WeldClientProxy.java)

              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

              at java.lang.reflect.Method.invoke(Method.java:606)

              at org.jboss.weld.util.reflection.SecureReflections$13.work(SecureReflections.java:305)

              at org.jboss.weld.util.reflection.SecureReflectionAccess.run(SecureReflectionAccess.java:54)

              at org.jboss.weld.util.reflection.SecureReflectionAccess.runAsInvocation(SecureReflectionAccess.java:163)

              at org.jboss.weld.util.reflection.SecureReflections.invoke(SecureReflections.java:299)

              at org.jboss.weld.introspector.jlr.WeldMethodImpl.invokeOnInstance(WeldMethodImpl.java:188)

              at org.jboss.weld.introspector.ForwardingWeldMethod.invokeOnInstance(ForwardingWeldMethod.java:59)

              at org.jboss.weld.injection.MethodInjectionPoint.invokeOnInstanceWithSpecialValue(MethodInjectionPoint.java:198)

              at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:282)

              at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:265)

              at org.jboss.weld.event.ObserverMethodImpl.notify(ObserverMethodImpl.java:234)

              at org.jboss.weld.manager.BeanManagerImpl.notifyObservers(BeanManagerImpl.java:635)

              at org.jboss.weld.manager.BeanManagerImpl.fireEvent(BeanManagerImpl.java:622)

              at org.jboss.weld.manager.BeanManagerImpl.fireEvent(BeanManagerImpl.java:616)

              at org.jboss.forge.shell.Bootstrap$1.run(Bootstrap.java:186)

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

            • 3. Re: Reverse Engineer Entities using customer Hibernate Dialect
              koen.aers

              Hi Blaine,

               

              This looks like the Hibernate version that is used by the reverse engineering plugin is not compatible with the Teiid Dialect you are using. The Hibernate Tools version of the reverse engineering plugin is 3.4.0.CR2 and that is using Hibernate Core 3.5.6-Final.

              The simplest solution seems to me to use a Teiid dialect that is compatible with that version of Hibernate. It seems to me that any Teiid dialect version from 8.1.0 or earlier would work (http://grepcode.com/file/repository.jboss.org/nexus/content/repositories/releases/org.jboss.teiid/teiid-hibernate-dialec…). Any later version uses Hibernate 4.x.

              An alternative but more involved solution would be to rebuild the reverse engineering plugin using Hibernate Tools 4.0.0.CR1 which will also use Hibernate 4.x.

               

              I hope this helps.

               

              Cheers,

              Koen