-->
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: Hibernate-C3P0 configuration issue
PostPosted: Thu Jan 08, 2004 12:07 pm 
Newbie

Joined: Tue Jan 06, 2004 3:49 pm
Posts: 11
Location: Montreal, Canada
I'm new to hibernate. I have been trying to set it up for the past few days. I went through the docs, the FAQ and searched the forum. On Hibernate start-up, we get an XML parser error, the parser does not accept our simplistic configuration and I can not figure out why :(

Thanking all of you in advance for any help!


Objective
---------------
Configure for Hibernate provided JDBC connection with C3P0 connection pooling

Problem
-------------
XML parser does not accept our simplistic configuration

System set-up
------------------------
Solaris 8
Tomcat 4.1.24
Hibernate 2.1.1

Configuration file (hibernate.cfg.xml)
-------------------------------------------

<?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>
<session-factory>
<!-- hibernate.connection.provider_class net.sf.hibernate.connection.C3P0ConnectionProvider -->
<property name="c3p0.min_size">2</property>
<property name="c3p0.max_size">10</property>
<property name="c3p0.max_statements">100</property>
<property name="c3p0.timeout">100</property>
<property name="c3p0.validate">true</property>

<property name="connection.driver_class">com.sybase.jdbc2.jdbc.SybDriver</property>
<property name="connection.url">jdbc:sybase:Tds:jardin:4100/patate</property>
<property name="connection.username">auser</property>
<property name="connection.password">apassword</property>
<property name="dialect">net.sf.hibernate.dialect.SybaseDialect</property>
<property name="show_sql">false</property>

<mapping resource="Customer.hbm.xml"/>
<mapping resource="HibernateTestUser.hbm.xml"/>
</session-factory>
</hibernate-configuration>


log
------
2004-01-08 10:49:50 INFO [cfg.Environment] - Hibernate 2.1.1
2004-01-08 10:49:50 INFO [cfg.Environment] - hibernate.properties not found
2004-01-08 10:49:50 INFO [cfg.Environment] - using CGLIB reflection optimizer
2004-01-08 10:49:50 INFO [cfg.Configuration] - configuring from resource: /hibernate.cfg.xml
2004-01-08 10:49:50 INFO [cfg.Configuration] - Configuration resource: /hibernate.cfg.xml
2004-01-08 10:49:50 DEBUG [util.DTDEntityResolver] - trying to locate http://hibernate.sourceforge.net/hibern ... on-2.0.dtd in classpath under net/sf/hibernate/
2004-01-08 10:49:50 DEBUG [util.DTDEntityResolver] - found http://hibernate.sourceforge.net/hibern ... on-2.0.dtd in classpath
2004-01-08 10:49:51 ERROR [util.XMLHelper] - Error parsing XML: /hibernate.cfg.xml(30) The content of element type "session-factory" must match "(property*,mapping+,(class-cache|collection-cache|jcs-class-cache|jcs-collection-cache)*)".
2004-01-08 10:49:51 ERROR [cfg.Configuration] - problem parsing configuration/hibernate.cfg.xml
net.sf.hibernate.MappingException: invalid configuration
at net.sf.hibernate.cfg.Configuration.doConfigure(Configuration.java:902)
at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:845)
at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:831)
at se.ericsson.lmc.common.model.util.HibernateUtil.<clinit>(HibernateUtil.java:15)
at se.ericsson.lmc.ccl.model.CclApplication.login(CclApplication.java:84)
at se.ericsson.lmc.ccl.struts.action.LoginAction.executeAction(Unknown Source)
at se.ericsson.lmc.ccl.struts.action.CclBaseAction.execute(Unknown Source)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
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.valves.AccessLogValve.invoke(AccessLogValve.java:509)
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.ajp.tomcat4.Ajp13Processor.process(Ajp13Processor.java:466)
at org.apache.ajp.tomcat4.Ajp13Processor.run(Ajp13Processor.java:585)
at java.lang.Thread.run(Thread.java:536)
Caused by: org.xml.sax.SAXParseException: The content of element type "session-factory" must match "(property*,mapping+,(class-cache|collection-cache|jcs-class-cache|jcs-collection-cache)*)".
at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.dtd.XMLDTDValidator.handleEndElement(Unknown Source)
at org.apache.xerces.impl.dtd.XMLDTDValidator.endElement(Unknown Source)
at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.dom4j.io.SAXReader.read(SAXReader.java:339)
at net.sf.hibernate.cfg.Configuration.doConfigure(Configuration.java:901)
... 40 more[code][/code]


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 08, 2004 12:18 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Your configuration is good. Did you copy any library (except the JDBC driver) to TOMCAT/common/lib or any other Tomcat classpath? What libraries are in your WEB-INF/lib? Double check that Hibernate is really loading the hibernate.cfg.xml you posted.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 08, 2004 1:13 pm 
Newbie

Joined: Tue Jan 06, 2004 3:49 pm
Posts: 11
Location: Montreal, Canada
Thanks for the lightning fast reply Christian.

The JDBC driver is not in ./tomcat/common/lib, since we are not using DBCP bundled with Tomcat but C3P0, we were hoping it was possible to store the driver elsewhere, is it possible? (we are tying to keep ./tomcat/common/lib as clean as possible).

Anyhow, we will run a test with the driver stored in the ./tomcat/common/lib and leave it there if necessary.


Here is more details on our set-up:

Our ./tomcat/common/lib contains only the standard libraries
activation.jar
ant.jar
commons-collections.jar
commons-dbcp.jar
commons-logging-api.jar
commons-pool.jar
jasper-compiler.jar
jasper-runtime.jar
jdbc2_0-stdext.jar
jndi.jar
jta.jar
mail.jar
naming-common.jar
naming-factory.jar
naming-resources.jar
servlet.jar

Here are the libraries which I added in the context classpath (./webapps/WEB-INF/lib)
c3p0.jar
cglib2.jar
dom4j.jar
hibernate2.jar
odmg.jar
(required commons are also there)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 08, 2004 1:57 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Its ok to have the JDBC driver in your webapp classpath if you don't use Tomcats connection pooling. I'm lost with your parsing error problem though. Can you try a newer version of Tomcat 4.1.*?

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 08, 2004 7:59 pm 
Newbie

Joined: Wed Jan 07, 2004 7:59 pm
Posts: 11
Location: Medellon, Colombia
Your problem might be related to the xerces library. I couldn't find xerces.jar in the file list you've posted.

You might want to use the xerces.jar included in the hibernate distribution files placing it under your webapp/WEB-INF/lib directory.

Other possible cause might be an other hibernate.cfg.xml in your classpath. The stackTrace indacates line number 30, your cfg file is roughly 20 lines long.

_________________
Andres Camilo Bustamante
Analista Arquitectura Informaca


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 09, 2004 3:08 pm 
Newbie

Joined: Tue Jan 06, 2004 3:49 pm
Posts: 11
Location: Montreal, Canada
Problem was fixed by using Tomcat 4.1.27. Though I'm not saying there was a compatibility issue with Tomcat 4.1.24. I think we have exactly the same setup now but I guess we missed something...

Thanks again for the help!


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.