• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

RMI and Hibernate

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I have a class that uses Hibernate to get data from the database. I invoke a method in this class from a RMI server.

The issue is that the RMI server works fine when there is no Hibernate component. Also, its the same with the Hibernate component. It works fine when invoked directly and doesnt work when invoked through the RMI server.

When i use them together, I get the following exception.

org.dom4j.DocumentException: Error on line 4 of document : External
entity not found: "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd". Nested exception: External entity not found: "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd".

Please help.


This is the Exception trace

21:14:50,381 ERROR XMLHelper:59 - Error parsing XML: /hibernate.cfg.xml(4) Exter
nal entity not found: "http://hibernate.sourceforge.net/hibernate-configuration-
3.0.dtd".
21:14:50,397 ERROR Configuration:1172 - problem parsing configuration/hibernate.
cfg.xml
org.dom4j.DocumentException: Error on line 4 of document : External entity not
found: "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd". Neste
d exception: External entity not found: "http://hibernate.sourceforge.net/hibern
ate-configuration-3.0.dtd".
at org.dom4j.io.SAXReader.read(SAXReader.java:482)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1168)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1112)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1098)
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not that experienced with Hibernate, but I'm betting this is a classpath issue - the classpath is probably set correctly to find the DTD when you are running your Hibernate class standalone; but when you run it with the RMI version, there's something missing from the classpath, and when the parser can't find the DTD in the classpath, it attempts to access it through the net and fails and throws the error.
 
Reshma Sreenivasulu
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Nathan,

Thanks for the hint. There was no issue in the CLASSPATH since I had not copied the dtd to the folder in the local machine.

As a separate component, Hibernate was not having any security issues while accessing the dtd. But when accessed through RMI, the SecurityManager was preventing it from accessing the external dtd (as the hibernate.cfg.xml is not part of the Sun Java Package). This (the security issue) was overcome when the following entry was made in the Policy File.

grant codebase "file:/D:/PROJECTS/~/~/src/-" {
permission java.security.AllPermission; };

Some more info on the security and permissions is available at

http://java.sun.com/j2se/1.5.0/docs/guide/security/PolicyFiles.html#Examples
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi Reshma,

i am getting the same error but i m nt using RMI.
can you help me on this please.
adave@mahindrabt.com


 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"a Dave" -

Welcome to the JavaRanch! Please adjust your displayed name to meet the
JavaRanch Naming Policy. User names cannot be obviously fake and must constist of a first name and a last name.

You can change your user name here.

Also, since your question is about this error in Hibernate in general, and not using RMI, a better forum to ask this question in would be our Object Relational Mapping forum.

Thanks! and welcome to the JavaRanch!
 
reply
    Bookmark Topic Watch Topic
  • New Topic