-->
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.  [ 2 posts ] 
Author Message
 Post subject: Trouble with integrating Hibernate and Axis2
PostPosted: Mon Jul 19, 2010 5:02 pm 
Newbie

Joined: Mon Jul 19, 2010 4:29 pm
Posts: 1
Hi,

I am writing a web service which relies on Hibernate to persist data in a MySQL DBMS. The web service is using Tomcat 6 with Axis2 on Ubuntu 9.

Unfortunately, I am unable to create a session factory. Whatever I try, I always get the exception message "/hibernate.cfg.xml not found". So far, I tried the following:

- Putting hibernate.cfg.xml and mappings.hbm.xml (which is referenced by the former) into <Axishome>/classes.

- Putting the XML files into <Axishome>/services.

- Putting the XML files into <Axishome> (/var/lib/tomcat6/webapps/axis2/WEB-INF/).

- Storing the XML files in one JAR file, then putting the JAR file into <Axishome>/lib.

- Storing the XML files on the root of the AAR archive used for deployment.

- Storing the XML files inside the META-INF directory of the AAR archive.

I combined all of these approaches with this modification:

Code:
<parameter name="ServiceTCCL">composite</parameter>


of the service.xml inside the AAR archive, below the <service> tag.

I used the following two approaches to create a Hibernate session factory, both of which did not work:

Approach 1:

Code:
SessionFactory myFactory = new Configuration().configure().buildSessionFactory();


Approach 2:

Code:
ConfigurationContext myConfigContext = ConfigurationContextFactory.createDefaultConfigurationContext();
ClassLoader myLoader = myConfigContext.getAxisConfiguration().getServiceClassLoader();
URL configURL = myLoader().getResource("hibernate.cfg.xml");
SessionFactory myFactory = new Configuration().configure(configURL).buildSessionFactory();


When using Approach 1, the method buildSessionFactory() throws a "org.hibernate.HibernateException" with the message "/hibernate.cfg.xml not found". When using Approach 2, the loader cannot find the resource (configURL remains null). This remains the same when calling getSystemClassLoader() or getModuleClassLoader() rather than getServiceClassLoader().

Someone on the internet suggested to use the following code instead:

Code:
URL configURL = MessageContext.getCurrentMessageContext().getAxisService().getClassLoader().getResource("hibernate.cfg.xml");


However, this does not work during the initialization of the server stub, since getCurrentMessageContext() returns null then. My database gateway class is supposed to be initialized when the server stub is instantiated.

So far, I've browsed a lot of Google pages, but without any luck. Does anyone know why Hibernate keeps ignoring the config file?


Top
 Profile  
 
 Post subject: Re: Trouble with integrating Hibernate and Axis2
PostPosted: Wed Aug 11, 2010 4:41 am 
Newbie

Joined: Wed Aug 11, 2010 4:39 am
Posts: 1
Hello,

i got the same problem integrating with Axis2. Did anyone find a solution so far?


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