aspose file tools*
The moose likes Object Relational Mapping and the fly likes Error reading resource: hbm.xml file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Error reading resource: hbm.xml file" Watch "Error reading resource: hbm.xml file" New topic
Author

Error reading resource: hbm.xml file

S.R.K.Vivek Raju
Ranch Hand

Joined: Sep 23, 2004
Posts: 58
Hi all

I have written a simple program to store certain fields into mysql database.
I have used a hibernate.cfg.xml file and is stored in the WEB-INF classes and the classpath is set.

Now when compiling the code the following message comes up on the jboss console.

12:35:19,156 INFO [STDOUT] Hibernate Exception :Error reading resource: com/businessob
jects/UserDataBO.hbm.xml
12:37:04,187 INFO [STDOUT] ************Hello World 1************
12:37:04,187 INFO [Configuration] configuring from resource: /hibernate.cfg.xml
12:37:04,187 INFO [Configuration] Configuration resource: /hibernate.cfg.xml
12:37:04,203 INFO [Configuration] Mapping resource: com/businessobjects/UserDataBO.hbm
.xml
12:37:04,203 INFO [HbmBinder] Mapping class: com.businessobjects.UserDataBO -> user
12:37:04,203 INFO [Configuration] Mapping resource: com/businessobjects/ContactDataBO.
hbm.xml
12:37:04,218 INFO [HbmBinder] Mapping class: com.businessobjects.ContactDataBO -> cont
act
12:37:04,218 INFO [Configuration] Mapping resource: com/businessobjects/GroupDataBO.hb
m.xml
12:37:04,234 INFO [HbmBinder] Mapping class: com.businessobjects.GroupDataBO -> group
12:37:04,234 INFO [Configuration] Mapping resource: com/businessobjects/MessageDataBO.
hbm.xml
12:37:04,250 INFO [HbmBinder] Mapping class: com.businessobjects.MessageDataBO -> mess
age
12:37:04,250 INFO [Configuration] Mapping resource: com/businessobjects/EmergencyAlert
DataBO.hbm.xml
12:37:04,265 INFO [HbmBinder] Mapping class: com.businessobjects.EmergencyAlertDataBO
-> emergency
12:37:04,265 INFO [Configuration] Configured SessionFactory: ehaa
12:37:04,265 INFO [Configuration] processing extends queue
12:37:04,265 INFO [Configuration] processing collection mappings
12:37:04,265 INFO [Configuration] processing association property references
12:37:04,265 INFO [Configuration] processing foreign key constraints
12:37:04,265 INFO [Dialect] Using dialect: org.hibernate.dialect.MySQLDialect
12:37:04,265 INFO [SettingsFactory] Maximum outer join fetch depth: 2
12:37:04,265 INFO [SettingsFactory] Default batch fetch size: 1
12:37:04,265 INFO [SettingsFactory] Generate SQL with comments: disabled
12:37:04,265 INFO [SettingsFactory] Order SQL updates by primary key: enabled
12:37:04,265 INFO [SettingsFactory] Query translator: org.hibernate.hql.ast.ASTQueryTr
anslatorFactory
12:37:04,265 INFO [ASTQueryTranslatorFactory] Using ASTQueryTranslatorFactory
12:37:04,265 INFO [SettingsFactory] Query language substitutions: {}
12:37:04,265 INFO [DriverManagerConnectionProvider] Using Hibernate built-in connectio
n pool (not for production use!)
12:37:04,265 INFO [DriverManagerConnectionProvider] Hibernate connection pool size: 20

12:37:04,265 INFO [DriverManagerConnectionProvider] autocommit mode: false
12:37:04,265 INFO [DriverManagerConnectionProvider] using driver: com.mysql.jdbc.Drive
r at URL: jdbc:mysql://localhost:3306/eh
12:37:04,265 INFO [DriverManagerConnectionProvider] connection properties: {user=, pas
sword=}
12:37:04,281 INFO [SettingsFactory] JDBC batch size: 15
12:37:04,281 INFO [SettingsFactory] JDBC batch updates for versioned data: disabled
12:37:04,281 INFO [SettingsFactory] Scrollable result sets: enabled
12:37:04,281 INFO [SettingsFactory] JDBC3 getGeneratedKeys(): enabled
12:37:04,281 INFO [TransactionFactoryFactory] Transaction strategy: org.hibernate.tran
saction.JDBCTransactionFactory
12:37:04,281 INFO [TransactionManagerLookupFactory] No TransactionManagerLookup config
ured (in JTA environment, use of read-write or transactional second-level cache is not
recommended)
12:37:04,281 INFO [SettingsFactory] Automatic flush during beforeCompletion(): disable
d
12:37:04,281 INFO [SettingsFactory] Automatic session close at end of transaction: dis
abled
12:37:04,281 INFO [SettingsFactory] Cache provider: org.hibernate.cache.HashtableCache
Provider
12:37:04,281 INFO [SettingsFactory] Second-level cache: enabled
12:37:04,281 INFO [SettingsFactory] Optimize cache for minimal puts: disabled
12:37:04,281 INFO [SettingsFactory] Structured second-level cache entries: enabled
12:37:04,281 INFO [SettingsFactory] Query cache: disabled
12:37:04,281 INFO [SettingsFactory] Echoing all SQL to stdout
12:37:04,281 INFO [SettingsFactory] Statistics: disabled
12:37:04,281 INFO [SettingsFactory] Deleted entity synthetic identifier rollback: disa
bled
12:37:04,281 INFO [SettingsFactory] Default entity-mode: pojo
12:37:04,281 INFO [SessionFactoryImpl] building session factory
12:37:04,359 INFO [SessionFactoryObjectFactory] Factory name: ehaa
12:37:04,359 INFO [NamingHelper] JNDI InitialContext properties:{}
12:37:04,359 INFO [SessionFactoryObjectFactory] Bound factory to JNDI name: ehaa
12:37:04,359 WARN [SessionFactoryObjectFactory] InitialContext did not implement Event
Context
12:37:04,359 INFO [SessionFactoryImpl] Checking 0 named queries
12:37:04,359 INFO [STDOUT] ************Hello World 2************
12:37:04,359 INFO [Configuration] Mapping resource: com/businessobjects/UserDataBO.hbm
.xml
12:37:04,375 ERROR [Configuration] Could not compile the mapping document
org.hibernate.MappingException: duplicate import: com.businessobjects.UserDataBO
at org.hibernate.cfg.Mappings.addImport(Mappings.java:100)
at org.hibernate.cfg.HbmBinder.bindPersistentClassCommonValues(HbmBinder.java:5
38)
at org.hibernate.cfg.HbmBinder.bindClass(HbmBinder.java:485)
at org.hibernate.cfg.HbmBinder.bindRootClass(HbmBinder.java:231)
at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:149)
at org.hibernate.cfg.Configuration.add(Configuration.java:358)
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:395)
at org.hibernate.cfg.Configuration.addClass(Configuration.java:463)
at com.dao.RegisterDAO.registerUser(RegisterDAO.java:62)
at com.actions.RegisterAction.execute(RegisterAction.java:68)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProces
sor.java:421)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:226)

at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1164)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:415)
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(Application
FilterChain.java:237)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh
ain.java:157)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.ja
va:75)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application
FilterChain.java:186)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh
ain.java:157)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.ja
va:214)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContex
t.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContext
Valve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.ja
va:152)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContex
t.java:104)
at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalVal
ve.java:44)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContex
t.java:102)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssoci
ationValve.java:169)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContex
t.java:102)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137
)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContex
t.java:104)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118
)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContex
t.java:102)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java
:109)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContex
t.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConne
ction(Http11Protocol.java:705)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.jav
a:683)
at java.lang.Thread.run(Thread.java:534)
12:37:04,375 INFO [STDOUT] Hibernate Exception :Error reading resource: com/businessob
jects/UserDataBO.hbm.xml
**************************************************************************************************************************
My DAO code is as follows

try{

System.out.println("************Hello World 1************");
config = new Configuration().configure();
config.buildSessionFactory();
System.out.println("************Hello World 2************");
config.addClass(UserDataBO.class);

System.out.println("************Hello World 3******************");
session = sessionFactory.openSession();

System.out.println("************Hello World 4******************");

System.out.println("**********Creating transaction***************");

session.save(userData);

session.flush();

System.out.println("**************Committing**************");

session.close();
}
catch(HibernateException he)
{
System.out.println("Hibernate Exception :"+he.getLocalizedMessage());
}
return userData;
}
*************************************************************
I am not understanding why it is giving an error reading the the hbm.xml file.

Please advice me

Thanks in advance

With Regards
S.R.K.Vivek Raju.
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Looks like you are trying to add UserDataBO to the SessionFactory config twice. You define it in hibernate.cfg.xml I presume, and add it explicitly with the line:

Do one or the other, not both.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Error reading resource: hbm.xml file