Hibernate3 Maven Plugin ERROR: Could not create or find "MyReverseStrategy.java" with one argument delegate constructor?

StackOverflow https://stackoverflow.com/questions/22908398

سؤال

I am using Hibernate3 Maven Plugin to reverse engineering, this is a part of my pom.xml

<plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>hibernate3-maven-plugin</artifactId>
            <version>2.2</version>
            <executions>
                <execution>
                    <id>hbm2java</id>
                    <phase>generate-sources</phase>
                    <goals>
                        <goal>hbm2java</goal>
                    </goals>
                    <configuration>
                        <components>
                            <component>
                                <name>hbm2java</name>
                                <implementation>jdbcconfiguration</implementation>
                                <outputDirectory>target/generatedClasses</outputDirectory>
                            </component>

                        </components>
                        <componentProperties>
                            <jdk5>true</jdk5>
                            <ejb3>false</ejb3>
                            <revengfile>/src/main/resources/reverse/engineering/hibernate.reveng.xml</revengfile>
                            <reversestrategy>/src/main/resources/reverse/engineering/MyReverseEngineeringStrategy.java</reversestrategy>
                            <propertyfile>src/main/resources/hibernate.properties</propertyfile>
                            <configurationFile>target/generatedClasses/hibernate.cfg.xml</configurationFile>
                        </componentProperties>
                    </configuration>
                </execution>

It looks that the connection to the database is ok, but it create classes following the default reverseStrategy and not the one I declared "MyReverseEngineeringStrategy.java". And I get this error in the stacktrace.

[ERROR] Could not create or find /src/main/resources/reverse/engineering/MyReverseEngineeringStrategy.java with one argu
ment delegate constructor
java.lang.ClassNotFoundException: /src/main/resources/reverse/engineering/MyReverseEngineeringStrategy.java
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:171)
        at org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:123)
        at org.codehaus.mojo.hibernate3.configuration.JDBCComponentConfiguration.loadReverseStrategy(JDBCComponentConfig
uration.java:100)
        at org.codehaus.mojo.hibernate3.configuration.JDBCComponentConfiguration.doConfiguration(JDBCComponentConfigurat
ion.java:42)
        at org.codehaus.mojo.hibernate3.configuration.AbstractComponentConfiguration.getConfiguration(AbstractComponentC
onfiguration.java:56)
        at org.codehaus.mojo.hibernate3.HibernateExporterMojo.configureExporter(HibernateExporterMojo.java:200)
        at org.codehaus.mojo.hibernate3.HibernateExporterMojo.doExecute(HibernateExporterMojo.java:273)
        at org.codehaus.mojo.hibernate3.HibernateExporterMojo.execute(HibernateExporterMojo.java:152)
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
        at org.apache.maven.lifecycle.internal.MojoExecutor.executeForkedExecutions(MojoExecutor.java:365)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:199)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)

Using the hibernate tools plugin on eclipse I was able to generate classes with my reverse strategy but I want my project to be independent from eclipse. Any suggestions!

هل كانت مفيدة؟

المحلول

It was so silly but the message of the error didn't help me. So the problem was with

 <reversestrategy>/src/main/resources/reverse/engineering/MyReverseEngineeringStrategy.java</reversestrategy>

When I changed to the following,

 <reversestrategy>reverse.engineering.MyReverseEngineeringStrategy</reversestrategy>

it worked perfectly.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top