You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Jacques Poulin <ja...@gmail.com> on 2011/03/15 02:38:47 UTC

Axis2, Hibernate, and configuration files...

Hi,

 

I have a regular java project containing code used by many other projects.
Call it project "SharedProject".

 

SharedProject has a class which initializes a Hibernate session in its
constructor.  Call it ParentClass.

 

In order to test that project inside Eclipse, I put a hibernate.cfg.xml file
in its "src" folder.

 

 

 

Now, I have a web service project, WSProject, which "uses" SharedProject.
In Eclipse terminology, SharedProject shows up in the properties for
WSProject, Projects tab.

 

 

WSProject has a java class which extends ParentClass, so that when it's
constructed (when the service is called for the first time), the Hibernate
initialization happens.

 

In WSProject's ant build file, I include SharedProject's classes, so that
they end up in the final .aar file as .class files...

 

 

What I want to do is figure out how to make the web service (WSProject) use
an EXTERNAL hibernate.cfg.xml file once deployed on a tomcat server.  The
reason is that I'll have multiple such web services, and I want them all to
use the same configuration file, instead of having each web service having
its own hibernate config file...

 

 

I tried putting the hibernate.cfg.xml file in the
$TOMCAT_HOME/webapps/axis2/WEB-INF directory, but when I start Tomcat, the
service gets deployed but it can't find the config file...

 

 

I also have the <parameter name="ServiceTCCL">composite</parameter> in the
services.xml...

 

 

Also, as a side question, I would like to be able to use a centralized
generic config file (that has nothing to do with Hibernate), again to be
used by all web services...  Some kind of properties file, for example
config.properties...  Is that possible, and if so, where do I put it ?

 

Thanks. 

 

 

 


Re: Axis2, Hibernate, and configuration files...

Posted by Jorge Medina <ce...@gmail.com>.
>
> Also, as a side question, I would like to be able to use a centralized
> generic config file (that has nothing to do with Hibernate), again to be
> used by all web services...  Some kind of properties file, for example
> config.properties...  Is that possible, and if so, where do I put it ?
>

You may use JNDI in context.xml.

http://stackoverflow.com/questions/514777/how-to-initialize-a-value-in-web-xml-from-a-jndi-variable

In fact, I define in this way a pointer to a directory that contains
my hibernate.cfg file and initialize Hibernate accordingly.

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@axis.apache.org
For additional commands, e-mail: java-user-help@axis.apache.org


Re: Axis2, Hibernate, and configuration files...

Posted by Ron Wheeler <rw...@artifact-software.com>.
On 14/03/2011 9:38 PM, Jacques Poulin wrote:
>
> Hi,
>
> I have a regular java project containing code used by many other 
> projects.  Call it project "SharedProject".
>
> SharedProject has a class which initializes a Hibernate session in its 
> constructor.  Call it ParentClass.
>
> In order to test that project inside Eclipse, I put a 
> hibernate.cfg.xml file in its "src" folder.
>
> Now, I have a web service project, WSProject, which "uses" 
> SharedProject.  In Eclipse terminology, SharedProject shows up in the 
> properties for WSProject, Projects tab.
>
> WSProject has a java class which extends ParentClass, so that when 
> it's constructed (when the service is called for the first time), the 
> Hibernate initialization happens.
>
> In WSProject's ant build file, I include SharedProject's classes, so 
> that they end up in the final .aar file as .class files...
>
> What I want to do is figure out how to make the web service 
> (WSProject) use an EXTERNAL hibernate.cfg.xml file once deployed on a 
> tomcat server.  The reason is that I'll have multiple such web 
> services, and I want them all to use the same configuration file, 
> instead of having each web service having its own hibernate config file...
>
> I tried putting the hibernate.cfg.xml file in the 
> $TOMCAT_HOME/webapps/axis2/WEB-INF directory, but when I start Tomcat, 
> the service gets deployed but it can't find the config file...
>

We built a library that includes the code required to support the 
database and Hibernate access and made all the war projects depend on 
that library.
You still get multiple copies of the cfg file but at least they are all 
the same.

> I also have the <parameter name="ServiceTCCL">composite</parameter> in 
> the services.xml...
>
> Also, as a side question, I would like to be able to use a centralized 
> generic config file (that has nothing to do with Hibernate), again to 
> be used by all web services...  Some kind of properties file, for 
> example config.properties...  Is that possible, and if so, where do I 
> put it ?
>
Are you aware of JNDI? It might help you solve a few of these problems. 
http://blog.artifact-software.com/tech/?p=58


Ron

> Thanks.
>


Re: Axis2, Hibernate, and configuration files...

Posted by robert lazarski <ro...@gmail.com>.
On Mon, Mar 14, 2011 at 10:38 PM, Jacques Poulin
<ja...@gmail.com> wrote:
>
> What I want to do is figure out how to make the web service (WSProject) use
> an EXTERNAL hibernate.cfg.xml file once deployed on a tomcat server.  The
> reason is that I'll have multiple such web services, and I want them all to
> use the same configuration file, instead of having each web service having
> its own hibernate config file...
>
>

I understand correctly, you could use the hibernate api:

http://docs.jboss.org/hibernate/stable/core/api/org/hibernate/cfg/Configuration.html#addDirectory%28java.io.File%29

Or if you are using spring anyways:

http://static.springsource.org/spring/docs/2.5.0/api/org/springframework/orm/hibernate3/LocalSessionFactoryBean.html#setMappingDirectoryLocations%28org.springframework.core.io.Resource[]%29

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@axis.apache.org
For additional commands, e-mail: java-user-help@axis.apache.org