-->
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.  [ 4 posts ] 
Author Message
 Post subject: Duplicate class/entity mapping
PostPosted: Wed Mar 29, 2006 5:03 am 
Newbie

Joined: Wed Mar 29, 2006 4:37 am
Posts: 3
Hi
In attempt to develop my first EJB3, I am using jboss-4.0.4RC1 with Hibernate 3.1.2., at deploy I got these exceptions:

10:29:54,257 FATAL [PersistenceXmlLoader] exlybris JTA
10:29:54,257 INFO [Ejb3Deployment] EJB3 deployment time took: 20
10:29:54,257 INFO [JmxKernelAbstraction] installing MBean: persistence.units:unitName=unit1 with dependencies:
10:29:54,257 INFO [JmxKernelAbstraction] jboss.jca:name=ExlybrisDS,service=ManagedConnectionFactory
10:29:54,277 INFO [Ejb3Configuration] found EJB3 Entity bean: gl.ejb3.category.Category
10:29:54,377 INFO [HbmBinder] Mapping class: gl.ejb3.category.Category -> CATEGORIES
10:29:54,377 INFO [Mappings] duplicate import: gl.ejb3.category.Category->gl.ejb3.category.Category
10:29:54,377 INFO [Mappings] duplicate import: gl.ejb3.category.Category->Category
10:29:54,377 INFO [HbmBinder] Mapping class: gl.ejb3.category.Category -> CATEGORIES

10:29:54,377 WARN [ServiceController] Problem starting service persistence.units:unitName=unit1
java.lang.reflect.InvocationTargetException
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 org.jboss.ejb3.ServiceDelegateWrapper.startService(ServiceDelegateWrapper.java:97)
at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289)
at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:245)
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 org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:260)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:974)
at $Proxy0.start(Unknown Source)
at org.jboss.system.ServiceController.start(ServiceController.java:417)
at sun.reflect.GeneratedMethodAccessor6.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:260)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:190)
at $Proxy50.start(Unknown Source)
at org.jboss.ejb3.JmxKernelAbstraction.install(JmxKernelAbstraction.java:76)
at org.jboss.ejb3.Ejb3Deployment.startPersistenceUnits(Ejb3Deployment.java:599)
at org.jboss.ejb3.Ejb3Deployment.start(Ejb3Deployment.java:452)
at org.jboss.ejb3.Ejb3Module.startService(Ejb3Module.java:139)
at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289)
at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:245)
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 org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:260)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:974)
at $Proxy0.start(Unknown Source)
at org.jboss.system.ServiceController.start(ServiceController.java:417)
at sun.reflect.GeneratedMethodAccessor6.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:260)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:190)
at $Proxy25.start(Unknown Source)
at org.jboss.ejb3.EJB3Deployer.start(EJB3Deployer.java:365)
at org.jboss.deployment.MainDeployer.start(MainDeployer.java:1007)
at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:808)
at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:771)
at sun.reflect.GeneratedMethodAccessor14.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:260)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:190)
at $Proxy6.deploy(Unknown Source)
at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:334)
at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:522)
at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:20
7)
at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.loop(AbstractDeploymentScanner.java:218)

at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.run(AbstractDeploymentScanner.java:197)
Caused by: org.hibernate.DuplicateMappingException: Duplicate class/entity mapping gl.ejb3.category.Category
at org.hibernate.cfg.Mappings.addClass(Mappings.java:118)
at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:154)
at org.hibernate.cfg.Configuration.add(Configuration.java:386)
at org.hibernate.cfg.AnnotationConfiguration.processArtifactsOfType(AnnotationConfiguration.java:261)
at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:210)
at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:997)
at org.hibernate.ejb.Ejb3Configuration.buildMappings(Ejb3Configuration.java:722)
at org.hibernate.ejb.EventListenerConfigurator.configure(EventListenerConfigurator.java:161)
at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:567)
at org.hibernate.ejb.Ejb3Configuration.createContainerEntityManagerFactory(Ejb3Configuration.java:245)
at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:108)
at org.jboss.ejb3.entity.PersistenceUnitDeployment.start(PersistenceUnitDeployment.java:260)
... 79 more
10:29:55,098 INFO [EJB3Deployer] Deployed: file:/C:/jboss-4.0.4RC1/server/ejb3/deploy/ejb3.jar
10:29:55,098 ERROR [URLDeploymentScanner] Incomplete Deployment listing:

--- MBeans waiting for other MBeans ---
ObjectName: persistence.units:unitName=unit1
State: FAILED
Reason: java.lang.reflect.InvocationTargetException
I Depend On:
jboss.jca:service=ManagedConnectionFactory,name=PGDS

--- MBEANS THAT ARE THE ROOT CAUSE OF THE PROBLEM ---
ObjectName: persistence.units:unitName=unit1
State: FAILED
Reason: java.lang.reflect.InvocationTargetException
I Depend On:
jboss.jca:service=ManagedConnectionFactory,name=PGDS

What causes the mapping duplication?

The entity class:

package gl.ejb3.category;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;

@Entity
@Table(name="categories")
/*
*
*/
public class Category implements Serializable {

static final long serialVersionUID = 321321321321654654L;
//azon stands for id
private Integer azon;
//megnevezes stands for name
private String megnevezes;

Category() {}

@Id
@Column(name="azon", nullable=false)
public Integer getAzon() {return azon;}
public void setAzon(Integer azon) {this.azon = azon;}

@Column(name="megnevezes", nullable=false)
public String getMegnevezes() {return megnevezes;}
public void setMegnevezes(String megnevezes) {this.megnevezes = megnevezes;}
}

Mapping documents:

category.hbm.xml

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="gl.ejb3.category.Category" table="CATEGORIES">
<id name="azon" type="big_decimal">
<column name="AZON"/>
</id>
<property name="megnevezes" type="string">
<column name="MEGNEVEZES"/>
</property>
</class>
</hibernate-mapping>

hibernate.cfg.xml

<?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>
<!-- Database connection settings -->
<property name="connection.driver_class">org.postgresql.Driver</property>
<property name="connection.url">jdbc:postgresql://localhost:5432/schema1</property>
<property name="connection.username">username</property>
<property name="connection.password">password</property>

<!-- JDBC connection pool (use the built-in) -->
<property name="connection.pool_size">1</property>

<!-- SQL dialect -->
<property name="dialect">org.hibernate.dialect.ProgressDialect</property>

<!-- Enable Hibernate's automatic session context management -->
<property name="current_session_context_class">thread</property>

<!-- Disable the second-level cache -->
<property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>

<!-- Echo all executed SQL to stdout -->
<property name="show_sql">true</property>

<!-- Drop and re-create the database schema on startup -->
<!-- property name="hbm2ddl.auto">create</property -->

<mapping resource="category/category.hbm.xml"/>
</session-factory>
</hibernate-configuration>

persistence.xml

<persistence>
<persistence-unit name="unit1">
<jta-data-source>java:/PGDS</jta-data-source>
<jar-file>../ejb3.jar</jar-file>
<class>gl.ejb3.category.Category</class>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.ProgressDialect"/>
<!-- property name="hibernate.hbm2ddl.auto" value="create-drop"/>
<property name="jboss.entity.manager.jndi.name" value="java:/unit1"/>
<property name="jboss.entity.manager.factory.jndi.name" value="java:/unit1Factory"/-->
</properties>
</persistence-unit>
</persistence>

My JAR looks like this:

ejb3.jar
\
META-INF
\
persistence.xml
\
gl
\
ejb3
\
hibernate.cfg.xml
category
\
Category.class
category.hbm.xml


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 29, 2006 6:16 am 
Newbie

Joined: Tue Jan 03, 2006 7:30 am
Posts: 18
Location: Budapest, Hungary
Quote:
What causes the mapping duplication?

You are mapping the entity twice: with annotations and with the .hbm.xml file. I'd guess you should make up your mind and drop one of them. If you are using EJB3, the hibernate.cfg.xml and *.hbm.xml files aren't needed.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 31, 2006 7:44 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
There should be a precedence mechanism though. Open a JIRA issue with a minimal test case. I think the precedence mechanism mess up class packages

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 04, 2007 2:11 pm 
Newbie

Joined: Wed Apr 04, 2007 1:56 pm
Posts: 5
Location: Boston Area
I was getting this error (DuplicateMappingException) when I accidentally had mapping turned on in my hibernate.cfg.xml file.


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