Running 2 webapp in Tomcat - 1 or 2 JVMs

J

James Yong

Hi,

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

Regards,
James
 
J

James Yong

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
 
C

cbroussard

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
 
R

Roedy Green

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.
 
R

Roedy Green

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.
 
R

Roedy Green

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.
 
J

John C. Bollinger

James said:
Thanks.

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.
 
P

pkriens

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
 
J

James Yong

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
 
J

James Yong

Roedy Green said:
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
 
J

James Yong

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

Hi cbroussard,

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

Regards,
James
 
R

Roedy Green

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
 
J

James Yong

Roedy Green said:
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

Hi Roedy,

Thanks for the explanation

Regards,
James
 
J

John C. Bollinger

James said:
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.

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).
 
J

James Yong

John C. Bollinger said:
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).

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
 
D

Dennis Willson

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top