-->
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.  [ 10 posts ] 
Author Message
 Post subject: duplicate import
PostPosted: Sun Sep 11, 2005 7:56 am 
Newbie

Joined: Sat Aug 27, 2005 2:02 pm
Posts: 13
Hi everyone.

I'm runnin hibernate 3.0.5 and mysql. i'm testting an application under XP and under debian.
i'm working with two sessionfactory connected to two different mysql's dbs.
I'm configuring the two sessionfactory with the same mapped class, and i got this error:

Code:
[java] GRAVE: Could not compile the mapping document
     [java] org.hibernate.MappingException: duplicate import Pet
     [java]     at org.hibernate.cfg.Mappings.addImport(Mappings.java:105)
     [java]     at org.hibernate.cfg.HbmBinder.bindPersistentClassCommonValues(HbmBinder.java:541)
     [java]     at org.hibernate.cfg.HbmBinder.bindClass(HbmBinder.java:488)
     [java]     at org.hibernate.cfg.HbmBinder.bindRootClass(HbmBinder.java:234)
     [java]     at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:152)
     [java]     at org.hibernate.cfg.Configuration.add(Configuration.java:362)
     [java]     at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:400)
     [java]     at org.hibernate.cfg.Configuration.addClass(Configuration.java:468)
     .....
     [java] Exception: [Error reading resource: Pet.hbm.xml][org.hibernate.MappingException: duplicate import: Pet]


this is from linux.
the point is that under XP , even if hibernate says about this duplicate exception, i'm still able to carry out the job, while under linux i get a NullPointerException.
what's going on?

Thank you,
regards


Top
 Profile  
 
 Post subject:
PostPosted: Sun Sep 11, 2005 1:51 pm 
Expert
Expert

Joined: Mon Jul 04, 2005 5:19 pm
Posts: 720
I have no idea why it's behaving differently between OSs . As far as the duplicate mapping exception goes, check the following:

See if the Pet mapping is specified twice in the same hibernate.cfg.xml file.
If you have two hibernate.cfg.xml files, make sure they are not both being loaded by Configuration.configure(), which is what happens if both are in the classpath and you are using the no args configure() invocation.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 14, 2005 3:39 am 
Newbie

Joined: Sat Aug 27, 2005 2:02 pm
Posts: 13
Thanks for the reply,

the point is that i'm configuring on time, so without a file, but just with two configuration objects, which should have nothing to do I guess, but i still get thi s duplicate...


thanks
marco


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 14, 2005 12:15 pm 
Expert
Expert

Joined: Mon Jul 04, 2005 5:19 pm
Posts: 720
Post the code that you are using to programmatically configure H.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 23, 2005 3:58 am 
Newbie

Joined: Sat Aug 27, 2005 2:02 pm
Posts: 13
right...

I tried to find the error using eclipse and it seems inside Hibernate, or perhaps i'm doing something wrong.. I have a class more or less like this:

Code:
class Conf  {
...
  getConf() {
   cfg.set...
   // an iterator with my mapped classes
   iterator...
   for ....
       cfg.addClass(Class.forName(iter.next());
   return conf;
  }
     


then as i said i Configure two sessionfactories, using two diffrent Conf object.. but when i try the second sessionfactories. i get that error...
(i repet, under win it just go on, while under linux it does not)

thanks for any suggestion..


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 23, 2005 3:42 pm 
Expert
Expert

Joined: Mon Jul 04, 2005 5:19 pm
Posts: 720
Use a logging statement to find out exactly which class is being duplicated. Also, you say you have a NPE, but the stack trace does not indicate this.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Sep 25, 2005 6:11 am 
Newbie

Joined: Sat Aug 27, 2005 2:02 pm
Posts: 13
Thanks dennisbyme,

well, i'm trying to load only one class, so to isolate the error, what is strage is that, having two sessionfactoryS, my program do the same (configure hib) twice.. what i mean is that the first time it works.. the second it doesn't!

I'll past the log.. entire! Thanks for the help given me, i relly need to fix it :)

Code:
25-set-2005 14.03.45 org.hibernate.cfg.Environment <clinit>
INFO: Hibernate 3.0.5
25-set-2005 14.03.45 org.hibernate.cfg.Environment <clinit>
INFO: hibernate.properties not found
25-set-2005 14.03.45 org.hibernate.cfg.Environment <clinit>
INFO: using CGLIB reflection optimizer
25-set-2005 14.03.45 org.hibernate.cfg.Environment <clinit>
INFO: using JDK 1.4 java.sql.Timestamp handling
25-set-2005 14.03.45 org.hibernate.cfg.Configuration addClass
INFO: Mapping resource: Pet.hbm.xml
25-set-2005 14.03.45 org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
INFO: Mapping class: Pet -> PET
25-set-2005 14.03.45 org.hibernate.cfg.Configuration secondPassCompile
INFO: processing extends queue
25-set-2005 14.03.45 org.hibernate.cfg.Configuration secondPassCompile
INFO: processing collection mappings
25-set-2005 14.03.45 org.hibernate.cfg.Configuration secondPassCompile
INFO: processing association property references
25-set-2005 14.03.45 org.hibernate.cfg.Configuration secondPassCompile
INFO: processing foreign key constraints
25-set-2005 14.03.46 org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Using Hibernate built-in connection pool (not for production use!)
25-set-2005 14.03.46 org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Hibernate connection pool size: 20
25-set-2005 14.03.46 org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: autocommit mode: false
25-set-2005 14.03.46 org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost/e1
25-set-2005 14.03.46 org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: connection properties: {user=root, password=****}
25-set-2005 14.03.46 org.hibernate.cfg.SettingsFactory buildSettings
INFO: RDBMS: MySQL, version: 4.1.13a-Debian_3-log
25-set-2005 14.03.46 org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC driver: MySQL-AB JDBC Driver, version: mysql-connector-java-3.1.10 ( $Date: 2005/05/19 15:52:23 $, $Revision: 1.1.2.2 $ )
25-set-2005 14.03.46 org.hibernate.dialect.Dialect <init>
INFO: Using dialect: org.hibernate.dialect.MySQLDialect
25-set-2005 14.03.46 org.hibernate.transaction.TransactionFactoryFactory buildTransactionFactory
INFO: Using default transaction strategy (direct JDBC transactions)
25-set-2005 14.03.46 org.hibernate.transaction.TransactionManagerLookupFactory getTransactionManagerLookup
INFO: No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
25-set-2005 14.03.46 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Automatic flush during beforeCompletion(): disabled
25-set-2005 14.03.46 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Automatic session close at end of transaction: disabled
25-set-2005 14.03.46 org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC batch size: 15
25-set-2005 14.03.46 org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC batch updates for versioned data: disabled
25-set-2005 14.03.46 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Scrollable result sets: enabled
25-set-2005 14.03.46 org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC3 getGeneratedKeys(): enabled
25-set-2005 14.03.46 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Connection release mode: null
25-set-2005 14.03.46 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Maximum outer join fetch depth: 2
25-set-2005 14.03.46 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Default batch fetch size: 1
25-set-2005 14.03.46 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Generate SQL with comments: disabled
25-set-2005 14.03.46 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Order SQL updates by primary key: disabled
25-set-2005 14.03.46 org.hibernate.cfg.SettingsFactory createQueryTranslatorFactory
INFO: Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
25-set-2005 14.03.46 org.hibernate.hql.ast.ASTQueryTranslatorFactory <init>
INFO: Using ASTQueryTranslatorFactory
25-set-2005 14.03.46 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Query language substitutions: {}
25-set-2005 14.03.46 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Second-level cache: enabled
25-set-2005 14.03.46 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Query cache: disabled
25-set-2005 14.03.46 org.hibernate.cfg.SettingsFactory createCacheProvider
INFO: Cache provider: org.hibernate.cache.EhCacheProvider
25-set-2005 14.03.46 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Optimize cache for minimal puts: disabled
25-set-2005 14.03.46 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Structured second-level cache entries: disabled
25-set-2005 14.03.46 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Echoing all SQL to stdout
25-set-2005 14.03.46 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Statistics: disabled
25-set-2005 14.03.46 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Deleted entity synthetic identifier rollback: disabled
25-set-2005 14.03.46 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Default entity-mode: pojo
25-set-2005 14.03.46 org.hibernate.impl.SessionFactoryImpl <init>
INFO: building session factory
25-set-2005 14.03.46 net.sf.ehcache.config.Configurator configure
AVVERTENZA: No configuration found. Configuring ehcache from ehcache-failsafe.xml found in the classpath: jar:file:/root/workspace/JaMigator/lib/ehcache-1.1.jar!/ehcache-failsafe.xml
25-set-2005 14.03.46 org.hibernate.impl.SessionFactoryObjectFactory addInstance
INFO: Not binding factory to JNDI, no JNDI name configured
25-set-2005 14.03.46 org.hibernate.impl.SessionFactoryImpl checkNamedQueries
INFO: Checking 0 named queries
25-set-2005 14.03.47 org.hibernate.cfg.Configuration addClass
INFO: Mapping resource: it/demarch/EE/test/Pet.hbm.xml
25-set-2005 14.03.47 org.hibernate.cfg.Configuration add
GRAVE: Could not compile the mapping document
org.hibernate.MappingException: duplicate import: it.demarch.EE.test.Pet
   at org.hibernate.cfg.Mappings.addImport(Mappings.java:105)
   at org.hibernate.cfg.HbmBinder.bindPersistentClassCommonValues(HbmBinder.java:541)
   at org.hibernate.cfg.HbmBinder.bindClass(HbmBinder.java:488)
   at org.hibernate.cfg.HbmBinder.bindRootClass(HbmBinder.java:234)
   at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:152)
   at org.hibernate.cfg.Configuration.add(Configuration.java:362)
   at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:400)
   at org.hibernate.cfg.Configuration.addClass(Configuration.java:468)
   at onfigure(Hiberonfiguration.java:32)
   at iigrate(Migtor.java:24)
   at igrate(Metrator.java:23)
   attionPerformed(Migtion.java:19)
   at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1786)
   at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(AbstractButton.java:1839)
   at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420)
   at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258)
   at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:245)
   at java.awt.Component.processMouseEvent(Component.java:5100)
   at java.awt.Component.processEvent(Component.java:4897)
   at java.awt.Container.processEvent(Container.java:1569)
   at java.awt.Component.dispatchEventImpl(Component.java:3615)
   at java.awt.Container.dispatchEventImpl(Container.java:1627)
   at java.awt.Component.dispatchEvent(Component.java:3477)
   at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3483)
   at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3198)
   at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3128)
   at java.awt.Container.dispatchEventImpl(Container.java:1613)
   at java.awt.Window.dispatchEventImpl(Window.java:1606)
   at java.awt.Component.dispatchEvent(Component.java:3477)
   at java.awt.EventQueue.dispatchEvent(EventQueue.java:456)
   at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201)
   at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
   at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)
   at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)
   at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)
Exception: [Error reading resource: Pet.hbm.xml][org.hibernate.MappingException: duplicate import: Pet]25-set-2005 14.03.47 org.hibernate.cfg.Configuration secondPassCompile
INFO: processing extends queue
25-set-2005 14.03.47 org.hibernate.cfg.Configuration secondPassCompile
INFO: processing collection mappings
25-set-2005 14.03.47 org.hibernate.cfg.Configuration secondPassCompile
INFO: processing association property references
25-set-2005 14.03.47 org.hibernate.cfg.Configuration secondPassCompile
INFO: processing foreign key constraints
25-set-2005 14.03.47 org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Using Hibernate built-in connection pool (not for production use!)
25-set-2005 14.03.47 org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Hibernate connection pool size: 20
25-set-2005 14.03.47 org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: autocommit mode: false
25-set-2005 14.03.47 org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost/e2
25-set-2005 14.03.47 org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: connection properties: {user=root, password=****}
25-set-2005 14.03.47 org.hibernate.cfg.SettingsFactory buildSettings
INFO: RDBMS: MySQL, version: 4.1.13a-Debian_3-log

25-set-2005 14.03.47 org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC driver: MySQL-AB JDBC Driver, version: mysql-connector-java-3.1.10 ( $Date: 2005/05/19 15:52:23 $, $Revision: 1.1.2.2 $ )
25-set-2005 14.03.47 org.hibernate.dialect.Dialect <init>
INFO: Using dialect: org.hibernate.dialect.MySQLDialect
25-set-2005 14.03.47 org.hibernate.transaction.TransactionFactoryFactory buildTransactionFactory
INFO: Using default transaction strategy (direct JDBC transactions)
25-set-2005 14.03.47 org.hibernate.transaction.TransactionManagerLookupFactory getTransactionManagerLookup
INFO: No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
25-set-2005 14.03.47 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Automatic flush during beforeCompletion(): disabled
25-set-2005 14.03.47 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Automatic session close at end of transaction: disabled
25-set-2005 14.03.47 org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC batch size: 15
25-set-2005 14.03.47 org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC batch updates for versioned data: disabled
25-set-2005 14.03.47 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Scrollable result sets: enabled
25-set-2005 14.03.47 org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC3 getGeneratedKeys(): enabled
25-set-2005 14.03.47 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Connection release mode: null
25-set-2005 14.03.47 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Maximum outer join fetch depth: 2
25-set-2005 14.03.47 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Default batch fetch size: 1
25-set-2005 14.03.47 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Generate SQL with comments: disabled
25-set-2005 14.03.47 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Order SQL updates by primary key: disabled
25-set-2005 14.03.47 org.hibernate.cfg.SettingsFactory createQueryTranslatorFactory
INFO: Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
25-set-2005 14.03.47 org.hibernate.hql.ast.ASTQueryTranslatorFactory <init>
INFO: Using ASTQueryTranslatorFactory
25-set-2005 14.03.47 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Query language substitutions: {}
25-set-2005 14.03.47 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Second-level cache: enabled
25-set-2005 14.03.47 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Query cache: disabled
25-set-2005 14.03.47 org.hibernate.cfg.SettingsFactory createCacheProvider
INFO: Cache provider: org.hibernate.cache.EhCacheProvider
25-set-2005 14.03.47 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Optimize cache for minimal puts: disabled
25-set-2005 14.03.47 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Structured second-level cache entries: disabled
25-set-2005 14.03.47 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Echoing all SQL to stdout
25-set-2005 14.03.47 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Statistics: disabled
25-set-2005 14.03.47 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Deleted entity synthetic identifier rollback: disabled
25-set-2005 14.03.47 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Default entity-mode: pojo
25-set-2005 14.03.47 org.hibernate.impl.SessionFactoryImpl <init>
INFO: building session factory
25-set-2005 14.03.47 org.hibernate.impl.SessionFactoryObjectFactory addInstance
INFO: Not binding factory to JNDI, no JNDI name configured
25-set-2005 14.03.47 org.hibernate.impl.SessionFactoryImpl checkNamedQueries
INFO: Checking 0 named queries
ImpossibleMigrationException: Impossible to carry out the migration.
   at or.migrate(Metrator.java:25)
   at actionPerformed(Migrction.java:19)
   at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1786)
   at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(AbstractButton.java:1839)
   at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420)
   at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258)
   at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:245)
   at java.awt.Component.processMouseEvent(Component.java:5100)
   at java.awt.Component.processEvent(Component.java:4897)
   at java.awt.Container.processEvent(Container.java:1569)
   at java.awt.Component.dispatchEventImpl(Component.java:3615)
   at java.awt.Container.dispatchEventImpl(Container.java:1627)
   at java.awt.Component.dispatchEvent(Component.java:3477)
   at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3483)
   at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3198)
   at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3128)
   at java.awt.Container.dispatchEventImpl(Container.java:1613)
   at java.awt.Window.dispatchEventImpl(Window.java:1606)
   at java.awt.Component.dispatchEvent(Component.java:3477)
   at java.awt.EventQueue.dispatchEvent(EventQueue.java:456)
   at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201)
   at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
   at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)
   at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)
   at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)


Top
 Profile  
 
 Post subject:
PostPosted: Sun Sep 25, 2005 6:42 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
your log shows you add pet.hbm.xml twice. Do you by any chance have it imported via some extends attribute ?

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Sun Sep 25, 2005 7:18 am 
Newbie

Joined: Sat Aug 27, 2005 2:02 pm
Posts: 13
thanks max,

i'm adding my Pet twice cause i need to use it in both the sessionfactories i'm building..
so to use it in two different DB..

thanks


Top
 Profile  
 
 Post subject:
PostPosted: Sun Sep 25, 2005 9:25 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
you have two imports into the same configuration - that will not happen unless you add it twice.

_________________
Max
Don't forget to rate


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