-->
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: Problem with buildSessionFactory method
PostPosted: Thu May 04, 2006 3:17 am 
Newbie

Joined: Thu May 04, 2006 3:11 am
Posts: 7
Hi! i have problems with hibernate v2.1, I recieve the follow message at tomcat:

Full stack trace of any exception that occurs:

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: Error reading resource: /gatos/gato.hbm.xml
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:254)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2415)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:594)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:392)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:565)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:619)
at java.lang.Thread.run(Thread.java:534)

Hibernate version:2.1

Mapping documents:I have only a simple mapping file

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping package="gatos">
<class name="gato" table="gato">
<id name="id">
<column name="id" type="java.lang.Integer"/>
<generator class="increment"/>
</id>

<property name="nombre" column="nombre" type="java.lang.String" update="true" insert="true"/>
</class>
</hibernate-mapping>

Code between sessionFactory.openSession() and session.close():

net.sf.hibernate.SessionFactory sessionFactory = null;
net.sf.hibernate.Session s = null;
net.sf.hibernate.Transaction transaction = null;
Configuration configuration = new Configuration();
sessionFactory = configuration.configure().buildSessionFactory();
//------------
gato gato = new gato();
gato.setNombre("aaa");
try{
s = sessionFactory.openSession();
transaction = s.beginTransaction();
s.save(gato);
transaction.commit();
}catch(Exception error){
out.print(error.getMessage());
}finally{
s.close();
}

Name and version of the database you are using:

Im using Mysql v4.0.16

The generated SQL (show_sql=true):

mysql> create table gato(
-> id int(4) primary key auto_increment,
-> nombre varchar(10));
Query OK, 0 rows affected (0.03 sec)

Debug level Hibernate log excerpt:

My config file of hibernate is same like this:

<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">

<hibernate-configuration>

<session-factory>

<!-- Database connection settings -->
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.url">jdbc:mysql://localhost/gato</property>
<property name="connection.username">root</property>
<property name="connection.password">root</property>

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

<mapping resource="/gatos/gato.hbm.xml"/>

</session-factory>

</hibernate-configuration>


--------------------------------

Can you help me please? I was all morning trying to make it run

Many thanks!


Last edited by ueshiba on Thu May 04, 2006 7:36 am, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Thu May 04, 2006 3:44 am 
Senior
Senior

Joined: Mon Aug 22, 2005 5:45 am
Posts: 146
I have no clue why your hbm is being red in your jsp-file.
But have you made sure your hbm-file is in classpath?

_________________
Please don't forget to give credit, if my posting helped to solve your problem.


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 04, 2006 3:49 am 
Newbie

Joined: Fri Apr 28, 2006 1:09 pm
Posts: 9
Two things to check;

1) The file is called GATO not GATOS, you seem to be using GATOS in your hbm.xml and package names, but GATO in your filename.

2) Can you check the gato.hbm.xml file in the gatos package of your class path NOT in a gatos directory of your webapp (i.e. in a package called gatos in a jar file or in /WEB-INF/classes/gatos).


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 04, 2006 3:55 am 
Newbie

Joined: Thu May 04, 2006 3:11 am
Posts: 7
I have the files in a package called gatos:

The structure of the files is...

gatos >> gato.java , gato.hbm.xml
hibernate.cfg.xml

And a JSP file that manage the files

Sorry for my english


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 04, 2006 4:46 am 
Newbie

Joined: Fri Apr 28, 2006 1:09 pm
Posts: 9
Can you post a complete list of all the files in the webapp and where they are (including JSPs, the WEB-INF directory).

For example;


index.jsp
WEB-INF\web.xml
WEB-INF\classes\hibernate.cfg.xml
.....


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 04, 2006 4:57 am 
Newbie

Joined: Thu May 04, 2006 3:11 am
Posts: 7
index.jsp
WEB-INF\web.xml
WEB-INF\classes\hibernate.cfg.xml
WEB-INF\classes\gatos\gato.class
WEB-INF\classes\gatos\gato.hbm.xml


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 04, 2006 6:41 am 
Newbie

Joined: Thu May 04, 2006 3:11 am
Posts: 7
i think i fix a few the problem, but now i have another problem :

Code:
org.apache.jasper.JasperException: net/sf/cglib/core/KeyFactory
   at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:254)
   at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
   at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
   at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
   at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
   at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
   at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
   at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
   at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
   at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2415)
   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
   at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
   at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
   at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
   at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
   at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
   at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
   at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
   at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
   at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
   at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
   at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:594)
   at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:392)
   at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:565)
   at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:619)
   at java.lang.Thread.run(Thread.java:534)

root cause


If i see the trace:

Code:
04-may-2006 12:35:32 net.sf.hibernate.cfg.Environment <clinit>
INFO: Hibernate 2.1 final
04-may-2006 12:35:32 net.sf.hibernate.cfg.Environment <clinit>
INFO: hibernate.properties not found
04-may-2006 12:35:32 net.sf.hibernate.cfg.Environment <clinit>
INFO: using CGLIB reflection optimizer
04-may-2006 12:35:32 net.sf.hibernate.cfg.Configuration configure
INFO: configuring from resource: /hibernate.cfg.xml
04-may-2006 12:35:32 net.sf.hibernate.cfg.Configuration getConfigurationInputStream
INFO: Configuration resource: /hibernate.cfg.xml
04-may-2006 12:35:32 net.sf.hibernate.cfg.Configuration addResource
INFO: Mapping resource: es/gato.hbm.xml
04-may-2006 12:35:32 net.sf.hibernate.cfg.Binder bindRootClass
INFO: Mapping class: es.gato -> gato
04-may-2006 12:35:32 net.sf.hibernate.cfg.Configuration doConfigure
INFO: Configured SessionFactory: null
04-may-2006 12:35:32 net.sf.hibernate.cfg.Configuration secondPassCompile
INFO: processing one-to-many association mappings
04-may-2006 12:35:32 net.sf.hibernate.cfg.Configuration secondPassCompile
INFO: processing one-to-one association property references
04-may-2006 12:35:32 net.sf.hibernate.cfg.Configuration secondPassCompile
INFO: processing foreign key constraints
04-may-2006 12:35:32 net.sf.hibernate.dialect.Dialect <init>
INFO: Using dialect: net.sf.hibernate.dialect.MySQLDialect
04-may-2006 12:35:32 net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: Use outer join fetching: true
04-may-2006 12:35:32 net.sf.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Using Hibernate built-in connection pool (not for production use!)
04-may-2006 12:35:32 net.sf.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Hibernate connection pool size: 20
04-may-2006 12:35:32 net.sf.hibernate.connection.DriverManagerConnectionProvider configure
INFO: using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost/gato
04-may-2006 12:35:32 net.sf.hibernate.connection.DriverManagerConnectionProvider configure
INFO: connection properties: {user=root, password=root}
04-may-2006 12:35:32 net.sf.hibernate.transaction.TransactionManagerLookupFactory getTransactionManagerLookup
INFO: No TransactionManagerLookup configured (in JTA environment, use of process level read-write cache is not recommended)
04-may-2006 12:35:32 net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: Use scrollable result sets: true
04-may-2006 12:35:32 net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC 2 max batch size: 15
04-may-2006 12:35:32 net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: Query language substitutions: {}
04-may-2006 12:35:32 net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: cache provider: net.sf.ehcache.hibernate.Provider
04-may-2006 12:35:32 net.sf.hibernate.cfg.Configuration configureCaches
INFO: instantiating and configuring caches


I think that the problem is that the SessionFactory object cant be created correctly cause the hibernate config file make something wrong :(

The Jsp code:

Code:
net.sf.hibernate.SessionFactory sessionFactory;
net.sf.hibernate.Session s = null;
net.sf.hibernate.Transaction transaction = null;
   Configuration configuration = new Configuration();
   sessionFactory = configuration.configure().buildSessionFactory();
//------------
gato gato = new gato();
gato.setNombre("aaa");
try{
   s = sessionFactory.openSession();
   transaction = s.beginTransaction();
   s.save(gato);
   transaction.commit();
}catch(Exception error){
   out.print(error.getMessage());
}finally{
   s.close();
}


Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 04, 2006 12:25 pm 
Newbie

Joined: Thu May 04, 2006 3:11 am
Posts: 7
up


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 05, 2006 2:47 am 
Newbie

Joined: Thu May 04, 2006 3:11 am
Posts: 7
i still with the same problem, plz help :(


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 05, 2006 3:42 am 
Newbie

Joined: Thu May 04, 2006 3:11 am
Posts: 7
problem fixed :D

My *** eclipse was deleting the libs each time i restart tomcat (grr)

Thanks to all


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.