-->
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.  [ 3 posts ] 
Author Message
 Post subject: can't use local DTD
PostPosted: Mon Dec 06, 2004 1:46 pm 
Newbie

Joined: Mon Sep 27, 2004 12:19 pm
Posts: 5
I am trying to avoid using http://hibernate.sourceforge.net/hibern ... ng-2.0.dtd to fetch the DTD and use a local copy. According to Hibernate documentation, I could use the DTD that is in hibernate2.jar.

When I change the DOCTYPE in my mapping file to point to that file, I get the FileNotFoundException. Hibernate docs also claims that the DTD is searched for in the CLASSPATH.

Has anyone gotton this to work? Could it be because I am using the addXML method of the configuration?

Thanks,
-ramin


Hibernate version: 2.0

Mapping documents:

<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"net/sf/hibernate/hibernate-mapping-2.0.dtd" >

Full stack trace of any exception that occurs:

java.io.FileNotFoundException: /blah/dev/bin/net/sf/hibernate/hibernate-mapping-2.0.dtd (A file or directory in the path name does not exist.)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:120)
at java.io.FileInputStream.<init>(FileInputStream.java:82)
at sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection.java:99)
at sun.net.www.protocol.file.FileURLConnection.getInputStream(FileURLConnection.java:164)
at java.net.URL.openStream(URL.java(Inlined Compiled Code))
at org.apache.xerces.impl.XMLEntityManager.setupCurrentEntity(Unknown Source)(Compiled Code)
at org.apache.xerces.impl.XMLEntityManager.startEntity(Unknown Source)(Inlined Compiled Code)
at org.apache.xerces.impl.XMLEntityManager.startDTDEntity(Unknown Source)(Inlined Compiled Code)
at org.apache.xerces.impl.XMLDTDScannerImpl.setInputSource(Unknown Source)(Compiled Code)
at org.apache.xerces.impl.XMLDocumentScannerImpl$DTDDispatcher.dispatch(Unknown Source)(Compiled Code)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.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 org.dom4j.io.SAXReader.read(SAXReader.java:271)
at net.sf.hibernate.cfg.Configuration.addXML(Configuration.java:207)


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 06, 2004 2:35 pm 
Newbie

Joined: Fri Sep 17, 2004 4:29 pm
Posts: 10
Hibernate has a class called DTDEntityResolver, this class implements an EntityResolver, then Hibernate can validate its xml files offline or online, this EntityResolver is a parser´s property, with this tool you can force your application to validate your XML files offline, hibernate makes that, thus, you don´t need to change the doctype, if you change the doctype, hibernate doesn´t work. if you have any class reading the hibernate´s XML files, you should implement an EntityResolver to solve this problem, i did that, and it works fine.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 06, 2004 4:52 pm 
Newbie

Joined: Mon Sep 27, 2004 12:19 pm
Posts: 5
It turns out that hibernate doesn't really lookup the DTD by connecting to sourceforge.net.


I just saw this in the source code for DTDEntityResolver:

private static final String URL = "http://hibernate.sourceforge.net/";

public InputSource resolveEntity (String publicId, String systemId) {
if ( systemId!=null && systemId.startsWith(URL) ) {
log.debug("trying to locate " + systemId + " in classpath under net/sf/hibernate/");
// Search for DTD
ClassLoader classLoader = this.getClass().getClassLoader();
InputStream dtdStream = classLoader.getResourceAsStream( "net/sf/hibernate/" + systemId.substring( URL.length() ) );

Thanks,
-ramin


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