You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Uff2 <un...@inf.nyme.hu> on 2009/08/06 14:54:31 UTC
Hibernate reveng
Hello,
I want to used hibernate3-maven-plugin to generate java classes from
database tables.
Maven generates classes for all tables in the database using pom.xml (can be
found at the end of this mail).
I want to filter tables and put the classes into different packages
according to schema of the tables.
For testing I created a simple hibernate.reveng.xml file:
------ hibernate.reveng.xml -----
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-reverse-engineering
PUBLIC "-//Hibernate/Hibernate Reverse Engineering DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-reverse-engineering-3.0.dtd" >
<hibernate-reverse-engineering>
</hibernate-reverse-engineering>
-------------
And I added the following line into the pom.xml
<revengfile>/src/main/resources/hibernate.reveng.xml</revengfile>
When it I run the following command:
mvn hibernate3:hbm2java
I get the following wierd error message:
$ mvn hibernate3:hbm2java
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'hibernate3'.
-----------------------------------------------------
this realm = plexus.core.child-container[extensions]
urls[0] = file:~/.m2/repository/asm/asm-util/3.1/asm-util-3.1.jar
urls[1] = file:~/.m2/repository/asm/asm-tree/3.1/asm-tree-3.1.jar
urls[2] = file:~/.m2/repository/asm/asm/3.1/asm-3.1.jar
urls[3] =
file:~/.m2/repository/org/codehaus/plexus/plexus-utils/1.1/plexus-utils-1.1.jar
urls[4] = file:~/.m2/repository/cglib/cglib/2.2/cglib-2.2.jar
urls[5] = file:~/.m2/repository/ant/ant/1.6.2/ant-1.6.2.jar
Number of imports: 0
this realm = plexus.core
urls[0] = file:/usr/share/maven2/lib/wagon-http-shared.jar
urls[1] = file:/usr/share/maven2/lib/wagon-provider-api.jar
urls[2] = file:/usr/share/maven2/lib/wagon-http-lightweight.jar
urls[3] = file:/usr/share/maven2/lib/jsch.jar
urls[4] = file:/usr/share/maven2/lib/commons-cli.jar
urls[5] = file:/usr/share/maven2/lib/jtidy.jar
urls[6] = file:/usr/share/maven2/lib/wagon-ssh-external.jar
urls[7] = file:/usr/share/maven2/lib/maven2.jar
urls[8] = file:/usr/share/maven2/lib/xml-apis.jar
urls[9] = file:/usr/share/maven2/lib/wagon-ssh.jar
urls[10] = file:/usr/share/maven2/lib/wagon-ssh-common.jar
urls[11] = file:/usr/share/maven2/lib/plexus-utils.jar
urls[12] = file:/usr/share/maven2/lib/plexus-interactivity-api.jar
urls[13] = file:/usr/share/maven2/lib/wagon-file.jar
urls[14] = file:/usr/share/maven2/lib/plexus-container-default.jar
urls[15] = file:/usr/share/maven2/lib/doxia-sink-api.jar
urls[16] =
file:~/.m2/repository/postgresql/postgresql/8.3-603.jdbc4/postgresql-8.3-603.jdbc4.jar
Number of imports: 0
-----------------------------------------------------
[INFO]
------------------------------------------------------------------------
[INFO] Building reveng
[INFO] task-segment: [hibernate3:hbm2java]
[INFO]
------------------------------------------------------------------------
[INFO] Preparing hibernate3:hbm2java
[INFO] [resources:resources]
[INFO] Using default encoding to copy filtered resources.
[INFO] [hibernate3:hbm2java]
[INFO] using jdbcconfiguration task.
14:35:20,350 INFO org.hibernate.cfg.Environment - Hibernate 3.3.1.GA
14:35:20,358 INFO org.hibernate.cfg.Environment - loaded properties from
resource hibernate.properties: {hibernate.connection.username=username,
hibernate.connection.password=****,
hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect,
hibernate.connection.url=jdbc:postgresql://dbserver:5432/dbname,
hibernate.bytecode.use_reflection_optimizer=false,
hibernate.connection.driver_class=org.postgresql.Driver}
14:35:20,365 INFO org.hibernate.cfg.Environment - Bytecode provider name :
javassist
14:35:20,381 INFO org.hibernate.cfg.Environment - using JDK 1.4
java.sql.Timestamp handling
[INFO] Configuration XML file loaded:
file:/home/reveng/src/main/resources/hibernate.cfg.xml
14:35:20,486 INFO org.hibernate.cfg.Configuration - configuring from url:
file:/reveng/src/main/resources/hibernate.cfg.xml
14:35:20,826 INFO org.hibernate.cfg.JDBCMetaDataConfiguration - Ignoring
null mapping
14:35:20,826 INFO org.hibernate.cfg.Configuration - Configured
SessionFactory: null
[INFO] No hibernate properties file loaded.
[FATAL ERROR]
org.codehaus.mojo.hibernate3.exporter.Hbm2JavaGeneratorMojo#execute() caused
a linkage error (java.lang.NoClassDefFoundError) and may be out-of-date.
Check the realms:
[FATAL ERROR] Plugin realm =
app0.child-container[org.codehaus.mojo:hibernate3-maven-plugin]
urls[0] =
file:/home/unghvary/linux/.m2/repository/org/codehaus/mojo/hibernate3-maven-plugin/2.2/hibernate3-maven-plugin-2.2.jar
urls[1] = file:~/.m2/repository/log4j/log4j/1.2.14/log4j-1.2.14.jar
urls[2] =
file:~/.m2/repository/org/hibernate/hibernate-tools/3.2.3.GA/hibernate-tools-3.2.3.GA.jar
urls[3] = file:~/.m2/repository/org/beanshell/bsh/2.0b4/bsh-2.0b4.jar
urls[4] =
file:~/.m2/repository/freemarker/freemarker/2.3.8/freemarker-2.3.8.jar
urls[5] =
file:~/.m2/repository/org/hibernate/jtidy/r8-20060801/jtidy-r8-20060801.jar
urls[6] =
file:~/.m2/repository/org/hibernate/hibernate-core/3.3.1.GA/hibernate-core-3.3.1.GA.jar
urls[7] = file:~/.m2/repository/antlr/antlr/2.7.6/antlr-2.7.6.jar
urls[8] =
file:~/.m2/repository/commons-collections/commons-collections/3.1/commons-collections-3.1.jar
urls[9] = file:~/.m2/repository/dom4j/dom4j/1.6.1/dom4j-1.6.1.jar
urls[10] =
file:~/.m2/repository/xml-apis/xml-apis/1.0.b2/xml-apis-1.0.b2.jar
urls[11] =
file:~/.m2/repository/org/slf4j/slf4j-api/1.5.6/slf4j-api-1.5.6.jar
urls[12] =
file:~/.m2/repository/org/codehaus/mojo/hibernate3/maven-hibernate3-api/2.2/maven-hibernate3-api-2.2.jar
urls[13] =
file:~/.m2/repository/org/codehaus/plexus/plexus-utils/1.1/plexus-utils-1.1.jar
urls[14] =
file:~/.m2/repository/org/apache/geronimo/specs/geronimo-jta_1.0.1B_spec/1.1.1/geronimo-jta_1.0.1B_spec-1.1.1.jar
urls[15] =
file:~/.m2/repository/org/slf4j/slf4j-log4j12/1.5.6/slf4j-log4j12-1.5.6.jar
urls[16] =
file:~/.m2/repository/org/slf4j/jcl-over-slf4j/1.5.6/jcl-over-slf4j-1.5.6.jar
urls[17] =
file:~/.m2/repository/org/codehaus/mojo/hibernate3/maven-hibernate3-jdk14/2.2/maven-hibernate3-jdk14-2.2.jar
urls[18] =
file:~/.m2/repository/org/codehaus/mojo/hibernate3/maven-hibernate3-jdk15/2.2/maven-hibernate3-jdk15-2.2.jar
urls[19] =
file:~/.m2/repository/org/hibernate/hibernate-entitymanager/3.4.0.GA/hibernate-entitymanager-3.4.0.GA.jar
urls[20] =
file:~/.m2/repository/org/hibernate/ejb3-persistence/1.0.2.GA/ejb3-persistence-1.0.2.GA.jar
urls[21] =
file:~/.m2/repository/org/hibernate/hibernate-commons-annotations/3.1.0.GA/hibernate-commons-annotations-3.1.0.GA.jar
urls[22] =
file:~/.m2/repository/org/hibernate/hibernate-annotations/3.4.0.GA/hibernate-annotations-3.4.0.GA.jar
urls[23] = file:~/.m2/repository/javax/transaction/jta/1.1/jta-1.1.jar
urls[24] =
file:~/.m2/repository/javassist/javassist/3.4.GA/javassist-3.4.GA.jar
urls[25] =
file:~/.m2/repository/jboss/jboss-common/4.0.2/jboss-common-4.0.2.jar
urls[26] = file:~/.m2/repository/slide/webdavlib/2.0/webdavlib-2.0.jar
urls[27] =
file:~/.m2/repository/xerces/xercesImpl/2.6.2/xercesImpl-2.6.2.jar
[FATAL ERROR] Container realm = plexus.core
urls[0] = file:/usr/share/maven2/lib/wagon-http-shared.jar
urls[1] = file:/usr/share/maven2/lib/wagon-provider-api.jar
urls[2] = file:/usr/share/maven2/lib/wagon-http-lightweight.jar
urls[3] = file:/usr/share/maven2/lib/jsch.jar
urls[4] = file:/usr/share/maven2/lib/commons-cli.jar
urls[5] = file:/usr/share/maven2/lib/jtidy.jar
urls[6] = file:/usr/share/maven2/lib/wagon-ssh-external.jar
urls[7] = file:/usr/share/maven2/lib/maven2.jar
urls[8] = file:/usr/share/maven2/lib/xml-apis.jar
urls[9] = file:/usr/share/maven2/lib/wagon-ssh.jar
urls[10] = file:/usr/share/maven2/lib/wagon-ssh-common.jar
urls[11] = file:/usr/share/maven2/lib/plexus-utils.jar
urls[12] = file:/usr/share/maven2/lib/plexus-interactivity-api.jar
urls[13] = file:/usr/share/maven2/lib/wagon-file.jar
urls[14] = file:/usr/share/maven2/lib/plexus-container-default.jar
urls[15] = file:/usr/share/maven2/lib/doxia-sink-api.jar
urls[16] =
file:/home/unghvary/linux/.m2/repository/postgresql/postgresql/8.3-603.jdbc4/postgresql-8.3-603.jdbc4.jar
[INFO]
------------------------------------------------------------------------
[ERROR] FATAL ERROR
[INFO]
------------------------------------------------------------------------
[INFO] net/sf/cglib/core/KeyFactory
net.sf.cglib.core.KeyFactory
[INFO]
------------------------------------------------------------------------
[INFO] Trace
java.lang.NoClassDefFoundError: net/sf/cglib/core/KeyFactory
at
org.hibernate.cfg.reveng.OverrideRepository.<clinit>(OverrideRepository.java:551)
at
org.codehaus.mojo.hibernate3.configuration.JDBCComponentConfiguration.loadRevengFile(JDBCComponentConfiguration.java:75)
at
org.codehaus.mojo.hibernate3.configuration.JDBCComponentConfiguration.doConfiguration(JDBCComponentConfiguration.java:40)
at
org.codehaus.mojo.hibernate3.configuration.AbstractComponentConfiguration.getConfiguration(AbstractComponentConfiguration.java:56)
at
org.codehaus.mojo.hibernate3.HibernateExporterMojo.configureExporter(HibernateExporterMojo.java:200)
at
org.codehaus.mojo.hibernate3.exporter.Hbm2JavaGeneratorMojo.configureExporter(Hbm2JavaGeneratorMojo.java:64)
...
I don't understand why the class net/sf/cglib/core/KeyFactory cannot be
found.
It is part of cglib which is part of pom.xml in section extensions and
dependencies as well.
PLease help me.
Thx
----- pom.xml ---
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>maventest</groupId>
<artifactId>reveng</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>reveng</name>
<url>http://maven.apache.org</url>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>hibernate3-maven-plugin</artifactId>
<version>2.2</version>
<extensions>true</extensions>
<configuration>
<components>
<component>
<name>hbm2ddl</name>
<implementation>postgresql</implementation>
</component>
<component>
<name>hbm2hbmxml</name>
<outputDirectory>src/main/resources</outputDirectory>
</component>
<component>
<name>hbm2java</name>
<outputDirectory>src/main/java</outputDirectory>
</component>
</components>
<componentProperties>
<drop>true</drop>
<jdk5>true</jdk5>
<implementation>jdbcconfiguration</implementation>
<configurationfile>/src/main/resources/hibernate.cfg.xml</configurationfile>
<outputfilename>schema.sql</outputfilename>
</componentProperties>
</configuration>
</plugin>
</plugins>
<extensions>
<extension>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>8.3-603.jdbc4</version>
</extension>
<extension>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
<version>2.2</version>
</extension>
</extensions>
</build>
<dependencies>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate</artifactId>
<version>3.2.5.ga</version>
<exclusions>
<exclusion>
<groupId>javax.transaction</groupId>
<artifactId>jta</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-annotations</artifactId>
<version>3.3.0.ga</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-commons-annotations</artifactId>
<version>3.3.0.ga</version>
</dependency>
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
<version>2.2</version>
</dependency>
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>8.3-603.jdbc4</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-tools</artifactId>
<version>3.2.3.GA</version>
</dependency>
</dependencies>
</project>
--
View this message in context: http://www.nabble.com/Hibernate-reveng-tp24845979p24845979.html
Sent from the Maven - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: Hibernate reveng
Posted by Uff2 <un...@inf.nyme.hu>.
Hi Karl,
Thank you for your suggestion about directory convention of generated files.
Karl Heinz Marbaise wrote:
>
> Hi,
>
>> <extensions>
>> <extension>
>> <groupId>postgresql</groupId>
>> <artifactId>postgresql</artifactId>
>> <version>8.3-603.jdbc4</version>
>> </extension>
> Why are you defining the postgresql driver not as dependency for
> Hibernate ?
>
I'm new to maven. I put postgresql and cglib dependencies into
hibernate-maven-plugin as dependencies.
Then maven doesn't miss class net.sf.cglib.core.KeyFactory.
Without cglib maven stops with the same error.
Karl Heinz Marbaise wrote:
>
> Why no leaving it to Maven to find the correct version of cglib ...
>
Without version element maven stops with error message.
Karl Heinz Marbaise wrote:
>
> The following is a transitive dependency of hibernate-annotations....
>
>> <dependency>
>> <groupId>org.hibernate</groupId>
>> <artifactId>hibernate-commons-annotations</artifactId>
>> <version>3.3.0.ga</version>
>> </dependency>
> The following is a snipped of an mvn dependency:tree
> I have only hibernate.jar (3.2.6.ga) and hibernate-annotations.jar
> (3.3.1.ga) as dependency nothing else...
>
> [INFO] +- org.hibernate:hibernate:jar:3.2.6.ga:compile
> [INFO] | +- net.sf.ehcache:ehcache:jar:1.2.3:compile
> [INFO] | +- asm:asm-attrs:jar:1.5.3:compile
> [INFO] | +- dom4j:dom4j:jar:1.6.1:compile
> [INFO] | +- antlr:antlr:jar:2.7.6:compile
> [INFO] | +- cglib:cglib:jar:2.1_3:compile
> [INFO] | +- asm:asm:jar:1.5.3:compile
> [INFO] | \- commons-collections:commons-collections:jar:2.1.1:compile
> [INFO] +- org.hibernate:hibernate-annotations:jar:3.3.1.GA:compile
> [INFO] | +-
> org.hibernate:hibernate-commons-annotations:jar:3.0.0.ga:compile
> [INFO] | \- org.hibernate:ejb3-persistence:jar:1.0.1.GA:compile
>
Unfortunately, hibernate-commons-annotation is not dependency of version
3.3.0.ga of hibernate-annotation, but it is of version 3.3.1.GA.
--
View this message in context: http://www.nabble.com/Hibernate-reveng-tp24845979p24862976.html
Sent from the Maven - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: Hibernate reveng
Posted by Karl Heinz Marbaise <kh...@gmx.de>.
Hi,
> <component>
> <name>hbm2hbmxml</name>
> <outputDirectory>src/main/resources</outputDirectory>
I would suggest not to use the src directory ...use the target directory ...
> </component>
> <component>
> <name>hbm2java</name>
> <outputDirectory>src/main/java</outputDirectory>
Use the default (AFAIK target/generated-sources)...for other defaults
take a look at
http://mojo.codehaus.org/maven-hibernate3/hibernate3-maven-plugin/components.html
> <extensions>
> <extension>
> <groupId>postgresql</groupId>
> <artifactId>postgresql</artifactId>
> <version>8.3-603.jdbc4</version>
> </extension>
Why are you defining the postgresql driver not as dependency for
Hibernate ?
> <extension>
> <groupId>cglib</groupId>
> <artifactId>cglib</artifactId>
> <version>2.2</version>
> </extension>
> </extensions>
Why no leaving it to Maven to find the correct version of cglib ...
> </build>
> <dependencies>
> <dependency>
> <groupId>org.hibernate</groupId>
> <artifactId>hibernate</artifactId>
> <version>3.2.5.ga</version>
> <exclusions>
> <exclusion>
> <groupId>javax.transaction</groupId>
> <artifactId>jta</artifactId>
> </exclusion>
> </exclusions>
> </dependency>
> <dependency>
> <groupId>org.hibernate</groupId>
> <artifactId>hibernate-annotations</artifactId>
> <version>3.3.0.ga</version>
> </dependency>
The following is a transitive dependency of hibernate-annotations....
> <dependency>
> <groupId>org.hibernate</groupId>
> <artifactId>hibernate-commons-annotations</artifactId>
> <version>3.3.0.ga</version>
> </dependency>
The following should be solved by Maven...only if you have particular
circumstances...or needs...
> <dependency>
> <groupId>cglib</groupId>
> <artifactId>cglib</artifactId>
> <version>2.2</version>
> </dependency>
The following is a snipped of an mvn dependency:tree
I have only hibernate.jar (3.2.6.ga) and hibernate-annotations.jar
(3.3.1.ga) as dependency nothing else...
[INFO] +- org.hibernate:hibernate:jar:3.2.6.ga:compile
[INFO] | +- net.sf.ehcache:ehcache:jar:1.2.3:compile
[INFO] | +- asm:asm-attrs:jar:1.5.3:compile
[INFO] | +- dom4j:dom4j:jar:1.6.1:compile
[INFO] | +- antlr:antlr:jar:2.7.6:compile
[INFO] | +- cglib:cglib:jar:2.1_3:compile
[INFO] | +- asm:asm:jar:1.5.3:compile
[INFO] | \- commons-collections:commons-collections:jar:2.1.1:compile
[INFO] +- org.hibernate:hibernate-annotations:jar:3.3.1.GA:compile
[INFO] | +-
org.hibernate:hibernate-commons-annotations:jar:3.0.0.ga:compile
[INFO] | \- org.hibernate:ejb3-persistence:jar:1.0.1.GA:compile
Kind regards
Karl Heinz Marbaise
--
SoftwareEntwicklung Beratung Schulung Tel.: +49 (0) 2405 / 415 893
Dipl.Ing.(FH) Karl Heinz Marbaise ICQ#: 135949029
Hauptstrasse 177 USt.IdNr: DE191347579
52146 Würselen http://www.soebes.de
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org