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.  [ 6 posts ] 
Author Message
 Post subject: hibernate.cfg.xml in EAR application files for WebLogic
PostPosted: Wed Sep 14, 2005 6:12 am 
Newbie

Joined: Fri Jun 17, 2005 2:51 am
Posts: 11
Hibernate version: 3.0.5

Hi,

I'm just trying to deploy an ear file in Weblogic. The ear file also contains besides the jars also the hibernate.cfg.xml file in the root directory.

However, when I want to initialize the Hibernate session factory I get the following Exception:

Code:
org.hibernate.HibernateException: /hibernate.cfg.xml not found
   at org.hibernate.cfg.Configuration.getConfigurationInputStream(Configuration.java:1087)
   at org.hibernate.cfg.Configuration.configure(Configuration.java:1111)
   at org.hibernate.cfg.Configuration.configure(Configuration.java:1098)
        ...


However, when I deploy the ear file in JBoss everything works correctly.
Does anybody know how I have to configure the EAR file so that the hibernate.cfg.xml file is found by WebLogic?

Thanks in advance,
Joern


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 14, 2005 5:34 pm 
Newbie

Joined: Wed Sep 14, 2005 11:03 am
Posts: 4
Location: Mississauga
It seems to be a Weblogic Classloader issue. Without knowing your exact ear deployment structure I would suggest that you make sure that hibernate.jar and your config file use the same classloader.

Keeping classloader hierarchy in mind, a classloader cannot get resources of its siblings or children.

If this doesn't help post how your ear is structured and where exactly you initialize hibernate.

JBoss might have a different classloader hierarchy. Evey J2EE server probably has its own classloader setup.

_________________
_________________________________
Haider Kazmi

|-|-|-|-|-|-|-|-|-|-|-|
Don't Forget to rate!
|-|-|-|-|-|-|-|-|-|-|-|


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 15, 2005 2:54 am 
Newbie

Joined: Fri Jun 17, 2005 2:51 am
Posts: 11
Hi hkazmi!

Thanks for your reply. The simplified ear structure looks like ths:

Code:
myEar.ear
|- myEJBJar.jar
|- hibernate-3.0.5.jar
|- other jars
|- hibernate.cfg.xml


the Manifest.mf file in myEJBJar.jar contains the classpath entries to hibernate and the other needed jars (and I also tried to add the hibernate.cfg.xml file to it with no effect).

The Hibernate initialization call is initiated from an EJB in myEJBJar.jar via a HibernateUtil class.

Just for completeness. My application.xml looks like this:

Code:
<application>
  <display-name>myApp</display-name>
  <module>
    <ejb>myEJBJar.jar</ejb>
  </module>
</application>


Greetings,
Joern

P.S. As a workaround I placed the hibernate.cfg.xml outside the jar in a conf dir and added the conf dir to the Weblogic classpath. However, I'd prefer to have it iin the ear instead :-(


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 15, 2005 3:22 am 
Newbie

Joined: Fri Jun 17, 2005 2:51 am
Posts: 11
I just realized that the configuration of the session factory takes place in the "constructor" of my HibernateUtil class in the following static block:

Code:
    // Create the initial SessionFactory from the default configuration files
    static {
        try {
            configuration = new Configuration();
            sessionFactory = configuration.configure().buildSessionFactory();
        } catch (Throwable ex) {
            // We have to catch Throwable, otherwise we will miss
            // NoClassDefFoundError and other subclasses of Error
            log.error("Building SessionFactory failed.", ex);
            throw new ExceptionInInitializerError(ex);
        }
    }


Nevertheless, the HibernateUtil class is the first time called by a class of my myEJBJar.jar...

Jörn


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 15, 2005 9:59 am 
Newbie

Joined: Wed Sep 14, 2005 11:03 am
Posts: 4
Location: Mississauga
Alright this gives a better understanding of how things are setup. Put the hibernate config file in the root of your myEJB.jar.

The weblogic classloader look like this.


SystemCL<--- <APP>EJBCL <-- WebAppCL</APP>

<APP> represents your EAR, but EAR/APP itself doesn't get a classloader, only EJBs and WebAPPs do.

Without being able to playaround I believe your EJB CL does not see whats in the root of your ear, putting ur hibernate config in your ebj jar should fix that.

BTW, what version of weblogic are you using ?

_________________
_________________________________
Haider Kazmi

|-|-|-|-|-|-|-|-|-|-|-|
Don't Forget to rate!
|-|-|-|-|-|-|-|-|-|-|-|


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 15, 2005 10:34 am 
Newbie

Joined: Fri Jun 17, 2005 2:51 am
Posts: 11
Hi,

I'm using Weblogic 8.1. SP3
I don't want to put the hibernate.cfg.xml file into myEJBJar.jar as my build process produces that file much later.
Maybe another solution is to put it in an APP-INF directory. I'll try that otherwise I keep it outside the ear....

Thanks,
Jörn


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