6 Replies Latest reply on Dec 26, 2008 4:30 AM by mrfarhankhan

    How to avoid starting JBoss AS, if already running

    mrfarhankhan

      Hello,

      I want to configure my JBoss so that if another instance is laready running on the same machine, then it should not start. How can I do that ??? Currently, it start another instance on some other port.

      Thanks in advance
      Farhan !

        • 1. Re: How to avoid starting JBoss AS, if already running
          jaikiran

           

          "mrfarhankhan" wrote:
          Hello,

          Currently, it start another instance on some other port.



          Are you sure it starts successfully? I would expect the second instance to fail to start when the first one is already running (and if you have not configured a different set of ports for the second instance).

          • 2. Re: How to avoid starting JBoss AS, if already running
            mrfarhankhan

            Thanks for your prompt response. Please see the server logs as following. My requirement is that if the server is already running, then another instance should not start, instead it should give a message and exit.

            ================================================
            I Depend On:
            jboss.mq:service=DestinationManager

            ObjectName: jboss.mq.destination:service=Queue,name=B
            State: CONFIGURED
            I Depend On:
            jboss.mq:service=DestinationManager

            ObjectName: jboss.mq.destination:service=Queue,name=C
            State: CONFIGURED
            I Depend On:
            jboss.mq:service=DestinationManager

            ObjectName: jboss.mq.destination:service=Queue,name=D
            State: CONFIGURED
            I Depend On:
            jboss.mq:service=DestinationManager

            ObjectName: jboss.mq.destination:service=Queue,name=ex
            State: CONFIGURED
            I Depend On:
            jboss.mq:service=DestinationManager

            ObjectName: jboss.mq:service=Invoker
            State: CONFIGURED
            I Depend On:
            jboss.mq:service=TracingInterceptor
            jboss:service=Naming
            Depends On Me:
            jboss.mq:service=InvocationLayer,type=HTTP
            jboss.mq:service=InvocationLayer,type=JVM
            jboss.mq:service=InvocationLayer,type=UIL2

            ObjectName: jboss.mq:service=TracingInterceptor
            State: CONFIGURED
            I Depend On:
            jboss.mq:service=SecurityManager
            Depends On Me:
            jboss.mq:service=Invoker

            ObjectName: jboss.mq:service=SecurityManager
            State: CONFIGURED
            I Depend On:
            jboss.security:service=JaasSecurityManager
            jboss.mq:service=DestinationManager
            Depends On Me:
            jboss.mq.destination:service=Topic,name=testTopic
            jboss.mq.destination:service=Topic,name=securedTopic
            jboss.mq.destination:service=Topic,name=testDurableTopic
            jboss.mq.destination:service=Queue,name=testQueue
            jboss.mq:service=TracingInterceptor
            jboss.mq.destination:service=Queue,name=DLQ

            ObjectName: jboss.mq.destination:service=Queue,name=DLQ
            State: CONFIGURED
            I Depend On:
            jboss.mq:service=DestinationManager
            jboss.mq:service=SecurityManager

            ObjectName: jboss.mq:service=InvocationLayer,type=JVM
            State: CONFIGURED
            I Depend On:
            jboss.mq:service=Invoker

            ObjectName: jboss.mq:service=InvocationLayer,type=UIL2
            State: CONFIGURED
            I Depend On:
            jboss.mq:service=Invoker

            ObjectName: jboss.mq:service=InvocationLayer,type=UIL
            State: CONFIGURED
            I Depend On:
            jboss:service=Naming

            ObjectName: jboss.mq:service=InvocationLayer,type=UILXA
            State: CONFIGURED
            I Depend On:
            jboss:service=Naming

            ObjectName: jboss.mq:service=InvocationLayer,type=UIL2,alias=UIL2ConnectionFacto
            ry
            State: CONFIGURED
            I Depend On:
            jboss:service=Naming

            ObjectName: jboss.mq:service=InvocationLayer,type=UIL2XA,alias=UIL2XAConnectionF
            actory
            State: CONFIGURED
            I Depend On:
            jboss:service=Naming

            ObjectName: jboss.jms:alias=QueueConnectionFactory
            State: CONFIGURED
            I Depend On:
            jboss:service=Naming

            ObjectName: jboss.jms:alias=TopicConnectionFactory
            State: CONFIGURED
            I Depend On:
            jboss:service=Naming

            ObjectName: jboss.jmx:type=adaptor,name=Invoker,protocol=jrmp,service=proxyFacto
            ry
            State: CONFIGURED
            I Depend On:
            jboss:service=invoker,type=jrmp
            jboss.jmx:type=adaptor,name=Invoker
            jboss:service=Naming
            Depends On Me:
            jboss.admin:service=PluginManager
            jboss.jmx:type=adaptor,name=MBeanProxyRemote,protocol=jrmp

            ObjectName: jboss.jmx:type=adaptor,name=MBeanProxyRemote,protocol=jrmp
            State: CONFIGURED
            I Depend On:
            jboss.jmx:type=adaptor,name=Invoker,protocol=jrmp,service=proxyFactory

            ObjectName: jboss.jmx:alias=jmx/rmi/RMIAdaptor
            State: CONFIGURED
            I Depend On:
            jboss:service=Naming

            ObjectName: jboss:service=Mail
            State: CONFIGURED
            I Depend On:
            jboss:service=Naming

            ObjectName: jboss:service=Hypersonic,database=localDB
            State: FAILED
            Reason: java.sql.SQLException: The database is already in use by another proce
            ss: org.hsqldb.persist.NIOLockFile@e69accf7[file =C:\jboss-4.2.2.GA\server\defau
            lt\data\hypersonic\localDB.lck, exists=true, locked=false, valid=false, fl =null
            ]: java.lang.Exception: java.io.IOException: The process cannot access the file
            because another process has locked a portion of the file : C:\jboss-4.2.2.GA\se
            rver\default\data\hypersonic\localDB.lck
            Depends On Me:
            jboss.jca:service=ManagedConnectionFactory,name=DefaultDS

            --- MBEANS THAT ARE THE ROOT CAUSE OF THE PROBLEM ---
            ObjectName: jboss:service=Hypersonic,database=localDB
            State: FAILED
            Reason: java.sql.SQLException: The database is already in use by another proce
            ss: org.hsqldb.persist.NIOLockFile@e69accf7[file =C:\jboss-4.2.2.GA\server\defau
            lt\data\hypersonic\localDB.lck, exists=true, locked=false, valid=false, fl =null
            ]: java.lang.Exception: java.io.IOException: The process cannot access the file
            because another process has locked a portion of the file : C:\jboss-4.2.2.GA\se
            rver\default\data\hypersonic\localDB.lck
            Depends On Me:
            jboss.jca:service=ManagedConnectionFactory,name=DefaultDS

            ObjectName: jboss.remoting:service=Connector,transport=socket
            State: FAILED
            Reason: java.net.BindException: Address already in use: JVM_Bind
            I Depend On:
            jboss.remoting:service=NetworkRegistry
            Depends On Me:
            jboss:service=invoker,type=unified

            ObjectName: jboss:service=Naming
            State: FAILED
            Reason: java.rmi.server.ExportException: Port already in use: 1098; nested exc
            eption is:
            java.net.BindException: Address already in use: JVM_Bind
            I Depend On:
            jboss.system:service=ThreadPool
            jboss:service=NamingBeanImpl
            Depends On Me:
            jboss.mq:service=DestinationManager
            jboss.mq:service=Invoker
            jboss.mq:service=InvocationLayer,type=UIL
            jboss.mq:service=InvocationLayer,type=UILXA
            jboss.mq:service=InvocationLayer,type=UIL2,alias=UIL2ConnectionFactory
            jboss.mq:service=InvocationLayer,type=UIL2XA,alias=UIL2XAConnectionFactory
            jboss.jms:alias=QueueConnectionFactory
            jboss.jms:alias=TopicConnectionFactory
            jboss.jmx:type=adaptor,name=Invoker,protocol=jrmp,service=proxyFactory
            jboss.jmx:alias=jmx/rmi/RMIAdaptor
            jboss:service=Mail

            ObjectName: jboss:service=WebService
            State: FAILED
            Reason: java.lang.Exception: Port 8083 already in use.
            I Depend On:
            jboss.system:service=ThreadPool
            Depends On Me:
            jboss.ejb:service=EJBDeployer

            ObjectName: jboss.remoting:type=Connector,name=DefaultEjb3Connector,handler=ejb3

            State: FAILED
            Reason: java.net.BindException: Address already in use: JVM_Bind
            I Depend On:
            jboss.aop:service=AspectDeployer

            ObjectName: jboss:service=invoker,type=pooled
            State: FAILED
            Reason: java.lang.Exception: Port 4445 is already in use
            I Depend On:
            jboss:service=TransactionManager

            ObjectName: jboss:service=invoker,type=jrmp
            State: FAILED
            Reason: java.rmi.server.ExportException: Port already in use: 4444; nested exc
            eption is:
            java.net.BindException: Address already in use: JVM_Bind
            I Depend On:
            jboss:service=TransactionManager
            Depends On Me:
            jboss:service=proxyFactory,target=ClientUserTransactionFactory
            jboss:service=proxyFactory,target=ClientUserTransaction
            jboss.jmx:type=adaptor,name=Invoker,protocol=jrmp,service=proxyFactory


            at org.jboss.deployment.MainDeployer.checkIncompleteDeployments(MainDepl
            oyer.java:1385)
            at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:785)
            at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:766)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
            java:39)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
            sorImpl.java:25)
            at java.lang.reflect.Method.invoke(Method.java:597)
            at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatch
            er.java:155)
            at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
            at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractIntercept
            or.java:133)
            at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
            at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelM
            BeanOperationInterceptor.java:142)
            at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
            at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.
            java:264)
            at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
            at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
            at $Proxy5.deploy(Unknown Source)
            at org.jboss.system.server.ServerImpl.doStart(ServerImpl.java:482)
            at org.jboss.system.server.ServerImpl.start(ServerImpl.java:362)
            at org.jboss.Main.boot(Main.java:200)
            at org.jboss.Main$1.run(Main.java:508)
            at java.lang.Thread.run(Thread.java:619)
            13:08:15,718 ERROR [Http11Protocol] Error starting endpoint
            java.net.BindException: Address already in use: JVM_Bind:8080
            at org.apache.tomcat.util.net.JIoEndpoint.init(JIoEndpoint.java:500)
            at org.apache.tomcat.util.net.JIoEndpoint.start(JIoEndpoint.java:514)
            at org.apache.coyote.http11.Http11Protocol.start(Http11Protocol.java:203
            )
            at org.apache.catalina.connector.Connector.start(Connector.java:1146)
            at org.jboss.web.tomcat.service.JBossWeb.startConnectors(JBossWeb.java:5
            84)
            at org.jboss.web.tomcat.service.JBossWeb.handleNotification(JBossWeb.jav
            a:621)
            at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
            sorImpl.java:25)
            at java.lang.reflect.Method.invoke(Method.java:597)
            at org.jboss.mx.notification.NotificationListenerProxy.invoke(Notificati
            onListenerProxy.java:153)
            at $Proxy35.handleNotification(Unknown Source)
            at org.jboss.mx.util.JBossNotificationBroadcasterSupport.handleNotificat
            ion(JBossNotificationBroadcasterSupport.java:127)
            at org.jboss.mx.util.JBossNotificationBroadcasterSupport.sendNotificatio
            n(JBossNotificationBroadcasterSupport.java:108)
            at org.jboss.system.server.ServerImpl.sendNotification(ServerImpl.java:9
            16)
            at org.jboss.system.server.ServerImpl.doStart(ServerImpl.java:497)
            at org.jboss.system.server.ServerImpl.start(ServerImpl.java:362)
            at org.jboss.Main.boot(Main.java:200)
            at org.jboss.Main$1.run(Main.java:508)
            at java.lang.Thread.run(Thread.java:619)
            13:08:15,734 WARN [JBossWeb] Failed to startConnectors
            LifecycleException: service.getName(): "jboss.web"; Protocol handler start fai
            led: java.net.BindException: Address already in use: JVM_Bind:8080
            at org.apache.catalina.connector.Connector.start(Connector.java:1153)
            at org.jboss.web.tomcat.service.JBossWeb.startConnectors(JBossWeb.java:5
            84)
            at org.jboss.web.tomcat.service.JBossWeb.handleNotification(JBossWeb.jav
            a:621)
            at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
            sorImpl.java:25)
            at java.lang.reflect.Method.invoke(Method.java:597)
            at org.jboss.mx.notification.NotificationListenerProxy.invoke(Notificati
            onListenerProxy.java:153)
            at $Proxy35.handleNotification(Unknown Source)
            at org.jboss.mx.util.JBossNotificationBroadcasterSupport.handleNotificat
            ion(JBossNotificationBroadcasterSupport.java:127)
            at org.jboss.mx.util.JBossNotificationBroadcasterSupport.sendNotificatio
            n(JBossNotificationBroadcasterSupport.java:108)
            at org.jboss.system.server.ServerImpl.sendNotification(ServerImpl.java:9
            16)
            at org.jboss.system.server.ServerImpl.doStart(ServerImpl.java:497)
            at org.jboss.system.server.ServerImpl.start(ServerImpl.java:362)
            at org.jboss.Main.boot(Main.java:200)
            at org.jboss.Main$1.run(Main.java:508)
            at java.lang.Thread.run(Thread.java:619)
            13:08:15,750 INFO [Server] JBoss (MX MicroKernel) [4.2.2.GA (build: SVNTag=JBos
            s_4_2_2_GA date=200710221139)] Started in 53s:313ms

            • 3. Re: How to avoid starting JBoss AS, if already running
              peterj

              There is no way to do this within JBoss AS itself. However, the run script is, after all, just a script. You can modify the script to test if another instance is running first, either by examining the existing processes or using a "lock" file. How you do either of those depends on the operating system.

              • 4. Re: How to avoid starting JBoss AS, if already running
                mrfarhankhan

                I have Linux Fedora Core 9 installed on my server. Would you please guide me through the steps to modify the run script. I would really appreciate if you provide me some sample script.

                Thanks in advance.
                Farhan !

                • 5. Re: How to avoid starting JBoss AS, if already running
                  peterj

                  Too bad you are not running Windows or I would have pointed you to the service.bat script (comes with JBoss AS 5.0 and with JBoss Native). That script uses a lock file to prevent multiple runs.

                  For Linux, look at the jboss_home/bin/jboss_init_hpux.sh script. It greps the output from ps looking for a JBoss AS instance running. I don't know if you can use that script as-is on Fedora, but if not you should be able to use the code that does the isJBossRunning check as an example for writing your own code.

                  • 6. Re: How to avoid starting JBoss AS, if already running
                    mrfarhankhan

                    Thankyou Peter ! I have solved the problem by adding the following to my runJBoss.sh script

                    jbossRunning=$(ps -ef | grep "sh runJBoss.sh" | grep -vc grep)
                    echo "jbossRunning = " $jbossRunning

                    if [ $jbossRunning -gt 2 ]; then
                    die "Already running JBoss . . . Going to exit"
                    else
                    warn "No instance running. Going to start this"
                    fi

                    I would also try the other method that you mentioned.

                    Thanks a lot
                    Farhan !