5

When you deploy many applications to a java application server, do those applications all run in the same JVM i.e. the JVM that's started when the application server starts up?

Do you have the option to run each of those applications in a separate JVM? If so why would you want to do this?

Paul
  • 101
  • 5

4 Answers4

3

java application server runs in a single JVM, so every app deployed under java application server instance runs in the same VM as every other application while every app has a different class loader

Saddam Abu Ghaida
  • 6,381
  • 2
  • 22
  • 29
  • Thanks for your response Saddam. Does having different class loaders cause problems then? What if app1 uses a class that app2 uses. Will app2 try to load this class after app1 does so? Does Tomcat know this is already loaded and not try to load it again? – Paul Feb 12 '14 at 15:51
  • every app has its own shared memory context which is accessed by the same app, so app2 is not aware of the classes loaded in app1 and doesnt have access to it – Saddam Abu Ghaida Feb 12 '14 at 16:00
  • Sorry just a bit confused. Do you mean there is a shared memory context that Tomcat manages and each app gets its own private area in there so no classloading conflicts can occur? I've heard of classloading problems before but not sure how they occur. Thanks for your help. – Paul Feb 12 '14 at 16:07
1

Go through this questions's answer..hope all queries will be answered :

Why have one JVM per application?

Community
  • 1
  • 1
Vivek
  • 895
  • 11
  • 23
1

I am afraid you can't run in different JVMs because the appserver have to manage the objects life cycle. That's what JEE is all about. Also, that's why JEE states that you should not use threads in your app, because you want the container to take care of the concurrency for you.

Of course, in a clustered environment, you can have several JVMs, but still be the same for the app server + container.

Leo
  • 6,480
  • 4
  • 37
  • 52
0

Yes if the application server is not clustered.

Otherwise it could work on different host machine and jvm.

venergiac
  • 7,469
  • 2
  • 48
  • 70
  • but still, each app runs in the same JVM of the appserver right? Because the appserver manages some objects life cycles of the webapp. And that's also why JEE states that you must not use threads in your webapp, since it may break the JEE contract. – Leo Feb 12 '14 at 15:55
  • Not necessarily...you can deploy the app asymmetrically...1 app per each node...this mechanism is used for jee5 app running batches...jee7 manages batches – venergiac Feb 12 '14 at 17:58
  • I'd like to know more about this :-) [learning one new thing everyday] – Leo Feb 12 '14 at 18:36
  • JEE7 supports JSR 352 in other words batch processing in an application server; JEE6 supports Java Singleton EJB working on a single node and able to migrate if a node fails (http://docs.oracle.com/javaee/6/tutorial/doc/gipvi.html); JEE5 has not support (Weblogic supports EJB Singleton service) and we need a trick to integrate EJB application working on a singleton way over nodes. – venergiac Feb 12 '14 at 21:34
  • JSR 352 sounds like an evolution of JMS – Leo Feb 12 '14 at 22:38