my dog learned polymorphism*
The moose likes JBoss/WildFly and the fly likes Two jboss instances with different JVM Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Products » JBoss/WildFly
Bookmark "Two jboss instances with different JVM" Watch "Two jboss instances with different JVM" New topic
Author

Two jboss instances with different JVM

lochan serma
Greenhorn

Joined: Apr 22, 2011
Posts: 23
Hi,

Could anyone please help me.
I am running two jboss instances (Jboss 4.0.3SP1) under linux(RHEL), each instance with a different web application. Each of these application require different JVM so i need to run each of these instances with different JVM. I googled but that only adds more confusion. How can I use two different run.sh script to set different JVMs for each of these instances? Please describe me in detail.

I have used service binding manager to avoid port conflicts.

Any help would be greatly appreciated.

Thank You
Lochan
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 9915
    
158

Use 2 different wrapper scripts. Each setting the JAVA_HOME appropriately and then calling run.sh. Something like:

jmv1.sh in bin :


jmv2.sh in bin:


The invoke jvm1.sh and jvm2.sh.

[My Blog] [JavaRanch Journal]
lochan serma
Greenhorn

Joined: Apr 22, 2011
Posts: 23
Hi Jaikiran,
Thank you so much for the reply. But I get the following error when i run the script as suggested by you.


JBoss Bootstrap Environment

JBOSS_HOME: /opt/jboss/jboss-4.0.3SP1/server/default

JAVA: /opt/java/jdk1.5.0_15/bin/java

JAVA_OPTS: -server -Xms128m -Xmx128m -Dprogram.name=run.sh

CLASSPATH: /opt/jboss/jboss-4.0.3SP1/server/default/bin/run.jar:/opt/java/jdk1.5.0_15/lib/tools.jar

=========================================================================

Failed to boot JBoss:
java.lang.ClassNotFoundException: org.jboss.system.server.ServerImpl
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at org.jboss.system.server.ServerLoader.createServer(ServerLoader.java:267)
at org.jboss.system.server.ServerLoader.load(ServerLoader.java:249)
at org.jboss.Main.boot(Main.java:179)
at org.jboss.Main$1.run(Main.java:438)
at java.lang.Thread.run(Thread.java:595)
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 9915
    
158

JBOSS_HOME: /opt/jboss/jboss-4.0.3SP1/server/default


Did you set JBOSS_HOME? The value you set is incorrect. Do not set it. It will be automatically set by the startup scripts.

lochan serma
Greenhorn

Joined: Apr 22, 2011
Posts: 23
Hi Jaikiran,

Thank you so much again for your time and concern.

I have not set JBOSS_HOME variable though i am still getting the error.

I have copied the original /bin folder to the new node and then created a jvm1.sh script for that node. The jvm1.sh script contains:

export JAVA_HOME=/opt/java/jdk1.6.0_17
./run.sh

I really appreciate your help.
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 9915
    
158

lochan serma wrote:
I have copied the original /bin folder to the new node and then created a jvm1.sh script for that node. The jvm1.sh script contains:


Do not copy the bin to any folder. Just create jvm1.sh and jvm2.sh in the JBOSS_HOME/bin folder.
lochan serma
Greenhorn

Joined: Apr 22, 2011
Posts: 23
Hi Jaikiran,

Thank you so much for you effort and selfless help. I really appreciate it.

I am done with my work now.
What I did was created a Wrapper for one node as you said e.g. jvm.sh and ran the other node with the original run.sh script. As I included JDK 1.5 in jvm.sh script and the default JDK is 1.6 my probelm was resolved.

Thank you once again.

Lochan
Sushma Sharma
Ranch Hand

Joined: Jun 02, 2005
Posts: 139
Lochan/Jaikiran,

I might have to do something similar. I currently have one copy/folder of jboss4.2.3GA and jdk1.5. If I want to have two instances of jboss running on the same server, do I have to have two copies/folders of jboss installation? We want to have separate jboss instance with separate jvm for each application. How do I achieve that?

Thanks,
Sushma
lochan serma
Greenhorn

Joined: Apr 22, 2011
Posts: 23
Hi Susma,

JBoss can be configured to run two different instances hosting separate applications concurrently.

Folder Structure
/opt/jboss-4.2.3GA/server

- default \\ The default folder
- node1 \\ Copy of default folder (Copy default folder and rename it. If you are using clusters copy "all" folder as it supports clusters)
- all
- minimal

The main problem when running two or more instances of the JBoss Application server is that they use the same port. You can make sure that these two instances use different ports by using the "binding service manager". You can use two different ports configuration for those two instances. e.g. ports-01 for default instance and ports-02 for node1.

Now to run these instances go to the /opt/jboss/jboss-4.2.3GA/bin file and run the command
#./run.sh -c default & (run the default instance)
#./run.sh -c node1 & (run the node1 instance)

To check the instances, you can can browse
http://192.168.72.16:8180 (if you use ports-01 for default, Jboss will run on 8180 port)
http://192.168.72.16:8280 (if you use ports-02 for node1, Jboss will run on 8280 port)
By default Jboss is configured with ports-default so by default Jboss runs on 8080 port. Notice the increment of 100 in each ports-configuration. This is how distinct ports are guaranteed.

To shutdown these instances run the following command from the bin folder
./shutdown.sh -s jnp://localhost:1199 (for default instance)
./shutdown.sh - s jnp://localhost:1299 (for node1 instance)

Hope, this might help you.


Sushma Sharma
Ranch Hand

Joined: Jun 02, 2005
Posts: 139
Thanks Lochan. This is exactly what I was looking for.
Priya sin
Greenhorn

Joined: Jun 06, 2012
Posts: 3
Hi Jaikiran,
I wanted to do the same thing i,.e want to run different JBoss instances with different jvm's. But this I wanted to do on Windows OS instead of Unix.
Could you please tell me how to do that .
I have already set the JAVA_HOME which is pointing to JDK1.6 and I want node 3 to point to JDK1.5 . How to do that ?
Thanks
Singh
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 9915
    
158

Priya, welcome to JavaRanch!

I wanted to do the same thing i,.e want to run different JBoss instances with different jvm's. But this I wanted to do on Windows OS instead of Unix.

Like the example in this thread, you can use two different scripts to set the appropriate JAVA_HOME location and then trigger the run script of JBoss AS. Since you are on Windows OS you'll have to use two different .bat files and internally call the run.bat.
Priya sin
Greenhorn

Joined: Jun 06, 2012
Posts: 3
Hi Jaikiran,
Thanks for the instant reply..
Actually initially i tried with the same script which was there in the thread but later on found out that it will work only on UNIX OS.
I tried doing this but still it is not working

set "JAVA_HOME=C:\Java5\jdk1.5.0_16"
./run.bat

but one thing I noticed that after running this several times again i switched back to my run.bat and started the node 3 like run.bat -c node3
And in the console I saw that this node3 is pointng to JAVA_HOME=C:\Java5\jdk1.5.0_16 ...Don't have any information how it is doing so..
Please let me know if you have any information

Thanks
Priya
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Two jboss instances with different JVM
 
Similar Threads
Apache mod_jk and Jboss
local vs remote
Multiple JVM in same machine
one servlet container per server or per JVM?
Changing JNDI port for JBOSS 5.1.0