File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JBoss/WildFly and the fly likes Running JBoss-5.1.0.GA as a service on Red Hat? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Products » JBoss/WildFly
Bookmark "Running JBoss-5.1.0.GA as a service on Red Hat?" Watch "Running JBoss-5.1.0.GA as a service on Red Hat?" New topic
Author

Running JBoss-5.1.0.GA as a service on Red Hat?

James Dekker
Ranch Hand

Joined: Dec 09, 2006
Posts: 215
I am using JBoss 5.1.0 GA on Red Hat (Amazon ECS)...

Am trying to set it up so JBoss will run as a service / daemon (right now it only starts up when I manually SSH and invoke sh $JBOSS_HOME/bin/run.sh).

Here's what I did so far:

(1) Created the following jboss script in /etc/init.d/:



(2) Made script executable and changed ownership by doing the following:



(3) When I tried to start it, I received the following output (and JBoss didn't start):



Questions:

(1) What am I possibly doing wrong?

(2) How do I set it up so it runs as root user? Do I have to add a JBoss group and a JBoss user?

I can manually run JBoss through $JBOSS_HOME/bin but would love to have it running all the time...

Any help is greatly appreciated...
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5838
    
    7

We cover this topic in detail in chapter 15 of JBoss in Action, section 15.6.3. And if you get the source code for the book, target 04 in project ch15 sets it up.

One of the things I found helpful in debugging the start script is to run it manually first. The first time through, comment out the 'su' lines (22-26) so that only your account is used. Then make sure the script brings up the app server. The reintroduce the 'su' lines and run it again (while logged in as root). Oh, and add echo statements to let you know how far the script got before it gave up.


JBoss In Action
James Dekker
Ranch Hand

Joined: Dec 09, 2006
Posts: 215
Hi Peter,

It seems that the source code for the book with the Ant target of 04 sets up 2 different JBoss servers, right?

How could I set it up to so only one JBoss instance / service / daemon is running?

Was there any errors with my previous script above?

The Chapter 15 directory / linux has 3 build scripts (of two of which are of particular interest):

-jboss_init_redhat.sh
-install.sh

Which file should I use?

I don't have your book so this does make my task harder...

There's no easy way to write a jboss script which will be placed under /etc/init.d/ and always make jboss run?

Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5838
    
    7

I started with the jboss_init_redhat.sh. And yes the sample code builds two services, but if you need only one, register only one. The whole point of doing two services is because people always ask "how can I pass the -b or -c option when I start as a service", so doing two services forces one to provide the answer to such questions. You can always just grab one of generated scripts and use it (after making appropriate changes for the -b and -c options).

I did not see anything in particular about your script that was incorrect - that is why I gave you suggested mechanism to debug the script - those are the same things I went through to get my scripts running.
James Dekker
Ranch Hand

Joined: Dec 09, 2006
Posts: 215
I finally am able to run jboss through my jboss script in /etc/init.d/

jboss (located in /etc/init.d/):



Set up all the permissions and run levels like this:



When I try to start up like this:
$ /etc/init.d/./jboss start

It works! :




Please take note of the JAVA and CLASSPATH variables values...

Breaks when I do:

$ service jboss start



This code block here (line 261 in $JBOSS_HOME/bin/run.sh):



Please note the differences in the JAVA and CLASSPATH variables compared to when I ran it manually using ./jboss start under /etc/init.d/.

I got my script working underneath /etc/init.d/jboss

but not under "service jboss start"

Would extremely be grateful if someone could help me...

-James
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5838
    
    7

I think you need some echo statements to find out when $JAVA_HOME was changed from "/usr/java/jdk/" to empty. First, make sure that line 4 really does set it, and check it again before and after lines 103-110 in run.sh. Also, echo out $JAVA at the same time.

When you run:

/etc/init.d/./jboss start

the scripts use your current environment. When you use:

service jboss start

the scripts use a different environment. A good debug tool is to dump out all of the environment variables at the start of the script.
James Dekker
Ranch Hand

Joined: Dec 09, 2006
Posts: 215
Hi Peter,

I bought your book! Yes, I tried following what you said by doing this (notice the run levels in the header):



And when I issue this:

service jboss start

This is what echoes out:



Notice how the tools.jar isn't even included on the CLASSPATH when JBoss start...
This system was installed as the root user with no jboss created on Fedora 8 (32 bit)...

In addition, I am unable to do this:

chkconfig --add jboss

"service jboss does not support chkconfig"

When I run it like this:
/etc/init.d/./jboss

It runs perfectly and does this:



I even created a .bash_profile under /root:



Why are the environments different when you type in service jboss start opposed to running the shell script manually?

At this point, I am stumped...

-James
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Running JBoss-5.1.0.GA as a service on Red Hat?