• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Carey Brown
  • Stephan van Hulst
  • Tim Holloway
  • Peter Rooke
  • Himai Minh
Bartenders:
  • Piet Souris
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 229
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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...
 
author
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
James Dekker
Ranch Hand
Posts: 229
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 229
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 229
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
reply
    Bookmark Topic Watch Topic
  • New Topic