-->
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.  [ 6 posts ] 
Author Message
 Post subject: Cannot find hibernate.cfg.xml
PostPosted: Fri Apr 23, 2004 12:03 am 
Newbie

Joined: Thu Apr 22, 2004 11:47 pm
Posts: 4
[b]Hibernate version[/b]: 2.1.2

I go through [url]http://www.hibernate.org/hib_docs/reference/html/session-configuration.html[/url]. I tried to use hibernate.cfg.xml instead of hibernate.properties, but seems it didnt try to find hibernate.cfg.xml.

As the document say, hibernate.cfg.xml have to put into root of CLASSPATH. Then I put hibernate.cfg.xml in three different places, but still didnt work.
1. [WEB-INF]\
2. [WEB-INF]\lib\
3. [WEB-INF]\classes\

Do i misunderstand the "root of CLASSPATH" ?

I find that it didnt search hibernate.cfg.xml subsequently when hibernate.properties not found in the log.
[b]Log:[/b]
[i]net.sf.hibernate.cfg.Environment Hibernate 2.1.2
net.sf.hibernate.cfg.Environment hibernate.properties not found
net.sf.hibernate.cfg.Environment using CGLIB reflection optimizer
net.sf.hibernate.cfg.Environment JVM does not support Statement.getGeneratedKeys()
net.sf.hibernate.cfg.Environment JVM does not support LinkedHasMap, LinkedHashSet - ordered maps and sets disabled
net.sf.hibernate.cfg.Environment using workaround for JVM bug in java.sql.Timestamp
net.sf.hibernate.cfg.Configuration Mapping resource: hibernate/Testing.hbm.xml
net.sf.hibernate.cfg.Binder Mapping class: hibernate.Testing -> testing
net.sf.hibernate.cfg.Configuration processing one-to-many association mappings
net.sf.hibernate.cfg.Configuration processing one-to-one association property references
net.sf.hibernate.cfg.Configuration processing foreign key constraints
net.sf.hibernate.cfg.SettingsFactory No dialect set - using GenericDialect: The dialect was not set. Set the property hibernate.dialect.
net.sf.hibernate.dialect.Dialect Using dialect: net.sf.hibernate.dialect.GenericDialect
net.sf.hibernate.cfg.SettingsFactory Use outer join fetching: false
net.sf.hibernate.connection.UserSuppliedConnectionProvider No connection properties specified - the user must supply JDBC connections
net.sf.hibernate.transaction.TransactionManagerLookupFactory No TransactionManagerLookup configured (in JTA environment, use of process level read-write cache is not recommended)
net.sf.hibernate.cfg.SettingsFactory Use scrollable result sets: false
net.sf.hibernate.cfg.SettingsFactory Use JDBC3 getGeneratedKeys(): false
net.sf.hibernate.cfg.SettingsFactory Optimize cache for minimal puts: false
net.sf.hibernate.cfg.SettingsFactory Query language substitutions: {}
net.sf.hibernate.cfg.SettingsFactory cache provider: net.sf.ehcache.hibernate.Provider
net.sf.hibernate.cfg.Configuration instantiating and configuring caches
net.sf.hibernate.impl.SessionFactoryImpl building session factory
net.sf.hibernate.impl.SessionFactoryObjectFactory no JNDI name configured
SRVE0026E: [Servlet Error]-[ControllerServlet]: java.lang.UnsupportedOperationException: The user must supply a JDBC connection
at net.sf.hibernate.connection.UserSuppliedConnectionProvider.getConnection(UserSuppliedConnectionProvider.java:32)
at net.sf.hibernate.impl.BatcherImpl.openConnection(BatcherImpl.java:278)
at net.sf.hibernate.impl.SessionImpl.connect(SessionImpl.java:3264)
at net.sf.hibernate.impl.SessionImpl.connection(SessionImpl.java:3244)
at net.sf.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:40)
at net.sf.hibernate.transaction.JDBCTransactionFactory.beginTransaction(JDBCTransactionFactory.java:19)
at net.sf.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:2195)
at HibernateTester.doIt(HibernateTester.java:53)
at ControllerServlet.doGet(ControllerServlet.java:24)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java(Compiled Code))
at com.ibm.ws.webcontainer.servlet.StrictServletInstance.doService(StrictServletInstance.java(Compiled Code))
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._service(StrictLifecycleServlet.java(Compiled Code))
at com.ibm.ws.webcontainer.servlet.IdleServletState.service(StrictLifecycleServlet.java(Compiled Code))
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.service(StrictLifecycleServlet.java(Inlined Compiled Code))
at com.ibm.ws.webcontainer.servlet.ServletInstance.service(ServletInstance.java(Compiled Code))
at com.ibm.ws.webcontainer.servlet.ValidServletReferenceState.dispatch(ValidServletReferenceState.java(Compiled Code))
at com.ibm.ws.webcontainer.servlet.ServletInstanceReference.dispatch(ServletInstanceReference.java(Inlined Compiled Code))
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java(Compiled Code))
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java(Compiled Code))
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java(Compiled Code))
at com.ibm.ws.webcontainer.srt.WebAppInvoker.doForward(WebAppInvoker.java:79)
at com.ibm.ws.webcontainer.srt.WebAppInvoker.handleInvocationHook(WebAppInvoker.java:199)
at com.ibm.ws.webcontainer.cache.invocation.CachedInvocation.handleInvocation(CachedInvocation.java:71)
at com.ibm.ws.webcontainer.srp.ServletRequestProcessor.dispatchByURI(ServletRequestProcessor.java:182)
at com.ibm.ws.webcontainer.oselistener.OSEListenerDispatcher.service(OSEListener.java:331)
at com.ibm.ws.webcontainer.http.HttpConnection.handleRequest(HttpConnection.java:56)
at com.ibm.ws.http.HttpConnection.readAndHandleRequest(HttpConnection.java:432)
at com.ibm.ws.http.HttpConnection.run(HttpConnection.java(Compiled Code))
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java(Compiled Code))[/i]



[b]hibernate.cfg.xml[/b]:
[i]<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 2.0//EN"

"http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">

<hibernate-configuration>

<!-- a SessionFactory instance listed as /jndi/name -->
<session-factory name="java:comp/env/hibernate/SessionFactory">

<!-- properties -->
<property name="connection.datasource">jdbc/pru_ais</property>
<property name="dialect">net.sf.hibernate.dialect.SybaseDialect</property>
<property name="show_sql">true</property>
<property name="use_outer_join">true</property>
<property name="transaction.manager_lookup_class">net.sf.hibernate.transaction.WebSphereTransactionManagerLookup</property>
<property name="transaction.factory_class">net.sf.hibernate.transaction.JTATransactionFactory</property>
<property name="jta.UserTransaction">java:comp/UserTransaction</property>

<!-- mapping files -->
<mapping resource="hibernate/Testing.hbm.xml"/>

</session-factory>

</hibernate-configuration>[/i]


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 23, 2004 4:21 am 
Beginner
Beginner

Joined: Tue Apr 20, 2004 12:07 pm
Posts: 21
Quote:
net.sf.hibernate.cfg.Configuration Mapping resource: hibernate/Testing.hbm.xml


It does find the Hibernate mapping file according to this log entry.
There is something else wrong.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 23, 2004 4:53 am 
Newbie

Joined: Thu Apr 22, 2004 11:47 pm
Posts: 4
i am sorry to mislead you.

Since I configure for hiberate.Testing.class in the code, so it shows the mapping correctly.

[i]SessionFactory sf = new Configuration().addClass(hibernate.Testing.class).buildSessionFactory();[/i]


Here is the detail code to open the session.
Session session = null;
Transaction tx = null;
try {
SessionFactory sf = new Configuration().addClass(hibernate.Testing.class).buildSessionFactory();
session = sf.openSession();

} catch ( MappingException me ) {
me.printStackTrace();


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 23, 2004 5:00 am 
Beginner
Beginner

Joined: Thu Mar 25, 2004 9:13 am
Posts: 20
I am having the exact same problem... can someone say where in a web-app the hibernate .cfg.xml should be? I also tried almost everything possible...

_________________
Oren Gross


Top
 Profile  
 
 Post subject: Solution
PostPosted: Fri Apr 23, 2004 6:19 am 
Newbie

Joined: Thu Apr 22, 2004 11:47 pm
Posts: 4
I knew what i did wrong.

It works fine for that ~~~
SessionFactory sf = new Configuration().configure().buildSessionFactory();
//SessionFactory sf = new Configuration().addClass(hibernate.Testing.class).buildSessionFactory();


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 23, 2004 7:58 am 
Beginner
Beginner

Joined: Thu Mar 25, 2004 9:13 am
Posts: 20
Ho.... now I see what you are saying... Right - works for me as well.
Cool, thanks.

_________________
Oren Gross


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