Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Grails Reverse Engineer Database

I'm trying to evaluate Grails as a solution for an upcoming project. There is already a large database in use that won't be modified much if it all. I wan't to reverse engineer the database into GORM domain objects as a starting point.

I found one here http://www.grails.org/plugin/db-reverse-engineer. I got it installed and configured however when I run it I see the same error over and over. The stacktrace is below.

Can someone help me correct the error, or recommend another tool for reverse engineering to grails? I've used Netbeans in the past to reverse engineer databases to JPA entities that worked out pretty well. I'm hoping for something similar with Grails.

| Error Error executing script DbReverseEngineer: javax/transaction/Transaction (NOTE: Stack trace has been filtered. Us
e --verbose to see entire trace.)
java.lang.NoClassDefFoundError: javax/transaction/Transaction
        at grails.plugin.reveng.GrailsJdbcBinder.readDatabaseSchema(GrailsJdbcBinder.groovy:51)
        at org.hibernate.cfg.JDBCBinder.readFromDatabase(JDBCBinder.java:93)
        at org.hibernate.cfg.JDBCBinder$readFromDatabase.call(Unknown Source)
        at grails.plugin.reveng.GrailsJdbcMetaDataConfiguration.readFromJDBC(GrailsJdbcMetaDataConfiguration.groovy:32)
        at grails.plugin.reveng.GrailsJdbcMetaDataConfiguration$readFromJDBC.call(Unknown Source)
        at grails.plugin.reveng.Reenigne.buildConfiguration(Reenigne.groovy:114)
        at grails.plugin.reveng.Reenigne.execute(Reenigne.groovy:60)
        at grails.plugin.reveng.Reenigne$execute.call(Unknown Source)
        at grails.plugin.reveng.RevengRunner.run(RevengRunner.groovy:81)
        at grails.plugin.reveng.RevengRunner$run.call(Unknown Source)
        at DbReverseEngineer$_run_closure1.doCall(DbReverseEngineer:36)
        at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:133)
        at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16_closure18.doCall(GantBinding.groovy:1
85)
        at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16_closure18.doCall(GantBinding.groovy)
        at org.codehaus.gant.GantBinding.withTargetEvent(GantBinding.groovy:90)
        at org.codehaus.gant.GantBinding.this$4$withTargetEvent(GantBinding.groovy)
        at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16.doCall(GantBinding.groovy:185)
        at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16.doCall(GantBinding.groovy)
        at gant.Gant$_dispatch_closure5.doCall(Gant.groovy:381)
        at gant.Gant$_dispatch_closure7.doCall(Gant.groovy:415)
        at gant.Gant$_dispatch_closure7.doCall(Gant.groovy)
        at gant.Gant.withBuildListeners(Gant.groovy:427)
        at gant.Gant.this$2$withBuildListeners(Gant.groovy)
        at gant.Gant$this$2$withBuildListeners$0.callCurrent(Unknown Source)
        at gant.Gant.dispatch(Gant.groovy:415)
        at gant.Gant.this$2$dispatch(Gant.groovy)
        at gant.Gant.invokeMethod(Gant.groovy)
        at gant.Gant.executeTargets(Gant.groovy:591)
        at gant.Gant.executeTargets(Gant.groovy:590)
Caused by: java.lang.ClassNotFoundException: javax.transaction.Transaction
        ... 29 more
| Error Error executing script DbReverseEngineer: javax/transaction/Transaction
like image 717
greyfox Avatar asked Sep 17 '14 15:09

greyfox


1 Answers

Actually this plugin is not compatible with Hibernate 4... yet. But since the last push was like ages ago, it doesn't look like that you will get a new version soon enough to work with it :)

However, you can still keep using this version of Grails and the db-reverse-engineer:0.5 plugin, by switching your Hibernate version, back to 3. And it is quite easy to do so !

In BuildConfig.groovy, comment the line runtime ":hibernate4:4.X.X.X"

And add instead: runtime ":hibernate:3.6.10.17"

(And btw, do not forget to add the correct connector to your database, I use myself this dependency: compile 'mysql:mysql-connector-java:5.1.22' )

like image 139
Loic Cara Avatar answered Oct 09 '22 00:10

Loic Cara