-->
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.  [ 4 posts ] 
Author Message
 Post subject: Strange problem: Could not read mappings from resource: xxx.
PostPosted: Thu Nov 15, 2007 4:49 am 
Newbie

Joined: Tue Oct 16, 2007 5:56 am
Posts: 10
Hello,
yesterday I have got this problem:
I have my java app that use Hibernate (3.0) for make search on DB (MySQl 5.0).

If I sent a search method (with hibernate method "session.createCriteria"), sometimes it worked good, and sometime it gives me this error:
"
org.hibernate.MappingException: Could not read mappings from resource: basket.hbm.xml
at org.hibernate.cfg.Configuration.addResource(Configuration.java:485)
at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1465)
at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1433)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1414)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1390)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1310)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1296)
at it.eminds.data.Basket.searchBasketInfo(Basket.java:406)
at it.eminds.ws.basket.Basket.BasketWs.OTA_SearchBasketRQ(BasketWs.java:8926)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.axis.providers.java.RPCProvider.invokeMethod(RPCProvider.java:388)
at org.apache.axis.providers.java.RPCProvider.processMessage(RPCProvider.java:283)
at org.apache.axis.providers.java.JavaProvider.invoke(JavaProvider.java:323)
at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
at org.apache.axis.handlers.soap.SOAPService.invoke(SOAPService.java:453)
at org.apache.axis.server.AxisServer.invoke(AxisServer.java:281)
at org.apache.axis.transport.http.AxisServlet.doPost(AxisServlet.java:699)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
at org.apache.axis.transport.http.AxisServletBase.service(AxisServletBase.java:327)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:210)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)
at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:834)
at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:640)
at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1286)
at java.lang.Thread.run(Unknown Source)
Caused by: org.hibernate.MappingException: Could not parse mapping document in input stream
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:431)
at org.hibernate.cfg.Configuration.addResource(Configuration.java:482)
... 36 more
Caused by: org.dom4j.DocumentException: Connection timed out: connect Nested exception: Connection timed out: connect
at org.dom4j.io.SAXReader.read(SAXReader.java:484)
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:422)
"

I don't understand why I have this error "Could not read mappings from resource: basket.hbm.xml" if sometimes it works!.

Can you please helpme to understand the problem (or cause)?? It's very URGENT!!

Thanks,
Francesco

These are my hibernate xml file:

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

<hibernate-configuration>
<session-factory>

<property name="hibernate.connection.driver_class">com.sybase.jdbc3.jdbc.SybDriver</property>
<property name="hibernate.connection.datasource">java:comp/env/jdbc/lmt</property>
<property name="show_sql">true</property>
<property name="dialect">org.hibernate.dialect.SybaseDialect</property>
<property name="hibernate.hbm2ddl.auto">update</property>

<!-- Mapping files -->
<mapping resource="basket.hbm.xml"/>
</session-factory>
</hibernate-configuration>

basket.hbm.xml :
<?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>
<!-- it.eminds.data.Basket root -->
<class name="it.eminds.data.Basket" table="Basket">
<composite-id>
<key-property name="id" column="id" />
<key-property name="bookID" column="bookID"/>
</composite-id>
<property name="utente" type="string" >
<column name="utente" not-null="false" sql-type="text"/>
</property>
<property name="carteDiCredito" type="string" >
<column name="carteDiCredito" not-null="false" sql-type="text"/>
</property>
<property name="cliente" type="string" >
<column name="cliente" not-null="false" sql-type="text"/>
</property>
<property name="spedizione" type="string" >
<column name="spedizione" not-null="false" sql-type="text"/>
</property>
<!--<property name="bookID" column="bookID" type="string" length="16"/>-->
<property name="dataBooking" column="dataBooking" type="timestamp"/>
<property name="bookId_Gest" column="bookId_Gest" type="string" length="16"/>
<property name="pos" type="string" >
<column name="pos" not-null="false" sql-type="text"/>
</property>

<!-- tabella Array servizi type="boolean" -->
<bag name="servizi" cascade="all">
<key>
<column name="uid" />
<column name="ubookID" />
</key>
<one-to-many class="it.eminds.data.ServiceBasket"/>
</bag>
</class>

<class name="it.eminds.data.ServiceBasket" table="serviceBasket">
<id name="id" unsaved-value="0">
<generator class="increment"/>
</id>
<property name="pax" type="string" >
<column name="pax" not-null="false" sql-type="text"/>
</property>
<property name="RQBook" type="string" >
<column name="RQBook" not-null="false" sql-type="text"/>
</property>
<property name="RSBook" type="string">
<column name="RSBook" not-null="false" sql-type="text"/>
</property>
<property name="RSPrev" type="string">
<column name="RSPrev" not-null="false" sql-type="text"/>
</property>
<property name="Type" column="Type" type="integer"/>
<property name="idServizio" column="idServizio" type="integer"/>
<property name="failed" column="failed" type="string" length="12" />
<property name="invoiceNumber" column="invoiceNumber" type="string" length="12" />
<property name="notaNumber" column="notaNumber" type="string" length="12" />
<property name="startDate" column="startDate" type="timestamp"/>
<property name="correlation" column="correlation" type="string" length="10" />
</class>
</hibernate-mapping>


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 15, 2007 6:09 am 
Expert
Expert

Joined: Fri Jul 13, 2007 8:18 am
Posts: 370
Location: london
Code:
Caused by: org.dom4j.DocumentException: Connection timed out: connect Nested exception: Connection timed out: connect
at org.dom4j.io.SAXReader.read(SAXReader.java:484)


Looks like the SAX parser is having trouble reading something over the network which explains why it works sometimes and not others.

If you're using hibernate 3 the DTD is wrong in Basket.hbm.xml:
Code:
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">


Should be

Code:
<!DOCTYPE hibernate-mapping PUBLIC
        "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
        "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">


You might need a local DTD catalog to prevent the xml parser going to the internet.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 15, 2007 7:02 am 
Newbie

Joined: Tue Oct 16, 2007 5:56 am
Posts: 10
Hello,

I have tried to change the version from 2.0 to 3.0, but I have this error:

org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: it.eminds.data.Basket.servizi, no session or session was closed

I think, this because, after search, I close the session, and then I use the object "Basket" for read that!
But why with 2.0 it works?!

This is the log:
Hibernate: select this_.id as id4_1_, this_.bookID as bookID4_1_, this_.utente as utente4_1_, this_.carteDiCredito as carteDiC4_4_1_, this_.cliente as cliente4_1_, this_.spedizione as spedizione4_1_, this_.dataBooking as dataBook7_4_1_, this_.bookId_Gest as bookId8_4_1_, this_.pos as pos4_1_, servicebas1_.id as id5_0_, servicebas1_.pax as pax5_0_, servicebas1_.RQBook as RQBook5_0_, servicebas1_.RSBook as RSBook5_0_, servicebas1_.RSPrev as RSPrev5_0_, servicebas1_.Type as Type5_0_, servicebas1_.idServizio as idServizio5_0_, servicebas1_.failed as failed5_0_, servicebas1_.invoiceNumber as invoiceN9_5_0_, servicebas1_.notaNumber as notaNumber5_0_, servicebas1_.startDate as startDate5_0_, servicebas1_.correlation as correla12_5_0_ from Basket this_ inner join serviceBasket servicebas1_ on this_.id=servicebas1_.uid and this_.bookID=servicebas1_.ubookID where this_.bookID=?
11:55:04,806 ERROR otalogger:9627 - BASKET: Errore durante l'elaborazione della richiesta xml
org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: it.eminds.data.Basket.servizi, no session or session was closed
at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationException(AbstractPersistentCollection.java:358)
at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationExceptionIfNotConnected(AbstractPersistentCollection.java:350)
at org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:343)
at org.hibernate.collection.AbstractPersistentCollection.read(AbstractPersistentCollection.java:86)
at org.hibernate.collection.PersistentBag.iterator(PersistentBag.java:246)
at it.eminds.data.Basket.toString(Basket.java:369)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 15, 2007 7:43 am 
Expert
Expert

Joined: Fri Jul 13, 2007 8:18 am
Posts: 370
Location: london
The lazy attribute for <bag> was defaulted to "false" in the v2 DTD so the SAX parser is setting it to false for you. In the v3 DTD lazy is #implied i.e. optional. The implementation defaults collections to lazy="true". This is why you see a difference in behaviour.

Just add lazy="false" to your bag.


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