-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Duplicate collection role mapping error in coverage run.
PostPosted: Mon Oct 02, 2006 2:04 pm 
Newbie

Joined: Mon Oct 02, 2006 10:23 am
Posts: 3
Location: Wisconsin, USA
Okay, here's a newbie's first forum question (after searching forum, Google, etc.). Using Hibernate in Windows XP Eclipse with current PostgreSQL on a very simple set of tables. Works great in Eclipse--JRun green bar, proper data management, etc. No problems.

Now I'm building an Ant script to run a test coverage job using coburtura and JUnit. Searches have uncovered the fact that coburtura and Hibernate use different versions of asm.jar. Coburtura needs the asm-2.2.1.jar file it ships with in the Ant classpath for the instrumentation task, and Hibernate needs the asm.jar file it ships with in the application classpath. Don't know if this is the problem or not, but it could be relevant.

Hibernate version: hibernate3.jar in Eclipse (don't know how to get specific version ID)

Code between sessionFactory.openSession() and session.close(): Not getting that far.

Name and version of the database you are using: Current version of PostgreSQL, 8.1-405 I believe

The generated SQL (show_sql=true): Not applicable

Debug level Hibernate log excerpt: Not sure where that is in Eclipse.

Full stack trace of any exception that occurs:


Error message is in this stack trace:

Testsuite: com.XXX.workflow.rulesEngine.RulesEngineTest
Tests run: 4, Failures: 1, Errors: 3, Time elapsed: 0.016 sec
------------- Standard Error -----------------
%%%% Error Creating SessionFactory %%%%
org.hibernate.MappingException: Could not read mappings from resource: com/XXX/workflow/hibernate/RuleSet.hbm.xml
at org.hibernate.cfg.Configuration.addResource(Configuration.java:485)
at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1465)
at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1433)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1414)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1390)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1310)
at com.XXX.workflow.hibernate.HibernateSessionFactory.rebuildSessionFactory(HibernateSessionFactory.java:59)
at com.XXX.workflow.hibernate.HibernateSessionFactory.getSession(HibernateSessionFactory.java:43)
at com.XXX.workflow.rulesEngine.RulesEngine.<init>(RulesEngine.java:100)
at com.XXX.workflow.rulesEngine.RulesEngineTest.<init>(RulesEngineTest.java:25)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at junit.framework.TestSuite.createTest(TestSuite.java:131)
at junit.framework.TestSuite.addTestMethod(TestSuite.java:114)
at junit.framework.TestSuite.<init>(TestSuite.java:75)
at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:277)
at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.launch(JUnitTestRunner.java:672)
at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:546)
Caused by: org.hibernate.DuplicateMappingException: Duplicate collection role mapping com.XXX.workflow.hibernate.RuleSet.states
at org.hibernate.cfg.Mappings.addCollection(Mappings.java:124)
at org.hibernate.cfg.HbmBinder.createClassProperties(HbmBinder.java:2030)
at org.hibernate.cfg.HbmBinder.createClassProperties(HbmBinder.java:2005)
at org.hibernate.cfg.HbmBinder.bindRootPersistentClassCommonValues(HbmBinder.java:368)
at org.hibernate.cfg.HbmBinder.bindRootClass(HbmBinder.java:282)
at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:153)
at org.hibernate.cfg.Configuration.add(Configuration.java:386)
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:427)
at org.hibernate.cfg.Configuration.addResource(Configuration.java:482)
... 19 more

Mapping documents: The mapping documents for the relevant classes:

Here they are for the parent class (RuleSet) and the child class (State) Both have been generated by Eclipse (or more likely, MyEclipse).

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!--
Mapping file autogenerated by MyEclipse - Hibernate Tools
-->
<hibernate-mapping>
<class name="com.XXX.workflow.hibernate.RuleSet" table="rule_set" schema="testing">
<composite-id name="id" class="com.XXX.workflow.hibernate.RuleSetId">
<key-property name="ruleSetId" type="java.lang.String">
<column name="rule_set_id" length="10" />
</key-property>
<key-property name="develStatus" type="java.lang.String">
<column name="devel_status" length="5" />
</key-property>
</composite-id>
<property name="parentRuleSet" type="java.lang.String">
<column name="parent_rule_set" length="10" not-null="true" />
</property>
<property name="parentStatus" type="java.lang.String">
<column name="parent_status" length="5" not-null="true" />
</property>
<property name="updateTstamp" type="java.util.Date">
<column name="update_tstamp" length="8" not-null="true" />
</property>
<property name="effectiveDate" type="java.util.Date">
<column name="effective_date" length="8" not-null="true" />
</property>
<property name="expirationDate" type="java.util.Date">
<column name="expiration_date" length="8" not-null="true" />
</property>
<property name="description" type="java.lang.String">
<column name="description" length="50" not-null="true" />
</property>
<set name="states" inverse="true">
<key>
<column name="rule_set_id" length="10" not-null="true" />
<column name="devel_status" length="5" not-null="true" />
</key>
<one-to-many class="com.XXX.workflow.hibernate.State" />
</set>
<set name="customers" inverse="true">
<key>
<column name="rule_set_id" length="10" not-null="true" />
<column name="devel_status" length="5" not-null="true" />
</key>
<one-to-many class="com.XXX.workflow.hibernate.Customer" />
</set>
</class>
</hibernate-mapping>



<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!--
Mapping file autogenerated by MyEclipse - Hibernate Tools
-->
<hibernate-mapping>
<class name="com.XXX.workflow.hibernate.State" table="state" schema="testing">
<composite-id name="id" class="com.XXX.workflow.hibernate.StateId">
<key-property name="ruleSetId" type="java.lang.String">
<column name="rule_set_id" length="10" />
</key-property>
<key-property name="develStatus" type="java.lang.String">
<column name="devel_status" length="5" />
</key-property>
<key-property name="stateId" type="java.lang.String">
<column name="state_id" length="10" />
</key-property>
</composite-id>
<many-to-one name="ruleSet" class="com.XXX.workflow.hibernate.RuleSet" update="false" insert="false" fetch="select">
<column name="rule_set_id" length="10" not-null="true" />
<column name="devel_status" length="5" not-null="true" />
</many-to-one>
<property name="updateTstamp" type="java.util.Date">
<column name="update_tstamp" length="8" not-null="true" />
</property>
<property name="effectiveDate" type="java.util.Date">
<column name="effective_date" length="8" not-null="true" />
</property>
<property name="expirationDate" type="java.util.Date">
<column name="expiration_date" length="8" not-null="true" />
</property>
<property name="description" type="java.lang.String">
<column name="description" length="50" not-null="true" />
</property>
<property name="constraintExpr" type="java.lang.String">
<column name="constraint_expr" length="2000" not-null="true" />
</property>
<set name="transitionsForTransitionFk1" inverse="true">
<key>
<column name="rule_set_id" length="10" not-null="true" />
<column name="devel_status" length="5" not-null="true" />
<column name="state_id" length="10" not-null="true" />
</key>
<one-to-many class="com.XXX.workflow.hibernate.Transition" />
</set>
<set name="transitionsForTransitionFk2" inverse="true">
<key>
<column name="rule_set_id" length="10" not-null="true" />
<column name="devel_status" length="5" not-null="true" />
<column name="next_state" length="10" not-null="true" />
</key>
<one-to-many class="com.XXX.workflow.hibernate.Transition" />
</set>
</class>
</hibernate-mapping>


Here is the Ant file I am using. All jars needed by Ant itself are set in a classpath option of the External Tools dialog classpath tab, and include: ant-junit.jar, asm-2.2.1.jar, asm.jar, cobertura.jar, commons-collections-2.1.1.jar, commons-logging-1.0.4.jar, dom4j-1.6.1.jar, hibernate2.jar, jakarta-oro-2.0.8.jar, junit.jar, log4j-1.2.9.jar, log4j.jar, and 3 PostgreSQL JDBC jars.

Note that this script is still under construction and prettyrough. Still everyting is now working except Hibernate.

<?xml version="1.0" encoding="ISO-8859-1"?>
<project name="WorkflowCoverage" default="report">

<property name="cobertura.dir" value="./lib" />

<path id="cobertura.classpath">
<fileset dir="${cobertura.dir}">
<include name="cobertura.jar" />
<include name="lib/**/*.jar" />
<include name="lib/asm-2.2.1.jar" />
</fileset>
</path>

<taskdef classpathref="cobertura.classpath" resource="tasks.properties" />

<target name="init" description="Run Initialization">
<echo message="Ant: running --init--."/>
<!-- Create the time stamp -->
<tstamp/>
<property name="sourceDir" value="src/main/java" />
<property name="outputDir" value="target" />
<property name="testreportdir" value="reports"/>
<property name="basedir" value="."/>
<property name="instr_classes_dir" value="instrumented-classes"/>

<!-- Rebuild the temporary directories -->
<delete dir="${testreportdir}" />
<delete dir="${instr_classes_dir}"/>
<mkdir dir="${testreportdir}" />
<mkdir dir="${instr_classes_dir}"/>
</target>


<target name="instrumentation" depends="init" description="Create a new set of class files instrumented for coverage testing.">
<echo message="Ant: running --instrumentation--."/>
<delete file="cobertura.ser" />
<cobertura-instrument todir="${instr_classes_dir}">
<fileset dir="${outputDir}">
<include name="**/*.class" />
</fileset>
</cobertura-instrument>
<echo message="Copying Hibernate mapping files to the instrumented files."/>
</target>

<target name="JUnit" depends="instrumentation" description="Run the JUnit unit tests.">
<echo message="Ant: running --JUnit--."/>
<junit printSummary="yes"
fork="true"
haltonerror="false"
haltonfailure="false"
forkmode="once">
<classpath path="${instr_classes_dir}"/>
<classpath location="lib/asm.jar"/>
<classpath location="lib/cobertura.jar"/>
<classpath location="lib/log4j-1.2.9.jar"/>
<classpath location="lib/hibernate3.jar"/>
<classpath location="lib/dom4j-1.6.1.jar"/>
<classpath location="lib/commons-logging-1.0.4.jar"/>
<classpath location="lib/commons-collections-2.1.1.jar"/>
<classpath path="${outputDir}"/>

<batchtest fork="yes" todir="reports">
<formatter type="plain"/>
<fileset dir="src/test/java">
<include name="**/*Test*.java"/>
</fileset>
</batchtest>
</junit>
</target>

<target name="report" depends="JUnit" description="Generate the reports from the metadata from the JUnit tests.">
<echo message="Ant: running --reports--."/>
<cobertura-report format="html" destdir="${testreportdir}" srcdir="${sourceDir}" />
</target>

</project>


Thanks in advance for any help anyone can offer.

JFE.


Top
 Profile  
 
 Post subject: Hello?
PostPosted: Sat Oct 07, 2006 10:41 am 
Newbie

Joined: Mon Oct 02, 2006 10:23 am
Posts: 3
Location: Wisconsin, USA
Has this gotten lost in the mists of Forum time, or have I happened across something that is quite out of the ordinary?

JFE.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.