You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Kevin Wilhelm <Ke...@gmx.net> on 2007/06/14 15:04:39 UTC

Using shared Spring Webapp in Tomcat 6

Hello,

I am about to finalize some early state Spring web application (just the persistence and logic part). I am using Hibernate to retrieve data from a database. I created the whole logic using the Spring framework; at the top there is a Session Facade providing access to all the services.

At this point I want to create JSP/JSF views in another webapp. I want to create a new web application that *USES* the services of the one described above.

For Tomcat 6 there is a folder called "$CATALINAHOME/lib" that is said to be used for that kind of stuff. But isn't this folder meant to be used for jars instead of complete running web apps?

1.) Does it work to create a war file from my services webapp and put it into the lib directory? Is this the way to go?

2.) Furthermore: Where do I start with my JSP/JSF view webapp? I assume I have to access the SessionFacade somehow. I will have to access the logic web app from within my view-webapp.

I'd appreciate some hints on that!
Thanks in advance!

-- 
Ist Ihr Browser Vista-kompatibel? Jetzt die neuesten 
Browser-Versionen downloaden: http://www.gmx.net/de/go/browser

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: Using shared Spring Webapp in Tomcat 6

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Kevin Wilhelm [mailto:kevinwilhelm@gmx.net] 
> Subject: Re: Using shared Spring Webapp in Tomcat 6
> 
> I understand it makes no sense to share a whole webapp in Tomcat.

Still not clear on what you mean by "share a whole webapp".  By
definition (the servlet spec), webapps are intended to be independent
and the interface to a webapp is via HTTP.  You can easily send an HTTP
request from one webapp to another within Tomcat, if that's what you
want to do - but I suspect you really want to use method invocations.

> What about sharing a singleton across all Tomcat webapps?

That's fine, and it doesn't have to be in a jar - you can put just the
.class file into the $CATALINA_HOME/lib directory.

> How do I access the singleton from within my webapps after that?

Just call it; the webapp's classloader will delegate to the common
classloader if the reference can't be found within the webapp.

> However, the first call must set the factory 
> (the main webapp will do that)

You might want to consider using a Listener to initialize the singleton.
Again, read the servlet spec.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Using shared Spring Webapp in Tomcat 6

Posted by Kevin Wilhelm <ke...@gmx.net>.
I understand it makes no sense to share a whole webapp in Tomcat.

What about sharing a singleton across all Tomcat webapps? I want my main 
webapp to call a method on that shared singleton in order to provide a 
factory (...getInstance().setFactory()). This factory should be retrieved by 
webapps using that singleton (....getFactory()). I know I have to put that 
singleton (in a jar file) into the $CATALINA_HOME/lib directory. How do I 
access the singleton from within my webapps after that? I guess I have to 
touch the web.xml somewhere. However, the first call must set the factory 
(the main webapp will do that)... all following calls shall be able to 
access the factory.


----- Original Message ----- 
From: "Caldarale, Charles R" <Ch...@unisys.com>
To: "Tomcat Users List" <us...@tomcat.apache.org>
Sent: Friday, June 15, 2007 12:08 AM
Subject: RE: Using shared Spring Webapp in Tomcat 6


> From: Kevin Wilhelm [mailto:KevinWilhelm@gmx.net]
> Subject: Using shared Spring Webapp in Tomcat 6
>
> For Tomcat 6 there is a folder called "$CATALINAHOME/lib"
> that is said to be used for that kind of stuff.

No, the $CATALINA_HOME/lib directory is for classes common to all
webapps, not any individual webapps.  Each webapp is normally deployed
in its own directory under the <Host> appBase (typically
$CATALINA_HOME/webapps).

> 1.) Does it work to create a war file from my services webapp
> and put it into the lib directory? Is this the way to go?

No.

> 2.) Furthermore: Where do I start with my JSP/JSF view
> webapp? I assume I have to access the SessionFacade somehow.
> I will have to access the logic web app from within my view-webapp.

If your "logic" webapp is just that - no presentation capabilities -
then it's not really a webapp, is it?  Sounds like you haven't really
thought through the application architecture here.

This may well be more of a Spring topic than a Tomcat one.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org 


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: Using shared Spring Webapp in Tomcat 6

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Kevin Wilhelm [mailto:KevinWilhelm@gmx.net] 
> Subject: Using shared Spring Webapp in Tomcat 6
> 
> For Tomcat 6 there is a folder called "$CATALINAHOME/lib" 
> that is said to be used for that kind of stuff.

No, the $CATALINA_HOME/lib directory is for classes common to all
webapps, not any individual webapps.  Each webapp is normally deployed
in its own directory under the <Host> appBase (typically
$CATALINA_HOME/webapps).

> 1.) Does it work to create a war file from my services webapp 
> and put it into the lib directory? Is this the way to go?

No.

> 2.) Furthermore: Where do I start with my JSP/JSF view 
> webapp? I assume I have to access the SessionFacade somehow. 
> I will have to access the logic web app from within my view-webapp.

If your "logic" webapp is just that - no presentation capabilities -
then it's not really a webapp, is it?  Sounds like you haven't really
thought through the application architecture here.

This may well be more of a Spring topic than a Tomcat one.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org