-->
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.  [ 19 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Could not parse configuration: /hibernate.cfg.xml
PostPosted: Tue Apr 11, 2006 5:03 pm 
Newbie

Joined: Tue Apr 11, 2006 4:20 pm
Posts: 14
Required help documentation below.. In the java stack trace, it is pointing to my class file SaveTasks line 18, which is the second line in the below code (cfg.configure().buildSessionFactory();

The application is on a stand alone network that is not connected to the internet and cannot be... I have the configuration file DTD in my WAR file and constructed the configuration xml off the DTD (using eclipse as my IDE). The DTD location in my hibernate.cfg.xml is as follows:

<!DOCTYPE hibernate-configuration SYSTEM "hibernate-configuration-3.0.dtd">

The DTD is located in my classpath (WEB-INF) directory.

My configuration is as follows (left out required elements hib-config and session-factory)... I changed the username and password, but ensured the actual settings are correct.

Code:
<property name="connection.username">username</property>
<property name="connection.password">password</property>
<property name="connection.url">jdbc:mysql://localhost/test</property>
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>

<mapping resource="tasks/TaskForm.hbm.xml"/>


What is causing this problem?

Hibernate version:
3.1
Mapping documents:

Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping SYSTEM "hibernate-mapping-3.0.dtd">
<hibernate-mapping package="tasks">
<class name="TaskForm" table="tasks">
<id name="id" column="id" type="long">
<generator class="native"/>
</id>
<property name="title" type="string" length="100"/>
... several more properties, syntax is correct (triple checked)
</class>
</hibernate-mapping>


Code between sessionFactory.openSession() and session.close():
Code:
Configuration cfg = new Configuration();
SessionFactory sessionFactory = cfg.configure().buildSessionFactory();
Session session = sessionFactory.openSession();

TaskForm taskForm = (TaskForm) form;

session.saveOrUpdate(taskForm);
session.flush();
session.close();


Full stack trace of any exception that occurs:
org.hibernate.HibernateException: Could not parse configuration: /hibernate.cfg.xml
org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1354)
org.hibernate.cfg.Configuration.configure(Configuration.Java:1288)
org.hibernate.cfg.Configuration.configure(Configuration.java:1274)
tasks.SaveTask.execute(SaveTask.java:18)

Name and version of the database you are using:
MySQL 5.0

The generated SQL (show_sql=true):
None yet

Debug level Hibernate log excerpt:
Huh?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 11, 2006 6:29 pm 
Newbie

Joined: Wed Apr 05, 2006 5:58 pm
Posts: 13
Is that the full stack trace? Generally I find the stack is a bit longer and includes some valuable information when hibernate.hbm.xml is flawed.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 11, 2006 8:07 pm 
Newbie

Joined: Tue Apr 11, 2006 4:20 pm
Posts: 14
the application i am developing is on a stand alone network... meaning not connected to the internet. I have no means of coping the full thing over to this message board. I plan not to type out the complete stack... Is there something in particular I should look for? The only noticable item I found was the line 18 in my code. But basically that tells me the configure() function could not completly parse the hibernate.cfg.xml file. Does this mean I have a malformed xml file? Possibly a typo?

_________________
Cheers,
Ken


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 12, 2006 3:59 am 
Expert
Expert

Joined: Thu Sep 22, 2005 10:29 am
Posts: 285
Location: Almassera/Valencia/Spain/EU/Earth/Solar system/Milky Way/Local Group/Virgo Supercluster
Post the full content of your hibernate.cfg.xml please


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 12, 2006 8:29 am 
Newbie

Joined: Tue Apr 11, 2006 4:20 pm
Posts: 14
pepelnm wrote:
Post the full content of your hibernate.cfg.xml please


Code:
<!DOCTYPE hibernate-configuration SYSTEM "hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="connection.username">username</property>
<property name="connection.password">password</property>
<property name="connection.url">jdbc:mysql://localhost/test</property>
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<mapping resource="tasks/TaskForm.hbm.xml"/>
</session-factory>
</hibernate-configuration>

_________________
Cheers,
Ken


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 12, 2006 8:43 am 
Expert
Expert

Joined: Thu Sep 22, 2005 10:29 am
Posts: 285
Location: Almassera/Valencia/Spain/EU/Earth/Solar system/Milky Way/Local Group/Virgo Supercluster
The problem is that your system cannot find the hibernate-mapping-3.0.dtd file.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 12, 2006 9:52 am 
Newbie

Joined: Tue Apr 11, 2006 4:20 pm
Posts: 14
pepelnm wrote:
The problem is that your system cannot find the hibernate-mapping-3.0.dtd file.


I have the DTD and the hibernate.cfg.xml file in the same folder. If the location stated above is not correct, what should I insert instead?

_________________
Cheers,
Ken


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 12, 2006 10:28 am 
Expert
Expert

Joined: Thu Sep 22, 2005 10:29 am
Posts: 285
Location: Almassera/Valencia/Spain/EU/Earth/Solar system/Milky Way/Local Group/Virgo Supercluster
I don't know.
I told you because that's the error that eclipse tell me if I use
Code:
<!DOCTYPE hibernate-configuration SYSTEM "hibernate-configuration-3.0.dtd">

in that case it looks for c:\eclipse\workspace\hibernate-configuration-3.0.dtd
but if I use
Code:
<!DOCTYPE hibernate-configuration PUBLIC
    "-//Hibernate/Hibernate Configuration DTD//EN"
    "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

I don't have any problem


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 12, 2006 10:41 am 
Newbie

Joined: Tue Apr 11, 2006 5:08 pm
Posts: 4
I'm with the same problem. I think the hibernate.cfg.xml is wrong.

The problem:

Code:
2006-04-12 11:21:43,013 INFO  hibernate.cfg.Environment  -> Hibernate 3.1.3
2006-04-12 11:21:43,030 INFO  hibernate.cfg.Environment  -> loaded properties from resource hibernate.properties: {hibernate.c3p0.timeout=300, hibernate.connection.driver_class=org.gjt.mm.mysql.Driver, hibernate.cglib.use_reflection_optimizer=true, hibernate.c3p0.max_statements=50, hibernate.c3p0.max_size=30, hibernate.dialect=org.hibernate.dialect.MySQLDialect, hibernate.c3p0.idle_test_period=3000, hibernate.c3p0.min_size=5, hibernate.connection.username=root, hibernate.connection.url=jdbc:mysql://192.168.10.100:3306/temp, hibernate.connection.password=****}
2006-04-12 11:21:43,033 INFO  hibernate.cfg.Environment  -> using CGLIB reflection optimizer
2006-04-12 11:21:43,036 INFO  hibernate.cfg.Environment  -> using JDK 1.4 java.sql.Timestamp handling
2006-04-12 11:21:43,118 INFO  hibernate.cfg.Configuration  -> configuring from resource: /hibernate.cfg.xml
2006-04-12 11:21:43,120 INFO  hibernate.cfg.Configuration  -> Configuration resource: /hibernate.cfg.xml
2006-04-12 11:21:43,336 DEBUG hibernate.util.DTDEntityResolver  -> trying to resolve system-id [http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd]
2006-04-12 11:21:43,337 DEBUG hibernate.util.DTDEntityResolver  -> recognized hibernate namespace; attempting to resolve on classpath under org/hibernate/
org.hibernate.HibernateException: Could not parse configuration: /hibernate.cfg.xml
   at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1376)
   at org.hibernate.cfg.Configuration.configure(Configuration.java:1310)
   at org.hibernate.cfg.Configuration.configure(Configuration.java:1296)
   at Main.main(Main.java:16)
Caused by: org.dom4j.DocumentException: null Nested exception: null
   at org.dom4j.io.SAXReader.read(SAXReader.java:484)
   at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1366)
   ... 3 more


The hibernate.cfg.xml:

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

<hibernate-configuration>
   <session-factory>
       <property name="hibernate.connection.driver_class">org.gjt.mm.mysql.Driver</property>

       <property name="hibernate.connection.url">jdbc:mysql://192.168.10.100:3306/temp</property>
       <property name="hibernate.connection.username">root</property>
       <property name="hibernate.connection.password">root</property>

       <property name="show_sql">true</property>
       <property name="dialect">org.hibernate.dialect.MySQLDialect</property>
       
        <!-- Enable Hibernate's automatic session context management -->
        <property name="current_session_context_class">thread</property>

        <!-- Disable the second-level cache  -->
        <property name="hibernate.cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
       
       
       <property name="hibernate.c3p0.max_size">10</property>
       <property name="hibernate.c3p0.min_sizw">2</property>
       <property name="hibernate.c3p0.timeout">5000</property>
       <property name="hibernate.c3p0.max_statements">10</property>
       <property name="hibernate.c3p0.idle_test_period">3000</property>
       <property name="hibernate.c3p0.acquize_increment">2</property>
           
       <mapping resource="hello/Message.hbm.xml"/>
   </session-factory>
</hibernate-configuration>


What you think about?

Thank you.

Leandro

_________________
Leandro Mesquita de Morais


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 12, 2006 10:45 am 
Newbie

Joined: Tue Apr 11, 2006 4:20 pm
Posts: 14
In your property names, should you remove the hibernate.

Example..

<property name ="connection.url">the url</property>



I changed my DOC type to say this
Code:
<!DOCTYPE hibernate-configuration SYSTEM "-//Hibernate/Hibernate Configuration DTD//EN hibernate-configuration-3.0.dtd">


No resolve... If i remove the doctype statement all together, it returns an invalid configuration... I wonder if my problem lies else where.

_________________
Cheers,
Ken


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 12, 2006 11:52 am 
Expert
Expert

Joined: Thu Sep 22, 2005 10:29 am
Posts: 285
Location: Almassera/Valencia/Spain/EU/Earth/Solar system/Milky Way/Local Group/Virgo Supercluster
Take a look at the last answer in this post:
http://forum.hibernate.org/viewtopic.php?t=943281


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 12, 2006 12:20 pm 
Newbie

Joined: Tue Apr 11, 2006 4:20 pm
Posts: 14
pepelnm wrote:
Take a look at the last answer in this post:
http://forum.hibernate.org/viewtopic.php?t=943281


That is interesting, I will give it a shot..

However...

I enabled log4j (didn't have the properties file in my war classpath). After reviewing the logs I found that even though I gave just the file name (i assumed the parser would look in the same directory as the XML file), instead the parser was begining at the root of the tomcat folder! And when I executed the application from eclipse it was looking in the root of the eclipse folder! I guess that is what happens when I specify the SYSTEM property. When I hardcoded the path to the DTD in my hibernate.cfg.xml file, it worked! Then it stumbled when referecing my mapping files...

Could no read mappings from resource

Not sure if it is a simular DTD error, I will hard code the path again.

The only problem I have with this hard coding is that it is hard coded... How can I tell the parser to look in the same folder as the .xml file??? I think that would be the most dynamic way of doing it.

_________________
Cheers,
Ken


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 12, 2006 12:36 pm 
Newbie

Joined: Tue Apr 11, 2006 4:20 pm
Posts: 14
After hard coding the path to the mapping dtd, I was able to get the application to make it further. I guess as a resolution, I could host the DTD files on our web server, change the SYSTEM back to public and point the hibernate.cfg.xml file to that.

Now I am getting this error. I have no idea what it means and now idea of how to fix it. Anyone know?

Code:
12:32:23,288  INFO Environment:479 - Hibernate 3.1
12:32:23,335  INFO Environment:509 - hibernate.properties not found
12:32:23,335  INFO Environment:525 - using CGLIB reflection optimizer
12:32:23,335  INFO Environment:555 - using JDK 1.4 java.sql.Timestamp handling
12:32:23,850  INFO Configuration:1286 - configuring from resource: /hibernate.cfg.xml
12:32:23,850  INFO Configuration:1263 - Configuration resource: /hibernate.cfg.xml
12:32:24,288  INFO Configuration:468 - Reading mappings from resource: chgRequests/TaskForm.hbm.xml
12:32:24,710  INFO HbmBinder:265 - Mapping class: chgRequests.TaskForm.TaskForm -> change_request
12:32:24,866  INFO Configuration:1397 - Configured SessionFactory: null
12:32:24,866  INFO Configuration:1022 - processing extends queue
12:32:24,866  INFO Configuration:1026 - processing collection mappings
12:32:24,866  INFO Configuration:1035 - processing association property references
12:32:24,866  INFO Configuration:1057 - processing foreign key constraints
12:32:25,397  INFO DriverManagerConnectionProvider:41 - Using Hibernate built-in connection pool (not for production use!)
12:32:25,397  INFO DriverManagerConnectionProvider:42 - Hibernate connection pool size: 20
12:32:25,397  INFO DriverManagerConnectionProvider:45 - autocommit mode: false
12:32:25,413  INFO DriverManagerConnectionProvider:80 - using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost:3306/configmanagement
12:32:25,413  INFO DriverManagerConnectionProvider:86 - connection properties: {user=web, password=****}
12:32:25,960  INFO SettingsFactory:77 - RDBMS: MySQL, version: 5.0.15-nt
12:32:25,960  INFO SettingsFactory:78 - JDBC driver: MySQL-AB JDBC Driver, version: mysql-connector-java-3.1.12 ( $Date: 2005-11-17 15:53:48 +0100 (Thu, 17 Nov 2005) $, $Revision$ )
12:32:26,210  INFO Dialect:103 - Using dialect: org.hibernate.dialect.MySQLInnoDBDialect
12:32:26,257  INFO TransactionFactoryFactory:31 - Using default transaction strategy (direct JDBC transactions)
12:32:26,272  INFO TransactionManagerLookupFactory:33 - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
12:32:26,272  INFO SettingsFactory:125 - Automatic flush during beforeCompletion(): disabled
12:32:26,272  INFO SettingsFactory:129 - Automatic session close at end of transaction: disabled
12:32:26,272  INFO SettingsFactory:136 - JDBC batch size: 15
12:32:26,272  INFO SettingsFactory:139 - JDBC batch updates for versioned data: disabled
12:32:26,288  INFO SettingsFactory:144 - Scrollable result sets: enabled
12:32:26,288  INFO SettingsFactory:152 - JDBC3 getGeneratedKeys(): enabled
12:32:26,288  INFO SettingsFactory:160 - Connection release mode: auto
12:32:26,288  INFO SettingsFactory:184 - Maximum outer join fetch depth: 2
12:32:26,288  INFO SettingsFactory:187 - Default batch fetch size: 1
12:32:26,288  INFO SettingsFactory:191 - Generate SQL with comments: disabled
12:32:26,288  INFO SettingsFactory:195 - Order SQL updates by primary key: disabled
12:32:26,288  INFO SettingsFactory:338 - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
12:32:26,319  INFO ASTQueryTranslatorFactory:21 - Using ASTQueryTranslatorFactory
12:32:26,319  INFO SettingsFactory:203 - Query language substitutions: {}
12:32:26,319  INFO SettingsFactory:209 - Second-level cache: enabled
12:32:26,319  INFO SettingsFactory:213 - Query cache: disabled
12:32:26,319  INFO SettingsFactory:325 - Cache provider: org.hibernate.cache.EhCacheProvider
12:32:26,335 ERROR [action]:253 - Servlet.service() for servlet action threw exception
java.lang.NoClassDefFoundError: net/sf/ehcache/CacheException
   at java.lang.Class.getDeclaredConstructors0(Native Method)
   at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
   at java.lang.Class.getConstructor0(Unknown Source)
   at java.lang.Class.newInstance0(Unknown Source)
   at java.lang.Class.newInstance(Unknown Source)
   at org.hibernate.cfg.SettingsFactory.createCacheProvider(SettingsFactory.java:327)
   at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:219)
   at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:1859)
   at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1152)
   at chgRequests.SaveTask.execute(SaveTask.java:18)
   at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
   at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
   at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
   at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
   at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
   at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:868)
   at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:663)
   at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
   at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
   at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
   at java.lang.Thread.run(Unknown Source)

_________________
Cheers,
Ken


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 12, 2006 2:40 pm 
Expert
Expert

Joined: Thu Sep 22, 2005 10:29 am
Posts: 285
Location: Almassera/Valencia/Spain/EU/Earth/Solar system/Milky Way/Local Group/Virgo Supercluster
try adding

Code:
        <!-- Disable the second-level cache  -->
        <property name="hibernate.cache.provider_class">org.hibernate.cache.NoCacheProvider</property>


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 12, 2006 3:01 pm 
Newbie

Joined: Tue Apr 11, 2006 4:20 pm
Posts: 14
pepelnm wrote:
try adding

Code:
        <!-- Disable the second-level cache  -->
        <property name="hibernate.cache.provider_class">org.hibernate.cache.NoCacheProvider</property>



that would work, but i forgot to include the ehcache.jar file... I included that, we are cooking...

I am at the point now the application works. The sql shows the insert command however, the values are ?, ?, ?, .... etc

I have a struts action form. The actionForm takes in the values from a web form, 8 fields total. Each field has a get and set method plus a get and set method for an id. I want to take the values from the actionForm and persist them to the database. I can system.out.println(actionForm.getName) and it works... but when I issue a session.save(actionForm) the values are not present... Whats the deal?

_________________
Cheers,
Ken


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 19 posts ]  Go to page 1, 2  Next

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.