Hi,
Will anyone who has encountered the error:
Code:
Caused by: net.sf.hibernate.MappingException: duplicate import: Chart
and found a solution please respond with how you fixed it? I’ve browsed through the related posts and can not find a solution. It appears that this is a catch all type error that, in addition to the obvious duplicate problem, it is also generated if there is a problem in the mapping file.
The problem occurred after I added the <set> section to the actype mapping (see below). I’ve adjusted each tag to no avail. I don't use the .addclass() method as I define all of the mappings in the config file. WIthout the <set> I don't get the duplicate error. I have changed the mapping files many times and I’ve included my most recent ones.
Any suggestions or ideas where to look would be most helpful. I’ve also looked at the on-line doco and have the books: Hibernate in Action, Hibernate Developers Guide, Hibernate Developers notebook (if you want to refer to some printed text). Thanks in advance. Paul
Hibernate version: 2.1.7c
Mapping documents:<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >
<!-- DO NOT EDIT: This is a generated file that is synchronized -->
<!-- by MyEclipse Hibernate tool integration. -->
<!-- Created Sat Nov 20 12:25:00 GMT-06:00 2004 -->
<!--
<set name="cgCharts" inverse="true" lazy="false">
<key column="ACID"/>
<one-to-many class="com.dygtig.chart.Chart"/>
</set>
-->
<hibernate-mapping >
<class name="com.dygtig.actype.Actype" table="actype">
<id name="id" column="ID" >
<generator class="increment"/>
</id>
<version name="ver" column="VER" />
<property name="type" column="TYPE" not-null="true" />
<property name="model" column="MODEL" not-null="true" />
<property name="mtow" column="MTOW" not-null="true" />
<set name="cgCharts" lazy="true" inverse="true">
<key><column name="ACID" /></key>
<one-to-many class="com.dygtig.chart.Chart" />
</set>
</class>
</hibernate-mapping>
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >
<!-- DO NOT EDIT: This is a generated file that is synchronized -->
<!-- by MyEclipse Hibernate tool integration. -->
<!-- Created Sun Jan 16 20:32:51 GMT-06:00 2005 -->
<!-- <many-to-one name="actype" class="com.dygtig.actype.Actype" column="ACID"/> -->
<!-- <property name="acid" column="ACID" not-null="true" /> -->
<hibernate-mapping >
<class name="com.dygtig.chart.Chart" table="chart">
<id name="id" column="ID" >
<generator class="increment"/>
</id>
<version name="ver" column="VER" />
<property name="type" column="TYPE" not-null="true" />
<property name="description" column="DESCRIPTION" not-null="true" />
<many-to-one name="acid" class="com.dygtig.actype.Actype" not-null="true">
<column name="ACID" />
</many-to-one>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():Full stack trace of any exception that occurs:Initializing c3p0 pool... com.mchange.v2.c3p0.PoolBackedDataSource@33549b [ connectionPoolDataSource -> com.mchange.v2.c3p0.WrapperConnectionPoolDataSource@717ef5 [ acquireIncrement -> 1, autoCommitOnClose -> false, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, idleConnectionTestPeriod -> 0, initialPoolSize -> 5, maxIdleTime -> 1800, maxPoolSize -> 20, maxStatements -> 50, minPoolSize -> 5, nestedDataSource -> com.mchange.v2.c3p0.DriverManagerDataSource@1f7be7b [ description -> null, driverClass -> null, factoryClassLocation -> null, jdbcUrl -> jdbc:mysql://gretta04/takeoff, properties -> {autoReconnect=true, user=root, password=} ] , propertyCycle -> 300, testConnectionOnCheckout -> false ] , factoryClassLocation -> null, numHelperThreads -> 3 ]
currentSession
%%%% Error Creating SessionFactory %%%%
net.sf.hibernate.MappingException: Error reading resource: com/dygtig/chart/Chart.hbm.xml
at net.sf.hibernate.cfg.Configuration.addResource(Configuration.java:336)
at net.sf.hibernate.cfg.Configuration.doConfigure(Configuration.java:990)
at net.sf.hibernate.cfg.Configuration.doConfigure(Configuration.java:946)
at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:874)
at com.dygtig.hibernate.HibernateSessionFactory.currentSession(HibernateSessionFactory.java:49)
at com.dygtig.actype.ActypeService.getAcTypeChartList(ActypeService.java:194)
at com.dygtig.actype.Actype.getCgCharts(Actype.java:53)
at com.dygtig.actype.Actype$$BulkBeanByCGLIB$$8dd3a77f.getPropertyValues(<generated>)
at net.sf.cglib.beans.BulkBean.getPropertyValues(BulkBean.java:86)
at net.sf.hibernate.util.ReflectHelper.getBulkBean(ReflectHelper.java:157)
at net.sf.hibernate.persister.AbstractEntityPersister.<init>(AbstractEntityPersister.java:753)
at net.sf.hibernate.persister.EntityPersister.<init>(EntityPersister.java:714)
at net.sf.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:42)
at net.sf.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:137)
at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:768)
at com.dygtig.hibernate.HibernateSessionFactory.currentSession(HibernateSessionFactory.java:50)
at com.dygtig.actype.ActypeService.getAcTypeList(ActypeService.java:170)
at com.dygtig.views.ACTypeListView.getAcTypes(ACTypeListView.java:42)
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:585)
at com.sun.faces.el.PropertyResolverImpl.getValue(PropertyResolverImpl.java:79)
at com.sun.faces.el.impl.ArraySuffix.evaluate(ArraySuffix.java:167)
at com.sun.faces.el.impl.ComplexValue.evaluate(ComplexValue.java:151)
at com.sun.faces.el.impl.ExpressionEvaluatorImpl.evaluate(ExpressionEvaluatorImpl.java:243)
at com.sun.faces.el.ValueBindingImpl.getValue(ValueBindingImpl.java:173)
at com.sun.faces.el.ValueBindingImpl.getValue(ValueBindingImpl.java:154)
at javax.faces.component.UIData.getValue(UIData.java:527)
at javax.faces.component.UIData.getDataModel(UIData.java:856)
at javax.faces.component.UIData.setRowIndex(UIData.java:379)
at com.sun.faces.renderkit.html_basic.TableRenderer.encodeBegin(TableRenderer.java:65)
at javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:683)
at javax.faces.component.UIData.encodeBegin(UIData.java:681)
at javax.faces.webapp.UIComponentTag.encodeBegin(UIComponentTag.java:591)
at javax.faces.webapp.UIComponentTag.doEndTag(UIComponentTag.java:543)
at com.sun.faces.taglib.html_basic.DataTableTag.doEndTag(DataTableTag.java:491)
at org.apache.jsp.ACTypeList_jsp._jspx_meth_h_dataTable_0(org.apache.jsp.ACTypeList_jsp:338)
at org.apache.jsp.ACTypeList_jsp._jspx_meth_h_form_0(org.apache.jsp.ACTypeList_jsp:251)
at org.apache.jsp.ACTypeList_jsp._jspx_meth_f_subview_0(org.apache.jsp.ACTypeList_jsp:187)
at org.apache.jsp.ACTypeList_jsp.access$0(org.apache.jsp.ACTypeList_jsp:164)
at org.apache.jsp.ACTypeList_jsp$ACTypeList_jspHelper.invoke0(org.apache.jsp.ACTypeList_jsp:1054)
at org.apache.jsp.ACTypeList_jsp$ACTypeList_jspHelper.invoke(org.apache.jsp.ACTypeList_jsp:1072)
at org.apache.jsp.tag.web.layout_tag._jspx_meth_f_view_0(org.apache.jsp.tag.web.layout_tag:139)
at org.apache.jsp.tag.web.layout_tag.doTag(org.apache.jsp.tag.web.layout_tag:84)
at org.apache.jsp.ACTypeList_jsp._jspx_meth_tags_layout_0(org.apache.jsp.ACTypeList_jsp:160)
at org.apache.jsp.ACTypeList_jsp._jspService(org.apache.jsp.ACTypeList_jsp:129)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:99)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:325)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:245)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:674)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:465)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:400)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:303)
at com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:322)
at com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:130)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:87)
at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:117)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:198)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at com.dygtig.filters.SecurityCheckFilter.doFilter(SecurityCheckFilter.java:71)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:186)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:825)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:731)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:526)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:595)
Caused by: net.sf.hibernate.MappingException:
duplicate import: Chart at net.sf.hibernate.cfg.Mappings.addImport(Mappings.java:85)
at net.sf.hibernate.cfg.Binder.bindClass(Binder.java:126)
at net.sf.hibernate.cfg.Binder.bindRootClass(Binder.java:221)
at net.sf.hibernate.cfg.Binder.bindRoot(Binder.java:1243)
at net.sf.hibernate.cfg.Configuration.add(Configuration.java:249)
at net.sf.hibernate.cfg.Configuration.addInputStream(Configuration.java:285)
at net.sf.hibernate.cfg.Configuration.addResource(Configuration.java:333)
... 81 more
Hibernate: select this.ID as ID0_, this.VER as VER0_, this.TYPE as TYPE0_, this.MODEL as MODEL0_, this.MTOW as MTOW0_ from actype this where 1=1 order by this.TYPE asc
Name and version of the database you are using:MYSQL[/code]