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.