Sam,

What is Environment, and what is the path passed to addResource()?

(I see the leading "/" on Address.hbm.xml, and I'm not sure I like that, and
I'm wondering if Environment's classloader can see WEB-INF - I know you said
it works under Tomcat, but if for some reason it's part of an EAR under
Jrun, then if Environment is loaded at the application/ear level, its
classloader might not be able to see the web app level.)

- John
212-522-0293
4-131H

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, October 18, 2005 6:23 PM
To: JRun-Talk
Subject: Odd behavior of getResourceAsStream

Hello,

 

I am trying to use Hibernate 3 with JRun 4. I have developed an
application the works correctly on Tomcat 5.5, but when I try to load
the application on JRun 4, I receive the following exception:

 

- Configuration resource: /hibernate.cfg.xml

- Mapping resource: /com/timeinc/si/dcgold/db/Address.hbm.xml

Initial SessionFactory creation failed.org.hibernate.MappingException:
Resource: /com/timeinc/si/dcgold/db/Address.hbm.xml not found

10/18 16:15:20 error

[1]org.hibernate.MappingException: Resource:
/com/timeinc/si/dcgold/db/Address.hbm.xml not found

       at
org.hibernate.cfg.Configuration.addResource(Configuration.java:447)

       at
org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1
263)

       at
org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1
235)

[complete stack trace omitted]

 

In my war file, hibernate.cfg.xml is located in WEB-INF/classes, and
Address.hbm.xml is located in
WEB-INF/classes/com/timeinc/si/dcgold/db/Address.hbm.xml

 

The Hibernate source code that throws the exception is:

      public Configuration addResource(String path) throws
MappingException {

            log.info( "Mapping resource: " + path );

            InputStream rsrc =
Thread.currentThread().getContextClassLoader().getResourceAsStream( path
);

            if ( rsrc == null ) rsrc =
Environment.class.getClassLoader().getResourceAsStream( path );

            if ( rsrc == null ) throw new MappingException( "Resource: "
+ path + " not found" );

[...]

 

I don't understand why the code from Hibernate would fail. Has anyone
encountered this problem? Is there an issue with the JRun classloader?

 

Any help would be greatly appreciated.

 

Thanks,

Sam Greenfield

Sports Illustrated

 





~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Sams Teach Yourself Regular Expressions in 10 Minutes  by Ben Forta 
http://www.houseoffusion.com/banners/view.cfm?bannerid=40

Message: http://www.houseoffusion.com/lists.cfm/link=i:8:5728
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/8
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:8
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.8
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to