facebook

org.hibernate.MappingException: duplicate class mapping:

  1. MyEclipse Archived
  2.  > 
  3. Database Tools (DB Explorer, Hibernate, etc.)
Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #251371 Reply

    lunasahu
    Member

    Hi all,I am using Myeclipse 4.x,eclipse 3.x,jboss 4.0x,Hibernet 3.x.I am facing the following error could any let me the error.

    I am refering the tutorial given in http://www.onjava.com/pub/a/onjava/2004/01/14/hibernate.html

    ERROR:::
    ———-

    23:07:54,065 INFO [Server] Starting JBoss (MX MicroKernel)…
    23:07:54,065 INFO [Server] Release ID: JBoss [Zion] 4.0.3SP1 (build: CVSTag=JBoss_4_0_3_SP1 date=200510231054)
    23:07:54,075 INFO [Server] Home Dir: C:\jboss-4.0
    23:07:54,075 INFO [Server] Home URL: file:/C:/jboss-4.0/
    23:07:54,075 INFO [Server] Patch URL: null
    23:07:54,075 INFO [Server] Server Name: hpcgg
    23:07:54,075 INFO [Server] Server Home Dir: C:\jboss-4.0\server\hpcgg
    23:07:54,075 INFO [Server] Server Home URL: file:/C:/jboss-4.0/server/hpcgg/
    23:07:54,075 INFO [Server] Server Temp Dir: C:\jboss-4.0\server\hpcgg\tmp
    23:07:54,075 INFO [Server] Root Deployment Filename: jboss-service.xml
    23:07:54,576 INFO [ServerInfo] Java version: 1.5.0_04,Sun Microsystems Inc.
    23:07:54,576 INFO [ServerInfo] Java VM: Java HotSpot(TM) Client VM 1.5.0_04-b05,Sun Microsystems Inc.
    23:07:54,576 INFO [ServerInfo] OS-System: Windows XP 5.1,x86
    23:07:55,567 INFO [Server] Core system initialized
    23:07:58,802 INFO [WebService] Using RMI server codebase: http://dpd30w046:8083/
    23:07:58,852 INFO [Log4jService$URLWatchTimerTask] Configuring from URL: resource:log4j.xml
    23:07:59,293 INFO [NamingService] Started jndi bootstrap jnpPort=1099, rmiPort=1098, backlog=50, bindAddress=/0.0.0.0, Client SocketFactory=null, Server SocketFactory=org.jboss.net.sockets.DefaultSocketFactory@ad093076
    23:08:05,441 INFO [Embedded] Catalina naming disabled
    23:08:06,343 INFO [Http11Protocol] Initializing Coyote HTTP/1.1 on http-0.0.0.0-80
    23:08:06,903 INFO [Http11Protocol] Initializing Coyote HTTP/1.1 on http-0.0.0.0-443
    23:08:06,903 INFO [Catalina] Initialization processed in 1372 ms
    23:08:06,903 INFO [StandardService] Starting service jboss.web
    23:08:06,913 INFO [StandardEngine] Starting Servlet Engine: Apache Tomcat/5.5
    23:08:06,983 INFO [StandardHost] XML validation disabled
    23:08:07,094 INFO [Catalina] Server startup in 191 ms
    23:08:07,324 INFO [TomcatDeployer] deploy, ctxPath=/invoker, warUrl=…/deploy/http-invoker.sar/invoker.war/
    23:08:08,606 INFO [TomcatDeployer] deploy, ctxPath=/ws4ee, warUrl=…/tmp/deploy/tmp2434jboss-ws4ee-exp.war/
    23:08:08,846 INFO [TomcatDeployer] deploy, ctxPath=/, warUrl=…/deploy/jbossweb-tomcat55.sar/ROOT.war/
    23:08:09,257 INFO [TomcatDeployer] deploy, ctxPath=/jbossmq-httpil, warUrl=…/deploy/jms/jbossmq-httpil.sar/jbossmq-httpil.war/
    23:08:13,032 INFO [TomcatDeployer] deploy, ctxPath=/web-console, warUrl=…/deploy/management/console-mgr.sar/web-console.war/
    23:08:14,674 INFO [MailService] Mail Service bound to java:/Mail
    23:08:15,626 INFO [RARDeployment] Required license terms exist, view META-INF/ra.xml in …/deploy/jboss-local-jdbc.rar
    23:08:15,896 INFO [RARDeployment] Required license terms exist, view META-INF/ra.xml in …/deploy/jboss-xa-jdbc.rar
    23:08:16,196 INFO [RARDeployment] Required license terms exist, view META-INF/ra.xml in …/deploy/jms/jms-ra.rar
    23:08:16,437 INFO [RARDeployment] Required license terms exist, view META-INF/ra.xml in …/deploy/mail-ra.rar
    23:08:17,448 INFO [ConnectionFactoryBindingService] Bound ConnectionManager ‘jboss.jca:service=DataSourceBinding,name=jdbc/gigpad’ to JNDI name ‘java:jdbc/gigpad’
    23:08:18,560 INFO [ConnectionFactoryBindingService] Bound ConnectionManager ‘jboss.jca:service=DataSourceBinding,name=jdbc-oci/gigpad’ to JNDI name ‘java:jdbc-oci/gigpad’
    23:08:19,311 INFO [bfxlims-submitBatch] Bound to JNDI name: queue/bfxlims-submitBatch
    23:08:19,351 INFO [bfxlims-returnBatch] Bound to JNDI name: queue/bfxlims-returnBatch
    23:08:19,731 INFO [hpcgg-messaging] Bound to JNDI name: topic/hpcgg-messaging
    23:08:19,861 INFO [UILServerILService] JBossMQ UIL service available at : /0.0.0.0:8193
    23:08:20,012 INFO [DLQ] Bound to JNDI name: queue/DLQ
    23:08:20,032 INFO [ConnectionFactoryBindingService] Bound ConnectionManager ‘jboss.jca:service=DataSourceBinding,name=jdbc/tamtron’ to JNDI name ‘java:jdbc/tamtron’
    23:08:20,512 INFO [ConnectionFactoryBindingService] Bound ConnectionManager ‘jboss.jca:service=ConnectionFactoryBinding,name=JmsXA’ to JNDI name ‘java:JmsXA’
    23:08:20,592 INFO [TomcatDeployer] deploy, ctxPath=/javaweb, warUrl=…/deploy/javaweb.war/
    23:08:22,024 INFO [TomcatDeployer] deploy, ctxPath=/jmx-console, warUrl=…/deploy/jmx-console.war/
    23:08:22,345 INFO [TomcatDeployer] deploy, ctxPath=/myweb, warUrl=…/deploy/myweb.war/
    23:08:23,737 INFO [TomcatDeployer] deploy, ctxPath=/onjava, warUrl=…/deploy/onjava.war/
    23:08:23,887 INFO [ContextConfig] Missing application web.xml, using defaults only StandardEngine[jboss.web].StandardHost[localhost].StandardContext[/onjava]
    23:08:24,328 INFO [Http11Protocol] Starting Coyote HTTP/1.1 on http-0.0.0.0-80
    23:08:24,728 INFO [ChannelSocket] JK: ajp13 listening on /0.0.0.0:8009
    23:08:24,798 INFO [JkMain] Jk running ID=0 time=0/150 config=null
    23:08:24,848 INFO [Http11Protocol] Starting Coyote HTTP/1.1 on http-0.0.0.0-443
    23:08:24,878 INFO [Server] JBoss (MX MicroKernel) [4.0.3SP1 (build: CVSTag=JBoss_4_0_3_SP1 date=200510231054)] Started in 30s:793ms
    23:08:34,362 INFO [TomcatDeployer] deploy, ctxPath=/frastu, warUrl=…/deploy/frastu.war/
    23:08:46,789 INFO [STDOUT] IN POST
    23:08:46,949 INFO [Environment] Hibernate 3.1
    23:08:46,969 INFO [Environment] hibernate.properties not found
    23:08:46,979 INFO [Environment] using CGLIB reflection optimizer
    23:08:46,979 INFO [Environment] using JDK 1.4 java.sql.Timestamp handling
    23:08:47,290 INFO [Configuration] Reading mappings from resource: hibernate/Product.hbm.xml
    23:08:47,590 INFO [HbmBinder] Mapping class: hibernate.Product -> products
    23:08:47,710 INFO [Configuration] configuring from resource: /hibernate.cfg.xml
    23:08:47,710 INFO [Configuration] Configuration resource: /hibernate.cfg.xml
    23:08:47,720 INFO [Configuration] Reading mappings from resource: hibernate/Order.hbm.xml
    23:08:47,760 INFO [HbmBinder] Mapping class: hibernate.Order -> orders
    23:08:47,821 INFO [Configuration] Reading mappings from resource: hibernate/OrderItem.hbm.xml
    23:08:47,871 INFO [HbmBinder] Mapping class: hibernate.OrderItem -> order_items
    23:08:48,231 INFO [Configuration] Reading mappings from resource: hibernate/Product.hbm.xml
    23:08:48,281 INFO [Mappings] duplicate import: hibernate.Product->hibernate.Product
    23:08:48,281 INFO [Mappings] duplicate import: hibernate.Product->Product
    23:08:48,281 INFO [HbmBinder] Mapping class: hibernate.Product -> products
    23:08:48,291 INFO [STDOUT] org.hibernate.MappingException: Could not read mappings from resource: hibernate/Product.hbm.xml
    at org.hibernate.cfg.Configuration.addResource(Configuration.java:476)
    at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1414)
    at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1382)
    at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1363)
    at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1339)
    at org.hibernate.cfg.Configuration.configure(Configuration.java:1259)
    at org.hibernate.cfg.Configuration.configure(Configuration.java:1245)
    at test.InsertProduct.insertProduct(InsertProduct.java:31)
    at events.WelCome.doPost(WelCome.java:25)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
    at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
    at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
    at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:159)
    at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
    at org.apache.catalina.authenticator.SingleSignOn.invoke(SingleSignOn.java:365)
    at org.apache.catalina.valves.FastCommonAccessLogValve.invoke(FastCommonAccessLogValve.java:481)
    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:856)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
    at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
    at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
    at java.lang.Thread.run(Thread.java:595)
    Caused by: org.hibernate.MappingException: duplicate class mapping: hibernate.Product
    at org.hibernate.cfg.Mappings.addClass(Mappings.java:96)
    at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:111)
    at org.hibernate.cfg.Configuration.add(Configuration.java:379)
    at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:418)
    at org.hibernate.cfg.Configuration.addResource(Configuration.java:473)
    … 31 more

    Regards
    Jyoti

    #251378 Reply

    Haris Peco
    Member

    Jyoti,

    You make double mapping for Product.hbm.xml.It looks that first mapping is before reading hibernate.cfg.xml
    (like this cfg = new Configuration().addFile(“…Product.hbm.xml”).configure() ).Can you send your hibernate configuration methods

    Thanks

    #251394 Reply

    lunasahu
    Member

    Hi ,
    Thanks for quick replay.Your answer helps me to solve the problem.I was coding new Configuration().addClass(“Product.class”) which put me in trouble.
    Regards
    Jyoti

    #271849 Reply

    chickenlips
    Member

    I am having the same problem with duplicate class mapping except that I don’t have the “new Configuration().addClass etc.”, so that is not my problem. Here is my exception:

    12:23,593 INFO [STDOUT] 17:12:23,593 INFO [Configuration] configuring from resource: /hibernate.cfg.xml
    17:12:23,593 INFO [STDOUT] 17:12:23,593 INFO [Configuration] Configuration resource: /hibernate.cfg.xml
    17:12:23,593 INFO [STDOUT] 17:12:23,593 INFO [Configuration] Reading mappings from resource : com/myWork/hibernate/MyClass.hbm.xml
    17:12:23,609 INFO [STDOUT] 17:12:23,609 INFO [Mappings] duplicate import: com.myWork.hibernate.MyClass->com.myWork.hibernate.MyClass
    17:12:23,609 INFO [STDOUT] 17:12:23,609 INFO [Mappings] duplicate import: com.myWork.hibernate.MyClass->MyClass
    17:12:23,609 INFO [STDOUT] 17:12:23,609 INFO [HbmBinder] Mapping class: com.myWork.hibernate.MyClass -> MyClass
    17:12:23,625 INFO [STDOUT] %%%% Error Creating SessionFactory %%%%
    17:12:23,625 ERROR [STDERR] org.hibernate.InvalidMappingException: Could not parse mapping document from resource com/myWork/hibernate/myClass.hbm.xml

    I have the MyClass.hbm.xml file in the hibernate.cfg.xml. The HibernateSessionFactory.java, the mapping files etc are all generated by MyEclipse/hibernate. I am not using annotation.

    So where does another copy of the mapping file get loaded? Thanks for any help you can give me.

    chickenlips

    #272122 Reply

    kwade
    Member

    I’m having the same issue where I’m getting DuplicateMappingExceptions. When I look at my log file, it’s apparent that hibernate.cfg.xml is being read TWICE.

    I’m using myeclipse 5.1.0 with hibernate 3.2. The context of this exception is a simple junit test. When I run the test, I see that the hibernate.cfg.xml file is read in… and then read in again, leading to “duplicate import” INFO log messages followed by the inevitable InvalidMappingException and DuplicateMappingException.

    The problem may be that my junit test is seeing 2 copies of the hibernate.cfg file: one in my /src directory (where myeclipse put it) and another one in WEB-INF/classes (where I think myeclipse copied it for my web application).

    How can I get my junit test to see only one hibernate configuration file and not both of them?

    #272558 Reply

    chickenlips
    Member

    Don’t know if this applies to you but my problems was that I had an error during the buildSessionFactory(). The code generated by MyEclipse automatically calls rebuildSessionFactory() which reads the hibernate.cfg.xml files again thus the duplicateMappingException.

    Go back and look through your log for hints on what might be wrong with your mapping files. Most likely is the misnaming of the class member name vs column name, at least for me.

    #273428 Reply

    guptaclp
    Member

    Hi,
    I am new in Hibernet. i have a problem in running the application.for Application server
    i have used JBoss.An error is comming as /hibernate.cfg.xml not found.
    please any one having know please give the solution.Thanks in Advance.

    #273530 Reply

    Loyal Water
    Member

    Where is your hibernate.cfg.xml file placed on deployment ?

    #274633 Reply

    chickenlips
    Member

    @guptaclp wrote:

    Hi,
    I am new in Hibernet. i have a problem in running the application.for Application server
    i have used JBoss.An error is comming as /hibernate.cfg.xml not found.
    please any one having know please give the solution.Thanks in Advance.

    The hibernate.cfg.xml file should be in your WEB-INF/classes directory.

    #274634 Reply

    chickenlips
    Member

    @guptaclp wrote:

    Hi,
    I am new in Hibernet. i have a problem in running the application.for Application server
    i have used JBoss.An error is comming as /hibernate.cfg.xml not found.
    please any one having know please give the solution.Thanks in Advance.

Viewing 10 posts - 1 through 10 (of 10 total)
Reply To: org.hibernate.MappingException: duplicate class mapping:

You must be logged in to post in the forum log in