-->
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: Resolve Hibernate DTDs locally
PostPosted: Wed Nov 09, 2005 7:32 pm 
Beginner
Beginner

Joined: Tue Jun 21, 2005 1:45 pm
Posts: 38
Code:
Hi,

I would like to keep Hibernate DTDs locally instead of going over the internet at runtime. As per the hibernate developers manual, during the hibernate config parsing, first it searches the DTDs within the classpath and use it if found. Or else it goes over the internet. However, I couldnt get it working. I have kept DTDs within classpath + they are also part of hibernate3.jar and still it gives below error while loading hibernate config -

java.net.UnknownHostException: hibernate.sourceforge.net
   at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:177)
   at java.net.Socket.connect(Socket.java:507)
   at java.net.Socket.connect(Socket.java:457)
   at sun.net.NetworkClient.doConnect(NetworkClient.java:157)
   at sun.net.www.http.HttpClient.openServer(HttpClient.java:365)
   at sun.net.www.http.HttpClient.openServer(HttpClient.java:477)
   at sun.net.www.http.HttpClient.<init>(HttpClient.java:214)
   at sun.net.www.http.HttpClient.New(HttpClient.java:287)
   at sun.net.www.http.HttpClient.New(HttpClient.java:299)
   at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:784)
   at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:736)
   at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:661)
   at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:905)
   at org.apache.xerces.impl.XMLEntityManager.setupCurrentEntity(Unknown Source)
   at org.apache.xerces.impl.XMLEntityManager.startEntity(Unknown Source)
   at org.apache.xerces.impl.XMLEntityManager.startDTDEntity(Unknown Source)


Could someone plz help me resolve this issue? Do I have to write my own EntityResolver?

- Nilesh


Top
 Profile  
 
 Post subject: links
PostPosted: Wed Nov 09, 2005 8:08 pm 
Expert
Expert

Joined: Fri Jul 22, 2005 2:42 pm
Posts: 670
Location: Seattle, WA
This might help
http://forum.hibernate.org/viewtopic.ph ... esolve+dtd

_________________
--------------
Konstantin

SourceLabs - dependable OpenSource systems


Top
 Profile  
 
 Post subject: Re: links
PostPosted: Wed Nov 09, 2005 8:42 pm 
Beginner
Beginner

Joined: Tue Jun 21, 2005 1:45 pm
Posts: 38
kgignatyev wrote:


Code:
Thanks for sending the link...

I had xerces-2.6.2.jar within my classpath... removed that file as per suggestion posted by someone in the thread.... and I'm still getting the same problem...

Below are the examples of mapping and configuration file I'm using -

<?xml version="1.0" ?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.onebeacon.diarytracking.ormapping.domain">
...
</hibernate-mapping>



<?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>
...
</hibernate-configuration>


Do you guys see any error in this DOCTYPE definition? This problem is driving me crazy....

Help !!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 09, 2005 10:46 pm 
Beginner
Beginner

Joined: Tue Jun 21, 2005 1:45 pm
Posts: 38
problem is resolved !!

Code:
        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
        DocumentBuilder db = dbf.newDocumentBuilder();
        db.setEntityResolver(new DTDEntityResolver());
        Document doc = db.parse(new InputSource(new StringReader(hibernateConfigData)));
        sessionFactory = new Configuration().configure(doc).buildSessionFactory();


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.