DuplicateMappingException: Duplicate class/entity mapping
---------------------------------------------------------

                 Key: MHIBERNATE-75
                 URL: http://jira.codehaus.org/browse/MHIBERNATE-75
             Project: Maven 2.x Hibernate Plugin
          Issue Type: Bug
          Components: hbm2java
    Affects Versions: 2.1
         Environment: Windows XP, Java 1.6.0_03, Maven 2.0.9
            Reporter: Marc
            Assignee: Johann Reyes


I've been having problems with the plugin recently when rebuilding my projects 
(see log below). Removing the entries from 'hibernate.cfg.xml' helps but leads 
to another issue, namely an ExporterException: 'unable to create directory' 
(see issue) . Why, if I specify the plugin to use the configuration 
(<implementation>configuration</implementation>), it still scans my project for 
mapping definitions?



[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building xyz
[INFO]    task-segment: [clean, install]
[INFO] ------------------------------------------------------------------------
[INFO] [clean:clean]
[INFO] Deleting directory Q:\java\eclipse\workspaces\java_uccs\trunk\xyz\target
[INFO] Preparing hibernate3:hbm2java
[WARNING] Removing: hbm2java from forked lifecycle, to prevent recursive 
invocation.
[INFO] [resources:resources]
[INFO] Using default encoding to copy filtered resources.
[INFO] [hibernate3:hbm2java {execution: default}]
[INFO] using configuration task.
11:29:22,121  INFO org.hibernate.cfg.Environment - Hibernate 3.2.5
11:29:22,121  INFO org.hibernate.cfg.Environment - hibernate.properties not 
found
11:29:22,121  INFO org.hibernate.cfg.Environment - Bytecode provider name : 
cglib
11:29:22,121  INFO org.hibernate.cfg.Environment - using JDK 1.4 
java.sql.Timestamp handling
[INFO] Configuration XML file loaded: 
file:/Q:/java/eclipse/workspaces/java_uccs/trunk/xyz/src/main/resources/hibernate.cfg.xml
11:29:22,184  INFO org.hibernate.cfg.Configuration - configuring from url: 
file:/Q:/java/eclipse/workspaces/java_uccs/trunk/xyz/src/main/resources/hibernate.cfg.xml
11:29:22,277  INFO org.hibernate.cfg.Configuration - Reading mappings from 
resource : nl/enovation/cloverleaf/customers/bronovo/dao/Berichten.hbm.xml
11:29:22,387  INFO org.hibernate.cfg.HbmBinder - Mapping class: 
xyz.dao.Berichten -> Berichten
11:29:22,402  INFO org.hibernate.cfg.Configuration - Reading mappings from 
resource : nl/enovation/cloverleaf/customers/bronovo/dao/Queries.hbm.xml
11:29:22,449  INFO org.hibernate.cfg.Configuration - Configured SessionFactory: 
null
[INFO] Configuration Properties file loaded: 
Q:\java\eclipse\workspaces\java_uccs\trunk\xyz\src\main\resources\database.properties
11:29:22,449  INFO org.hibernate.cfg.Configuration - Reading mappings from 
file: 
Q:\java\eclipse\workspaces\java_uccs\trunk\xyz\target\classes\nl\enovation\cloverleaf\customers\bronovo\dao\Berichten.hbm.xm
l
11:29:22,496  INFO org.hibernate.cfg.Mappings - duplicate import: 
xyz.dao.Berichten->xyz.dao.Berichten
11:29:22,496  INFO org.hibernate.cfg.Mappings - duplicate import: 
xyz.dao.Berichten->Berichten
11:29:22,496  INFO org.hibernate.cfg.HbmBinder - Mapping class: 
xyz.dao.Berichten -> Berichten
[INFO] ------------------------------------------------------------------------
[ERROR] FATAL ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Could not parse mapping document from file 
Q:\java\eclipse\workspaces\java_uccs\trunk\xyz\target\classes\nl\enovation\cloverleaf\customers\bronovo\dao\Berichten.hbm.xml
Duplicate class/entity mapping xyz.dao.Berichten
[INFO] ------------------------------------------------------------------------
[INFO] Trace
org.hibernate.InvalidMappingException: Could not parse mapping document from 
file 
Q:\java\eclipse\workspaces\java_uccs\trunk\xyz\target\classes\nl\enovation\cloverleaf\customers\bronovo\dao\Berichten.hbm.x
ml
        at org.hibernate.cfg.Configuration.addFile(Configuration.java:319)
        at org.hibernate.cfg.Configuration.addDirectory(Configuration.java:662)
        at org.hibernate.cfg.Configuration.addDirectory(Configuration.java:659)
        at org.hibernate.cfg.Configuration.addDirectory(Configuration.java:659)
        at org.hibernate.cfg.Configuration.addDirectory(Configuration.java:659)
        at org.hibernate.cfg.Configuration.addDirectory(Configuration.java:659)
        at org.hibernate.cfg.Configuration.addDirectory(Configuration.java:659)
        at org.hibernate.cfg.Configuration.addDirectory(Configuration.java:659)
        at 
org.codehaus.mojo.hibernate3.configuration.DefaultComponentConfiguration.doConfiguration(DefaultComponentConfiguration.java:30)
        at 
org.codehaus.mojo.hibernate3.configuration.AbstractComponentConfiguration.getConfiguration(AbstractComponentConfiguration.java:40)
        at 
org.codehaus.mojo.hibernate3.HibernateExporterMojo.configureExporter(HibernateExporterMojo.java:188)
        at 
org.codehaus.mojo.hibernate3.exporter.Hbm2JavaGeneratorMojo.configureExporter(Hbm2JavaGeneratorMojo.java:69)
        at 
org.codehaus.mojo.hibernate3.HibernateExporterMojo.doExecute(HibernateExporterMojo.java:268)
        at 
org.codehaus.mojo.hibernate3.HibernateExporterMojo.execute(HibernateExporterMojo.java:140)
        at 
org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:451)
        at 
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:558)
        at 
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:499)
        at 
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:478)
        at 
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:330)
        at 
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:291)
        at 
org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:142)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:336)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:129)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:287)
        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.classworlds.Launcher.launchEnhanced(Launcher.java:315)
        at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
        at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
        at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: org.hibernate.DuplicateMappingException: Duplicate class/entity 
mapping xyz.dao.Berichten
        at org.hibernate.cfg.Mappings.addClass(Mappings.java:118)
        at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:145)
        at org.hibernate.cfg.Configuration.add(Configuration.java:669)
        at org.hibernate.cfg.Configuration.addFile(Configuration.java:309)
        ... 31 more
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6 seconds
[INFO] Finished at: Tue Apr 15 11:29:22 CEST 2008
[INFO] Final Memory: 13M/26M
[INFO] ------------------------------------------------------------------------


== plugin configuration ==

<plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>hibernate3-maven-plugin</artifactId>
        <executions>
                <execution>
                        <goals>
                                <goal>hbm2java</goal>
                        </goals>
                </execution>
        </executions>
        <configuration>
                <components>
                        <component>
                                <name>hbm2java</name>
                                
<outputDirectory>${project.build.directory}/generated-sources/hibernate3</outputDirectory>
                        </component>
                </components>
                <componentProperties>
                        <implementation>configuration</implementation>
                        <packagename>xyz.dao</packagename>
                        
<revengfile>${basedir}/src/main/resources/hibernate.reveng.xml</revengfile>
                </componentProperties>
        </configuration>
</plugin>


=== hibernate.cfg.xml ===
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration 
DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd";>
<hibernate-configuration>
        <session-factory>
                <property name="hibernate.connection.pool_size">1</property>
                <property name="current_session_context_class">thread</property>
                <property 
name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
                <property name="show_sql">true</property>
                <!--property name="hbm2ddl.auto">validate</property-->
                <mapping resource="xyz/dao/Berichten.hbm.xml" />
                <mapping resource="xyz/dao/Queries.hbm.xml" />
        </session-factory>
</hibernate-configuration>




-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to