-->
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.  [ 3 posts ] 
Author Message
 Post subject: Duplicate class/entity mapping
PostPosted: Thu Nov 20, 2008 6:15 pm 
Newbie

Joined: Wed Nov 05, 2008 5:35 pm
Posts: 3
Hi all,
I am creating a new Hibernate project. In my SessionFactory class I call the following method to read my hibernate.cfg.xml file....

configuration.configure("/hibernate-esong.cfg.xml");

However this throws the following exception....

Code:
org.hibernate.InvalidMappingException: Could not parse mapping document from resource ESongBulkFile.hbm.xml
   at org.hibernate.cfg.Configuration.addResource(Configuration.java:569)
   at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1587)
   at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1555)
   at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1534)
   at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1508)
   at org.hibernate.cfg.Configuration.configure(Configuration.java:1428)
   at com.hfa.esong.dao.HibernateSessionFactory.rebuildSessionFactory(HibernateSessionFactory.java:76)
   at com.hfa.esong.dao.HibernateSessionFactory.getSession(HibernateSessionFactory.java:60)
   at com.hfa.esong.dao.BaseHibernateDAO.getSession(BaseHibernateDAO.java:14)
   at com.hfa.esong.dao.FileDAO.save(FileDAO.java:20)
   at com.hfa.esong.web.EsongUploadController.onSubmit(EsongUploadController.java:121)
   at org.springframework.web.servlet.mvc.SimpleFormController.processFormSubmission(SimpleFormController.java:267)
   at org.springframework.web.servlet.mvc.AbstractFormController.handleRequestInternal(AbstractFormController.java:250)
   at org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:153)
   at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:45)
   at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:820)
   at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:755)
   at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:396)
   at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:360)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
   at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
   at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
   at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:524)
   at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
   at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
   at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
   at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
   at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
   at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
   at java.lang.Thread.run(Thread.java:595)
Caused by: org.hibernate.DuplicateMappingException: Duplicate class/entity mapping com.hfa.esong.bean.FileBean
   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.addInputStream(Configuration.java:504)
   at org.hibernate.cfg.Configuration.addResource(Configuration.java:566)




Here is my hibernate-esong.cfg.xml.......


Code:
<?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="connection.datasource">jdbc/dupsong</property>
     <property name="dialect">org.hibernate.dialect.DB2Dialect</property>
     <property name="show_sql">${showsql}</property>
      
       <mapping resource="ESongBulkFile.hbm.xml" />
      

   </session-factory>

</hibernate-configuration>


Here is my ESongBulkFile.hbm.xml.....

Code:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>
    <class name="com.hfa.esong.bean.FileBean" table="FILE" schema="ESONGBULK">
        <id name="inputFileId" type="java.lang.Integer">
            <column name="FILE_ID" />
            <generator class="identity" />
        </id>
       
        <timestamp name="updateTsp" column="UPDATE_DATE"/>
       
       
        <property name="recieveDt" type="java.util.Date">
            <column name="RECEIVED_DT" not-null="false" length="26" />
        </property>
        <property name="submittingPubId" type="java.lang.Integer">
            <column name="SUBMITTING_PUB_ID" not-null="false" length="10"  />
        </property>
        <property name="transCount" type="java.lang.Integer">
            <column name="TRANS_CNT" not-null="false" length="10" />
        </property>
        <property name="originalFilename" type="java.lang.String">
            <column name="ORIGINAL_FILE_NAME" not-null="false" length="60"  />
        </property>
        <property name="fileStatus" type="java.lang.Integer">
            <column name="FILE_STATUS_ID" not-null="false" length="10"  />
        </property>
        <property name="originalFilename" type="java.lang.String">
            <column name="HFA_FILE_NAME" length="60" not-null="false" />
        </property>
    </class>
</hibernate-mapping>


I am running this on JBoss 4 and both of these XML files are in the WEB-INF/classes folder of my web application.

Thanks in advance for any help.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 20, 2008 7:58 pm 
Newbie

Joined: Thu Nov 20, 2008 1:08 am
Posts: 9
Well the key part of the exception says

Quote:
Duplicate class/entity mapping com.hfa.esong.bean.FileBean


So that suggests you're configuring FileBean more than once. Could it be that your configuration.configure(..) method is being called more than once? Or are you also configuring FileBean somewhere else?

HTH,

Rob Hills
Waikiki, Western Australia


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 21, 2008 4:15 pm 
Newbie

Joined: Wed Nov 05, 2008 5:35 pm
Posts: 3
I found the problem. In the hbm file the property called "originalFilename" is repeated twice. I know this is my mistake, but Hibernate gave me a really bad error message. It really threw me off.

If we can fix that it would be great.

Thanks anyway for your help.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.