Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Error installing to Start: name=persistence.unit:

 
Pradeep Bhat
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why do I get the error : Duplicate XML entry for entities.CategoryDD???

My persistence.xml is as follows




And my orm.xml




Both are placed in META-INF folder.
But whenever i start my server i get the following error while deploying.

01:44:05,048 INFO [Configuration] Reading mappings from resource : /META-INF/orm.xml
01:44:05,118 INFO [Ejb3Configuration] [PersistenceUnit: DDTrial] META-INF/orm.xml found
01:44:05,158 ERROR [AbstractKernelController] Error installing to Start: name=persistence.unit:unitName=#DDTrial state=Create
java.lang.IllegalStateException: Duplicate XML entry for entities.CategoryDD
at org.hibernate.cfg.annotations.reflection.XMLContext.addClass(XMLContext.java:91)
at org.hibernate.cfg.annotations.reflection.XMLContext.addDocument(XMLContext.java:76)
at org.hibernate.cfg.AnnotationConfiguration.add(AnnotationConfiguration.java:691)
at org.hibernate.cfg.AnnotationConfiguration.addInputStream(AnnotationConfiguration.java:779)
at org.hibernate.ejb.Ejb3Configuration.addClassesToSessionFactory(Ejb3Configuration.java:929)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:758)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:425)
at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:131)
at org.jboss.jpa.deployment.PersistenceUnitDeployment.start(PersistenceUnitDeployment.java:301)
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.reflect.plugins.introspection.ReflectionUtils.invoke(ReflectionUtils.java:59)
at org.jboss.reflect.plugins.introspection.ReflectMethodInfoImpl.invoke(ReflectMethodInfoImpl.java:150)
at org.jboss.joinpoint.plugins.BasicMethodJoinPoint.dispatch(BasicMethodJoinPoint.java:66)
at org.jboss.kernel.plugins.dependency.KernelControllerContextAction$JoinpointDispatchWrapper.execute(KernelControllerContextAction.java:241)
at org.jboss.kernel.plugins.dependency.ExecutionWrapper.execute(ExecutionWrapper.java:47)
at org.jboss.kernel.plugins.dependency.KernelControllerContextAction.dispatchExecutionWrapper(KernelControllerContextAction.java:109)
at org.jboss.kernel.plugins.dependency.KernelControllerContextAction.dispatchJoinPoint(KernelControllerContextAction.java:70)
at org.jboss.kernel.plugins.dependency.LifecycleAction.installActionInternal(LifecycleAction.java:221)
at org.jboss.kernel.plugins.dependency.InstallsAwareAction.installAction(InstallsAwareAction.java:54)
at org.jboss.kernel.plugins.dependency.InstallsAwareAction.installAction(InstallsAwareAction.java:42)
at org.jboss.dependency.plugins.action.SimpleControllerContextAction.simpleInstallAction(SimpleControllerContextAction.java:62)
at org.jboss.dependency.plugins.action.AccessControllerContextAction.install(AccessControllerContextAction.java:71)
at org.jboss.dependency.plugins.AbstractControllerContextActions.install(AbstractControllerContextActions.java:51)
at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)
at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1598)
at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)
at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1062)
at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)
at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:774)
at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:540)
at org.jboss.deployers.vfs.deployer.kernel.BeanMetaDataDeployer.deploy(BeanMetaDataDeployer.java:121)
at org.jboss.deployers.vfs.deployer.kernel.BeanMetaDataDeployer.deploy(BeanMetaDataDeployer.java:51)
at org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer.internalDeploy(AbstractSimpleRealDeployer.java:62)
at org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer.deploy(AbstractRealDeployer.java:50)
at org.jboss.deployers.plugins.deployers.DeployerWrapper.deploy(DeployerWrapper.java:171)
at org.jboss.deployers.plugins.deployers.DeployersImpl.doDeploy(DeployersImpl.java:1439)
at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1157)
at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1178)
at org.jboss.deployers.plugins.deployers.DeployersImpl.install(DeployersImpl.java:1098)
at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)
at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1598)
at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)
at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1062)
at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)
at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:822)
at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553)
at org.jboss.deployers.plugins.deployers.DeployersImpl.process(DeployersImpl.java:781)
at org.jboss.deployers.plugins.main.MainDeployerImpl.process(MainDeployerImpl.java:698)
at org.jboss.system.server.profileservice.ProfileServiceBootstrap.loadProfile(ProfileServiceBootstrap.java:304)
at org.jboss.system.server.profileservice.ProfileServiceBootstrap.start(ProfileServiceBootstrap.java:205)
at org.jboss.bootstrap.AbstractServerImpl.start(AbstractServerImpl.java:405)
at org.jboss.Main.boot(Main.java:209)
at org.jboss.Main$1.run(Main.java:547)
at java.lang.Thread.run(Thread.java:595)
01:44:05,388 ERROR [ProfileServiceBootstrap] Failed to load profile: Summary of incomplete deployments (SEE PREVIOUS ERRORS FOR DETAILS):

DEPLOYMENTS MISSING DEPENDENCIES:
Deployment "jboss.j2ee:jar=41_OrderBilling_MDB_DD.jar,name=OrderBillingMDB_DDName,service=EJB3" is missing the following dependencies:
Dependency "<UNKNOWN jboss.j2ee:jar=41_OrderBilling_MDB_DD.jar,name=OrderBillingMDB_DDName,service=EJB3>" (should be in state "Described", but is actually in state "** UNRESOLVED Demands 'persistence.unit:unitName=#DDTrial' **")

DEPLOYMENTS IN ERROR:
Deployment "persistence.unit:unitName=#DDTrial" is in error due to the following reason(s): java.lang.IllegalStateException: Duplicate XML entry for entities.CategoryDD
Deployment "<UNKNOWN jboss.j2ee:jar=41_OrderBilling_MDB_DD.jar,name=OrderBillingMDB_DDName,service=EJB3>" is in error due to the following reason(s): ** UNRESOLVED Demands 'persistence.unit:unitName=#DDTrial' **


The folloing entry is in my ejb-jar.xml


 
Jaikiran Pai
Marshal
Pie
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You seem to be mapping the entities.CategoryDD twice. Once through the class element in the persistence.xml:



and once through the orm.xml file. Try removing the class element from the persistence.xml.

 
Pradeep Bhat
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It worked. Thanks.
 
Akshay Sahu
Greenhorn
Posts: 26
Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

My Persistence.xml file:

<persistence-unit name="CSP" transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>java:/CSP</jta-data-source>
<mapping-file>/META-INF/orm.xml</mapping-file>
<properties>
<property name="hibernate.hbm2ddl.auto" value="update"/>
<property name="toplink.logging.level" value="FINE" />
<property name="hibernate.show-sql" value="true" />
</properties>
</persistence-unit>

My orm.xml file:

<entity class="com.entity.CustomerDetails" name="CustomerProfile">
<table name="CUSTOMER_DETAILS" schema="dbo" />
<attributes>
<id name="CustomerId">
<column name="CUSTOMER_ID" insertable="true" />
<generated-value strategy="IDENTITY" />
</id>
<basic name="PartnerId" optional="true" fetch="LAZY">
<column name="PARTNER_ID" nullable="true" insertable="true" />
</basic>
<basic name="activationStatus" optional="false" fetch="EAGER">
<column name="ACTIVATION_STATUS" nullable="false" insertable="true" length="10" />
</basic>
<basic name="customerType" optional="false" fetch="EAGER">
<column name="CUSTOMER_TYPE" nullable="false" insertable="true" length="10" />
</basic>
<basic name="notes" optional="true" fetch="LAZY">
<column name="NOTES" nullable="true" insertable="true" length="300"/>
</basic>
<basic name="createdDate" optional="true" fetch="LAZY">
<column name="CREATED_DATE" nullable="true" insertable="true" />
</basic>
<basic name="updatedDate" optional="true" fetch="LAZY">
<column name="UPDATED_DATE" nullable="true" insertable="true" />
</basic>
<basic name="createdByUserId" optional="true" fetch="LAZY">
<column name="CREATED_BY_USER_ID" nullable="true" insertable="true" />
</basic>
<basic name="updatedByUserId" optional="true" fetch="LAZY">
<column name="UPDATED_BY_USER_ID" nullable="true" insertable="true" />
</basic>
</attributes>
</entity>

Even though I am not deploying it twice, JBoss 5 throws an exception stating
that

java.lang.IllegalStateException: Duplicate XML entry for com.entity.CustomerDetails

I don't know, where am I going wrong.

Any help, highly appreciated. !!!

Thank You,
Akshay Sahu
 
Akshay Sahu
Greenhorn
Posts: 26
Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes guys, I have solved it for myself.


The solution is:


1. The default name of mapping file in EJB 3 is orm.xml. So in persistence.xml file, if I provide the <mapping-file> name as orm.xml, then the container deploys the same orm.xml twice. So I renamed my orm.xml file to mapping.xml file. The error is gone now.


2. Instead of renaming it to some other name, remove <mapping-file> element from persistence.xml file, then also it will work as the container treats orm.xml as the default mapping file, and even though you do not make an entry of that in persistence.xml file, the container loads it.


Thanks 2 my self
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic