8 Replies Latest reply on Mar 22, 2004 4:01 PM by Michael Daleiden

    Can't shutdown when running multiple instances (LONG, sorry)

    Dale Bronk Newbie

      I have posted this several times over the past several months and have yet to get it to work. Last time I posted in the config forum and received one reply which did not work. I have not seen anything in the docs either and really don't want to pay $200/hr for someone to tell me how to shutdown the server when it should be in the docs and a very easy thing to do. Yes, I may have missed it in the docs, but the docs are not that great. Yes, the product is free so I don't really bitch too much about the docs (although other open source have great docs).

      Windows 2000 server
      JBoss 3.2.3
      Setup my service-binding.xml as in the example and it is working great. My basic setup is that I have the default server setup in the service-binding.xml and for each additional instance I need I simply copy the default server and paste it in the same file, then change the name and simply increment each port by 100 from the last. Again, starting up multiple instances works great.

      Example: Default naming port 1099, default rmi port 1098, etc.
      defaultE2RD naming port 1199, defaultE2RD rmi port 1198, etc + 100.

      My problem is shutting down. The only option for me is ctrl+c but that sucks as I want to have scripts to deploy, stop, start, etc. Stack trace below.

      The shutdown command I enter is:
      C:\jboss-3.2.3\bin\shutdown.bat --server=defaultE2RD

      Note: I also don't know the command to stop/start remotely.
      The exception I get is below

      Note: it is trying to connect to defaultE2RD:1099, it should use the service-binding.xml and connect to defaultE2RD:1199

      Receive on reply that did not work:
      shutdown.sh --server=localhost:1099 --serverName=jboss.system:type=Server
      where 1099 is your jnp port (see your server.log)

      What do I need to enter for shutdown? Added bonus... How to do it remotely?

      Thanks,
      Dale

      10:33:00,231 WARN [NamingContext] Failed to connect to defaultE2RD:1099
      javax.naming.CommunicationException: Failed to connect to server defaultE2RD:1099 [Root exception is
      javax.naming.ServiceUnavailableException: Failed to connect to server defaultE2RD:1099 [Root except
      ion is java.net.UnknownHostException: defaultE2RD: defaultE2RD]]
      at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:215)
      at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1181)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:514)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:507)
      at javax.naming.InitialContext.lookup(InitialContext.java:347)
      at org.jboss.Shutdown.main(Shutdown.java:182)
      Caused by: javax.naming.ServiceUnavailableException: Failed to connect to server defaultE2RD:1099 [R
      oot exception is java.net.UnknownHostException: defaultE2RD: defaultE2RD]
      at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:190)
      ... 5 more
      Caused by: java.net.UnknownHostException: defaultE2RD: defaultE2RD
      at java.net.InetAddress.getAllByName0(InetAddress.java:1011)
      at java.net.InetAddress.getAllByName0(InetAddress.java:981)
      at java.net.InetAddress.getAllByName(InetAddress.java:975)
      at java.net.InetAddress.getByName(InetAddress.java:889)
      at org.jnp.interfaces.TimedSocketFactory.createSocket(TimedSocketFactory.java:61)
      at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:186)
      ... 5 more
      Exception in thread "main" java.lang.ClassCastException
      at org.jnp.interfaces.NamingContext.discoverServer(NamingContext.java:986)
      at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1192)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:514)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:507)
      at javax.naming.InitialContext.lookup(InitialContext.java:347)
      at org.jboss.Shutdown.main(Shutdown.java:182)

        • 1. Re: Can't shutdown when running multiple instances (LONG, so
          Dale Bronk Newbie

          Anyone at all have any suggestions?

          • 2. Re: Can't shutdown when running multiple instances (LONG, so
            Dale Bronk Newbie

            Well, if there is not a better way to shutdown JBoss than a ctrl+c in Windows and running multiple instances (ie: some command line way), then I am afraid I will not be recommending it to my clients. Simply should not have to pay $200/hr or $1200 for a class to learn how to correctly shut down the appserver.

            I'll keep using it for demo and development, but not for production.... Yet. We will see how 4.0 is. I am looking forward to it, just hope the documentation is 100% better than current docs... Which will still be short of what they should be.

            • 3. Re: Can't shutdown when running multiple instances (LONG, so
              Michael Daleiden Newbie

              The --server argument defaults to using port 1099 unless you specify otherwise:

              C:\jboss-3.2.3\bin\shutdown.bat --server=defaultE2RD:1199

              The scripts do not look at the configuration files, as there is no way for the scripts to know which configuration is actually running (remember, you can set up as many different configurations as you want, running them with
              C:\jboss-3.2.3\bin\run.bat -c <config name>

              Another important thing to note: the shutdown scripts can be used to remotely shutdown an instance of JBoss by simply specifying in the --server argument the name and port of the server that you want to shutdown.

              • 4. Re: Can't shutdown when running multiple instances (LONG, so
                Dale Bronk Newbie

                I do appreciate your reply, but it simply does not work. I tried as you specified and also tried with --server=localhost:1199 and it does not work either. Now, my bad was thinking the --server was expecting the JBoss server name, not the machine name. Still did not work with local host (get same error when trying to shutdown with --server=defaultE2RD:1199). But when using --server=127.0.0.1:1199 it works! Remote shutdown does not work, same error.

                Why doesn't it look at the same binding xml that run.bat uses? Why not allow me to specify this just as I do for starting up? That way if my config changes, but run/shutdown does not need to change.

                Here is how I start my server:
                C:\jboss-3.2.3\bin\run.bat -c defaultE2RD

                Here is the beginning snippet of my bindings.xml:

                <service-config name="jboss:service=Naming" delegateClass="org.jboss.services.binding.AttributeMappingDelegate">
                <delegate-config portName="Port" hostName="BindAddress">
                1198
                </delegate-config>

                </service-config>
                ...


                Here are parts of my startup console log:
                10:12:17,106 INFO [Server] Starting JBoss (MX MicroKernel)...
                10:12:17,106 INFO [Server] Release ID: JBoss [WonderLand] 3.2.3 (build: CVSTag=JBoss_3_2_3 date=200
                311301445)
                10:12:17,106 INFO [Server] Home Dir: C:\jboss-3.2.3
                10:12:17,106 INFO [Server] Home URL: file:/C:/jboss-3.2.3/
                10:12:17,106 INFO [Server] Library URL: file:/C:/jboss-3.2.3/lib/
                10:12:17,106 INFO [Server] Patch URL: null
                10:12:17,106 INFO [Server] Server Name: defaultE2RD
                10:12:17,106 INFO [Server] Server Home Dir: C:\jboss-3.2.3\server\defaultE2RD
                10:12:17,106 INFO [Server] Server Home URL: file:/C:/jboss-3.2.3/server/defaultE2RD/
                ...
                10:12:22,559 INFO [NamingService] Started jnpPort=1199, rmiPort=1198, backlog=50, bindAddress=/0.0.
                0.0, Client SocketFactory=null, Server SocketFactory=org.jboss.net.sockets.DefaultSocketFactory@ad09
                3076
                10:12:22,591 INFO [NamingService] Listening on port 1199
                10:12:22,606 INFO [NamingService] Started jboss:service=Naming
                10:12:22,606 INFO [JNDIView] Started jboss:service=JNDIView
                10:12:22,606 INFO [SecurityConfig] Started jboss.security:service=SecurityConfig

                Here is what I get with shutting down with --server=defaultE2RD:1199
                C:\jboss-3.2.3\bin>shutdown.bat --server=defaultE2RD:1199
                10:22:06,707 WARN [NamingContext] Failed to connect to defaultE2RD:1199
                javax.naming.CommunicationException: Failed to connect to server defaultE2RD:1199 [Root exception is
                javax.naming.ServiceUnavailableException: Failed to connect to server defaultE2RD:1199 [Root except
                ion is java.net.UnknownHostException: defaultE2RD: defaultE2RD]]
                at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:215)
                at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1181)
                at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:514)
                at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:507)
                at javax.naming.InitialContext.lookup(InitialContext.java:347)
                at org.jboss.Shutdown.main(Shutdown.java:182)
                Caused by: javax.naming.ServiceUnavailableException: Failed to connect to server defaultE2RD:1199 [R
                oot exception is java.net.UnknownHostException: defaultE2RD: defaultE2RD]
                at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:190)
                ... 5 more
                Caused by: java.net.UnknownHostException: defaultE2RD: defaultE2RD
                at java.net.InetAddress.getAllByName0(InetAddress.java:1011)
                at java.net.InetAddress.getAllByName0(InetAddress.java:981)
                at java.net.InetAddress.getAllByName(InetAddress.java:975)
                at java.net.InetAddress.getByName(InetAddress.java:889)
                at org.jnp.interfaces.TimedSocketFactory.createSocket(TimedSocketFactory.java:61)
                at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:186)
                ... 5 more
                Exception in thread "main" java.lang.ClassCastException
                at org.jnp.interfaces.NamingContext.discoverServer(NamingContext.java:986)
                at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1192)
                at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:514)
                at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:507)
                at javax.naming.InitialContext.lookup(InitialContext.java:347)
                at org.jboss.Shutdown.main(Shutdown.java:182)

                Dale

                • 5. Re: Can't shutdown when running multiple instances (LONG, so
                  dannyyates Newbie

                  Well, a tiny bit of logical thinking here...

                  If "localhost" doesn't work, but "127.0.0.1" does, that would suggest you have a naming issue resolving "localhost".

                  This is also bourne out by looking at the stack trace you have quoted. The most nested exception says "java.net.UnknownHostException: defaultE2RD", which says that Java cannot lookup the "defaultE2RD" name and resolve it to an IP address. Again - a naming issue.

                  So, can you "ping defaultE2RD"? I suspect not, and I therefore suspect that you have a DNS name lookup issue.

                  2 minutes of applying brain may well have saved waiting 2 weeks for somebody else to do your thinking for you. Or I may be wrong. But hey, I didn't charge $200 for the priviledge, right?

                  • 6. Re: Can't shutdown when running multiple instances (LONG, so
                    Michael Daleiden Newbie

                    As Danny mentions, the root of your problem is with name resolution, since it will shutdown properly when the IP address is specified. Is defaultE2RD the hostname of the machine, or simply the name of the JBoss configuration that you are running? The shutdown script takes the hostname or IP address of the machine, as well as the port, as the value for the --server argument.

                    As to your question about why the shutdown script does not look at the bindings XML, it gets back what arguments are being passed to the script (see above). The script cannot accept a JBoss configuration name as the argument, as it would then need to have some way of determining if that configuration was running locally or remotely and, based on that, need to figure out the hostname/IP address and port on which that configuration was running on that machine. Also, what if that configuration was running on multiple machines? Which one would you expect it to shut down? The local one, a random one, or all of them?

                    To give you a little more detail on what the shutdown script does, it uses the value of the --server argument to make a RMI connection to the JMX server instance running on the specified server and port. Once it connects to the JMX server, it executes the stop() method on the server instance, which initiates a clean shutdown of the JBoss instance that is using that JMX server as its backbone. You can accomplish the same thing through a web browser by pointing it at the server's JMX console:

                    http://<hostname>:8080/jmx-console

                    From the console, select the alias=jmx/rmi/RMIAdaptor entry under jboss.jmx, then invoke the stop() MBean operation to stop the JMX server (which will stop the other components and shut down the server).

                    Note: configuration "names" are a convenience for grouping components for a particular configuration. It does not uniquely identify a running server instance -- it simply identifies a top-level directory under which all of the configuration information and components for that configuration can be found.

                    It really doesn't get you anywhere to get angry in a post or reply (hint: danny). We are all working professionals and should conduct discussions in that same professional manner. People will be more likely to provide assistance if you state your questions, concerns, and comments clearly and without resorting to inappropriate comments or remarks.

                    • 7. Re: Can't shutdown when running multiple instances (LONG, so
                      Dale Bronk Newbie

                      Michael,

                      Thanks for your help... Still not sure why localhost or remote doesn't work (both get the same exception). And no, Danny, localhost is not resolved to anything other than localhost. I use localhost:8080 in my browser to connect to my jboss apps and it works fine and localhost to connect to just about anything else on my box.

                      But, since 127.0.0.1 works I am fine. Remote would be nice, but not a requirement.

                      The reason I thought I needed to give the jboss name and not the box name was I was led this way and localhost or the ip was not working. The box ip is 10.10.2.84 and that doesn't work either. Seems that ONLY 127.0.0.1 works for me.

                      Question... Is this in the documentation anywhere? I didn't seem to find anything about all the arguments for shutdown.

                      Again, thanks.

                      Dale

                      • 8. Re: Can't shutdown when running multiple instances (LONG, so
                        Michael Daleiden Newbie

                        What I have learned is from trial-and-error, scanning these forums, and scouring the source code for JBoss -- I have not paid for the advanced docs (yet), so I do not know if this is covered in them or not.

                        One other possibility for why your box is working strangely with shutdown: do you have multiple NICs? Type ipconfig /all in a DOS console window to see if there are multiple IP addresses configured for the box. Even if you don't have more than one physical network card installed, there is the possibility that more than one IP address has been configured (gotta luv Windows...)

                        To force JBoss to use a specific IP address (instead of what Windows thinks is the "default"), start jboss with the following syntax:

                        C:\jboss-3.2.3\bin\run.bat --host=10.10.2.84 -c defaultE2RD

                        Look through the log and make sure you see this IP address reflected in the startup. Once you do this, you should be able to do local and remote shutdown by using --server=10.10.2.84:1199 (or by going to the JMX console and clicking invoking the stop() method on the RMIAdaptor, if you want to shutdown without using the shutdown script -- great for shutting down a JBoss instance with just a web browser).