[Beginners Corner] - How to run JBoss as a service/daemon in RedHat?
by socal_javaguy
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/:
| #define where jboss is - this is the directory containing directories log, bin, conf etc
| JBOSS_HOME=${JBOSS_HOME:-"/usr/jboss-5.1.0.GA"}
|
| #define the user under which jboss will run, or use 'RUNASIS' to run as the current user
| JBOSS_USER=${JBOSS_USER:-"jboss"}
|
| #make sure java is in your path
| JAVAPTH=${JAVAPTH:-"/usr/java/jdk/bin"}
|
| #configuration to use, usually one of 'minimal', 'default', 'all'
| JBOSS_CONF=${JBOSS_CONF:-"default"}
|
| #if JBOSS_HOST specified, use -b to bind jboss services to that address
| JBOSS_BIND_ADDR=${JBOSS_HOST:+"-b $JBOSS_HOST"}
|
| #define the classpath for the shutdown class
| JBOSSCP=${JBOSSCP:-"$JBOSS_HOME/bin/shutdown.jar:$JBOSS_HOME/client/jnet.jar"}
|
| #define the script to use to start jboss
| JBOSSSH=${JBOSSSH:-"$JBOSS_HOME/bin/run.sh -c $JBOSS_CONF $JBOSS_BIND_ADDR"}
|
| if [ "$JBOSS_USER" = "RUNASIS" ]; then
| SUBIT=""
| else
| SUBIT="su - $JBOSS_USER -c "
| fi
|
| if [ -n "$JBOSS_CONSOLE" -a ! -d "$JBOSS_CONSOLE" ]; then
| # ensure the file exists
| touch $JBOSS_CONSOLE
| if [ ! -z "$SUBIT" ]; then
| chown $JBOSS_USER $JBOSS_CONSOLE
| fi
| fi
|
| if [ -n "$JBOSS_CONSOLE" -a ! -f "$JBOSS_CONSOLE" ]; then
| echo "WARNING: location for saving console log invalid: $JBOSS_CONSOLE"
| echo "WARNING: ignoring it and using /dev/null"
| JBOSS_CONSOLE="/dev/null"
| fi
|
| #define what will be done with the console log
| JBOSS_CONSOLE=${JBOSS_CONSOLE:-"/dev/null"}
|
| JBOSS_CMD_START="cd $JBOSS_HOME/bin; $JBOSSSH"
| JBOSS_CMD_STOP=${JBOSS_CMD_STOP:-"java -classpath $JBOSSCP org.jboss.Shutdown --shutdown"}
|
| if [ -z "`echo $PATH | grep $JAVAPTH`" ]; then
| export PATH=$PATH:$JAVAPTH
| fi
|
| if [ ! -d "$JBOSS_HOME" ]; then
| echo JBOSS_HOME does not exist as a valid directory : $JBOSS_HOME
| exit 1
| fi
|
| echo JBOSS_CMD_START = $JBOSS_CMD_START
|
| case "$1" in
| start)
| cd $JBOSS_HOME/bin
| if [ -z "$SUBIT" ]; then
| eval $JBOSS_CMD_START >${JBOSS_CONSOLE} 2>&1 &
| else
| $SUBIT "$JBOSS_CMD_START >${JBOSS_CONSOLE} 2>&1 &"
| fi
| ;;
| stop)
| if [ -z "$SUBIT" ]; then
| $JBOSS_CMD_STOP
| else
| $SUBIT "$JBOSS_CMD_STOP"
| fi
| ;;
| restart)
| $0 stop
| $0 start
| ;;
| *)
| echo "usage: $0 (start|stop|restart|help)"
| esac
|
(2) Made script executable and changed ownership by doing the following:
| sudo chown root:root /etc/init.d/jboss
| sudo chmod ug+x /etc/init.d/jboss
|
(3) When I tried to start it, I received the following output (and JBoss didn't start):
| JBOSS_CMD_START = cd /usr/jboss-5.1.0.GA/bin; /usr/jboss-5.1.0.GA/bin/run.sh -c default
|
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...
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4246311#4246311
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4246311
16 years, 11 months
[Clustering/JBoss] - Affinity and Failover
by diegom
Hello
I have a problem configuring session affinity and failover in a web application
I'm using apache httpd 2.2, jboss 4.2.3, and mod_jk.1.2.27
The affinity works fine, until a node goes down. At this moment, failover happens and the httpd server redirects to other (alive) node, but it doesn't set the affinity (ÿJSESSIONID cookie?) to this new node.
In all the JBoss nodes I set :
In jboss-web.deployer/META-INF/jboss-service.xml
<attribute name="UseJK" replace="true" trim="true">true</attribute>
In jboss-web.deployer/server.xml
<Engine name="jboss.web" defaultHost="localhost" jvmRoute="nodeX">
with diferent jvmRoute names for each node (in concordance with worker's names)
The mod-jk.conf file looks similar to this
| # Load mod_jk module
| LoadModule jk_module modules/mod_jk-1.2.27-httpd-2.2.10.so
|
| # Where to find workers.properties
| JkWorkersFile conf/workers.properties
|
| # Where to put jk logs
| JkLogFile logs/mod_jk.log
|
| # Set the jk log level [debug/error/info]
| JkLogLevel info
|
| # Select the log format
| JkLogStampFormat "[%a %b %d %H:%M:%S %Y]"
|
| # JkOptions indicates to send SSK KEY SIZE
| JkOptions +ForwardKeySize +ForwardURICompatUnparsed -ForwardDirectories
|
| # JkRequestLogFormat
| JkRequestLogFormat "%w %V %T"
|
| # You can use external file for mount points.
| JkMountFile conf/uriworkermap.properties
|
| # Add shared memory.
| JkShmFile logs/jk.shm
|
| # Add jkstatus for managing runtime data
| <Location /jkstatus >
| JkMount jkstatus
| Order deny,allow
| Deny from all
| Allow from all
| </Location>
|
And the workers.properties looks like this
| worker.list=loadbalancer,jkstatus
|
| worker.jkstatus.type=status
|
| # Define Node 1
| worker.node1.port=<port>
| worker.node1.host=<ip>
| worker.node1.type=ajp13
| worker.node1.lbfactor=1
|
| # Define Node 2
| worker.node2.port=<port>
| worker.node2.host=<ip>
| worker.node2.type=ajp13
| worker.node2.lbfactor=1
|
| # etc for more nodes...
|
| # Load-balancing behaviour
| worker.loadbalancer.type=lb
| worker.loadbalancer.balance_workers=node1,node2,<etc...>
| worker.loadbalancer.sticky_session=1
| worker.loadbalancer.retries=<number of nodes>
|
I think the problem is related to the JSESSIONID cookie which doesn't change after failover
What am I doing wrong?
Thanks in advance
PS: excuse my English, but I am a spanish speaker :-)
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4246309#4246309
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4246309
16 years, 11 months
[JBoss Cache: Core Edition] - Jboss Cache + Spring Security
by spezam_
Hello,
I'm currently stuck on this problem.
We have a two 4.2.3.GA servers cluster setup, configured with:
- Apache2 + mod_jk with sticky session
- JDK 1.6.0_07
- JbossCache 1.4.1.SP13 configured as a TreeCache
- Spring Security Framework 2.5.5
The two nodes see each other, and the cluster is synced. When a session is created I can see the replication on the other node, through the JMX console.
The problem occurs when one of the nodes go down and the application tries to recover the session. The application throws the following exception:
21:56:10,078 ERROR [JBossCacheService] loadSession(): id: UjsgmlsqnWDTJh6aOmxz exception occurred during deserialization
java.lang.ArrayStoreException: org.springframework.security.GrantedAuthorityImpl
at java.io.ObjectInputStream.readArray(ObjectInputStr eam.java:1667)
at java.io.ObjectInputStream.readObject0(ObjectInputS tream.java:1323)
at java.io.ObjectInputStream.defaultReadFields(Object InputStream.java:1947)
at java.io.ObjectInputStream.readSerialData(ObjectInp utStream.java:1871)
at java.io.ObjectInputStream.readOrdinaryObject(Objec tInputStream.java:1753)
at java.io.ObjectInputStream.readObject0(ObjectInputS tream.java:1329)
at java.io.ObjectInputStream.defaultReadFields(Object InputStream.java:1947)
at java.io.ObjectInputStream.readSerialData(ObjectInp utStream.java:1871)
at java.io.ObjectInputStream.readOrdinaryObject(Objec tInputStream.java:1753)
at java.io.ObjectInputStream.readObject0(ObjectInputS tream.java:1329)
at java.io.ObjectInputStream.readObject(ObjectInputSt ream.java:351)
at java.util.concurrent.ConcurrentHashMap.readObject( ConcurrentHashMap.java:1275)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at java.io.ObjectStreamClass.invokeReadObject(ObjectS treamClass.java:974)
at java.io.ObjectInputStream.readSerialData(ObjectInp utStream.java:1849)
at java.io.ObjectInputStream.readOrdinaryObject(Objec tInputStream.java:1753)
at java.io.ObjectInputStream.readObject0(ObjectInputS tream.java:1329)
at java.io.ObjectInputStream.readObject(ObjectInputSt ream.java:351)
at org.jboss.web.tomcat.service.session.SessionBasedC lusteredSession.readExternal(SessionBasedClustered Session.java:154)
at org.jboss.web.tomcat.service.session.JBossCacheSer vice.loadSession(JBossCacheService.java:284)
at org.jboss.web.tomcat.service.session.JBossCacheMan ager.loadSession(JBossCacheManager.java:1041)
at org.jboss.web.tomcat.service.session.JBossCacheMan ager.findSession(JBossCacheManager.java:813)
at org.apache.catalina.connector.Request.doGetSession (Request.java:2283)
at org.apache.catalina.connector.Request.getSession(R equest.java:2075)
at org.jboss.web.tomcat.service.session.JvmRouteValve .checkJvmRoute(JvmRouteValve.java:91)
at org.jboss.web.tomcat.service.session.JvmRouteValve .invoke(JvmRouteValve.java:81)
at org.jboss.web.tomcat.security.JaccContextValve.inv oke(JaccContextValve.java:84)
at org.apache.catalina.core.StandardHostValve.invoke( StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke (ErrorReportValve.java:102)
at org.jboss.web.tomcat.service.sso.ClusteredSingleSi gnOn.invoke(ClusteredSingleSignOn.java:638)
at org.apache.catalina.core.StandardEngineValve.invok e(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.servic e(CoyoteAdapter.java:262)
at org.apache.coyote.ajp.AjpAprProcessor.process(AjpA prProcessor.java:419)
at org.apache.coyote.ajp.AjpAprProtocol$AjpConnection Handler.process(AjpAprProtocol.java:378)
at org.apache.tomcat.util.net.AprEndpoint$SocketWithO ptionsProcessor.run(AprEndpoint.java:1928)
at java.util.concurrent.ThreadPoolExecutor$Worker.run Task(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)
I'm not sure it's a spring security problem. We tried to debug the application and apparently the session content is empty.
Anyone experienced the same problem or have an idea of the cause?
Thanks in advance for your reply.
Mattie
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4246308#4246308
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4246308
16 years, 11 months