Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / December 2005

Tip: Looking for answers? Try searching our database.

Running 2 webapp in Tomcat - 1 or 2 JVMs

Thread view: 
James Yong - 28 Nov 2005 15:27 GMT
Hi,

If I run 2 web applications in a Tomcat, is that 2 web application run by 2
JVMs or 1 JVM?

Regards,
James
poundinc@yahoo.com - 28 Nov 2005 15:54 GMT
Hello
1 JVM.I suppose it is virtual
James Yong - 28 Nov 2005 17:57 GMT
> Hello
> 1 JVM.I suppose it is virtual

Thanks.

Does that means that it is impossible to implement RMI between them, since
RMI requires at least 2 JVM to work?

Regards,
James
cbroussard@liquiddatainc.com - 28 Nov 2005 18:18 GMT
i believe, if you are under 1 jvm you would be able to share objects
between the two contexts.

things to try (in any order of preference)
1) you might have to write a patch and alter tomcat to add a hook into
the bootstrap to do this "under the table"..

2) the more appropriate way would be to do it "above the table", and
have a servlet to servlet communication through a post/get... assuming
the table is conceptually at the context level.

3) another possibility i just thought of, is to do this via jndi.
that's kinda the purpose of it. and probably the best solution.

4) run two seperate jvm's and then rmi would make more sense.

www.binaryfrost.com
Roedy Green - 29 Nov 2005 02:37 GMT
>1) you might have to write a patch and alter tomcat to add a hook into
>the bootstrap to do this "under the table"..

a garden variety static class will let anyone communicate with anyone
in a JVM.
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.

Roedy Green - 29 Nov 2005 02:38 GMT
On Tue, 29 Nov 2005 02:37:28 GMT, Roedy Green
<my_email_is_posted_on_my_website@munged.invalid> wrote, quoted or
indirectly quoted someone who said :

>a garden variety static class will let anyone communicate with anyone
>in a JVM.

More precisely the static variables of a garden variety class will let
anyone communicate with anyone within a JVM.
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.

pkriens@gmail.com - 29 Nov 2005 11:15 GMT
> More precisely the static variables of a garden variety class will let
> anyone communicate with anyone within a JVM.
Depends ... if the different web applications are loaded via different
class loaders then statics do not work.

Also, RMI has its use also in a VM. Using RMI makes sure that you do
not share any member between apps, really important if you want to
unload apps dynamically, like OSGi.

Kind regards,

   Peter Kriens
   OSGi Evangelist

> On Tue, 29 Nov 2005 02:37:28 GMT, Roedy Green
> <my_email_is_posted_on_my_website@munged.invalid> wrote, quoted or
[quoted text clipped - 8 lines]
> Canadian Mind Products, Roedy Green.
> http://mindprod.com Java custom programming, consulting and coaching.
James Yong - 29 Nov 2005 14:03 GMT
> On Tue, 29 Nov 2005 02:37:28 GMT, Roedy Green
> <my_email_is_posted_on_my_website@munged.invalid> wrote, quoted or
[quoted text clipped - 5 lines]
> More precisely the static variables of a garden variety class will let
> anyone communicate with anyone within a JVM.

Hi Roedy,

I am not sure how a static class can help web app A calling and getting
results from web ap B. Can you give an example?

Regards,
James
Roedy Green - 29 Nov 2005 18:17 GMT
>I am not sure how a static class can help web app A calling and getting
>results from web ap B. Can you give an example?

In a very simple example:

public class Common
{
public static string share;
}

A has code like this:

Common.share = "I will meet you at the casbah";

B has code like this:

if ( Common.share != null ) ...

In a real example A and B could call methods of Common and Common
would call methods in the concurrent package.  See
http://mindprod.com/jgloss/queue.html
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.

James Yong - 30 Nov 2005 13:42 GMT
> >I am not sure how a static class can help web app A calling and getting
> >results from web ap B. Can you give an example?
[quoted text clipped - 17 lines]
> would call methods in the concurrent package.  See
> http://mindprod.com/jgloss/queue.html

Hi Roedy,

Thanks for the explanation

Regards,
James
James Yong - 29 Nov 2005 14:10 GMT
> i believe, if you are under 1 jvm you would be able to share objects
> between the two contexts.
[quoted text clipped - 13 lines]
>
> www.binaryfrost.com

Hi cbroussard,

Your recommendation is very valuable. I will start to look into the jndi
solution.

Regards,
James
Roedy Green - 29 Nov 2005 02:36 GMT
>Does that means that it is impossible to implement RMI between them, since
>RMI requires at least 2 JVM to work?

the R in RMI stands for Remote.  It jumps through hoops because sender
and receiver are in different JVMS. When they are in the same JVM you
can simply and efficiently past references back and forth.

Typically, RMI involves at least three JVMs, a RMI server, an RMI
application server and a client.
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.

John C. Bollinger - 29 Nov 2005 02:52 GMT
>>Hello
>>1 JVM.I suppose it is virtual
[quoted text clipped - 3 lines]
> Does that means that it is impossible to implement RMI between them, since
> RMI requires at least 2 JVM to work?

It probably does mean that you cannot do RMI between the two apps, but
I'm not certain of it.  A better question for you to think about,
however, is whether it makes sense to split things up into two web
applications in the first place when they are tightly enough bound
together that you /want/ to do RMI between them.

Signature

John Bollinger
jobollin@indiana.edu

James Yong - 29 Nov 2005 13:56 GMT
> It probably does mean that you cannot do RMI between the two apps, but
> I'm not certain of it.  A better question for you to think about,
> however, is whether it makes sense to split things up into two web
> applications in the first place when they are tightly enough bound
> together that you /want/ to do RMI between them.

Hi John,

The 2 web application serves different purposes but web app A requires some
information from web app B.
So for my case, it make sense to split them, and to communicate via RMI.

However I also forsee a possibility that they may be hosted in the same
container. Hence my questions in this threads.

I will probably code some functions to allow switching of RMI with an
alternative solution that is recomended in this thread.

Regards,
James
John C. Bollinger - 01 Dec 2005 02:00 GMT
>>It probably does mean that you cannot do RMI between the two apps, but
>>I'm not certain of it.  A better question for you to think about,
[quoted text clipped - 13 lines]
> I will probably code some functions to allow switching of RMI with an
> alternative solution that is recomended in this thread.

I personally would prefer a solution that works all the time.  I see two
 alternatives that look reasonable:

1) App A obtains the needed information from app B through appropriate
methods on B's web interface.  If you like buzz words, you could
describe this as B providing a web service that A uses.  This approach
makes sense if providing the required information falls in, or close to,
B's general area of operation.

2) App A and app B share a common back end with which they both
communicate, but which is logically separate from either.  They don't
communicate directly.  The back end might be as simple as a common
database, or as complex as a full-blown J2EE application comprising one
or more EJBs, etc.  A simpler RMI-based back end would fall in the
middle, and there are other alternatives as well.

I don't particularly care for the idea of B providing a back-door
interface for A to use to get a hold of information that B just happens
to be holding (though it's not clear whether that's what you were asking
about).

Signature

John Bollinger
jobollin@indiana.edu

James Yong - 01 Dec 2005 14:38 GMT
> I personally would prefer a solution that works all the time.  I see two
>   alternatives that look reasonable:
[quoted text clipped - 16 lines]
> to be holding (though it's not clear whether that's what you were asking
> about).

Hi John,

I think I like solution A better. Thanks for the advice. I have been trying
to look for information about doing a custom JDNI solution, but couldn't get
the revelant information. So I will go back and look at XML solutions

Regards,
James
Dennis Willson - 02 Dec 2005 22:29 GMT
Why not use something like SOAP or XML-RPC? That way it work the same on one JVM, two JVMs or remotely on a completely different
server.

>>Hello
>>1 JVM.I suppose it is virtual
[quoted text clipped - 6 lines]
> Regards,
> James
poundinc@yahoo.com - 28 Nov 2005 15:55 GMT
Hello
1 JVM.I suppose it is virtual
Roedy Green - 28 Nov 2005 16:27 GMT
>If I run 2 web applications in a Tomcat, is that 2 web application run by 2
>JVMs or 1 JVM?

One.
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.