1 2 Previous Next 25 Replies Latest reply on Oct 25, 2010 11:03 PM by mirkasim

    Running HornetQ as a windows service

    hughbragg

      I've been trying to get this to run for ages now and run into a lot of problems.

       

      Attempt 1: Someone here has a VB.Net service runner that installs a service and stops it.

           I wrote a few scripts and it worked... BUT:

           The jmx console isn't accessible locally. It's there but jconsole or another program can't access it since they can't find how the program's main entry point is so all I see is the pid greyed out. same in the new jvisualvm.

       

      Attempt 2: Use tomcats service installer with jdk x64. After some considerable experimentaions I created this script (WIP, see bellow):

           BUT: java x64 has issues and I couldn't get the right dlls to load

       

      Attempt 3: Use tomcat service installer with jdk x86.

       

      setlocal ENABLEDELAYEDEXPANSION

       

      rem Start HornetQ using the profile1

       

      set HORNET_BASE=C:\Apps\HornetQ
      set HORNET_HOME=%HORNET_BASE%\hornetq-2.1.2.Final
      set HORNET_BIN=%HORNET_HOME%\bin
      set APP_HOME=%HORNET_BASE%\Profile1
      set APP_DATA=%APP_HOME%\data

       

      set CLASSPATH=%APP_HOME%;%HORNET_HOME%\schemas\

       

      for /R %HORNET_HOME%\lib %%A in (*.jar) do (
        SET CLASSPATH=!CLASSPATH!;%%A
      )

       

      set JVM_ARGS=-XX:+UseParallelGC;-XX:+AggressiveOpts;-XX:+UseFastAccessorMethods;-Dhornetq.config.dir=%APP_HOME%;-Ddata.dir=%APP_DATA%;-Djava.util.logging.config.file=%APP_HOME%\logging.properties;-Djava.library.path=%HORNET_BIN%

       


      %APP_HOME%\tomcat6-x86.exe //IS//HornetProfile1 --Install=%APP_HOME%\tomcat6-x86.exe --Description="HornetQ Profile1 tc" --Jvm=auto --Classpath=%CLASSPATH% --JvmMs512M --JvmMx1024M --JvmOptions="%JVM_ARGS%" --StartMode=jvm --StartClass=org.hornetq.integration.bootstrap.HornetQBootstrapServer --StartParams=hornetq-beans.xml --LogPath=%APP_HOME% --StdOutput=auto --StdError=auto

       

           BUT: I when I startup the service I get this:

           ... javajni.c] [error] Static method 'void main(String[])' in Class org/hornetq/integration/bootstrap/HornetQBootstrapServer not found
      [2010-09-13 16:28:52] [996  prunsrv.c] [error] Failed loading main org/hornetq/integration/bootstrap/HornetQBootstrapServer class  ...

           ... prunsrv.c] [error] Failed loading main org/hornetq/integration/bootstrap/HornetQBootstrapServer ...

       

      I have 2 question:

      1. What is the entry point I should use in this script for Hornet (tomcat looks for main)?

      2. Is there a better way to install multiple instances (or even 1 instance) of stand-alone non-clustered HornetQ as a windows service?

        • 1. Re: Running HornetQ as a windows service
          timfox

          I don't see why you need a main() method to see the JMX console.

           

          You just need to specify the host and port and connect to it on that. This is explained in the JMX documentation (not specific to HornetQ)

          • 2. Re: Running HornetQ as a windows service
            hughbragg

            I don't want to connect remotly. I just want to connect locally. This is a known Java/windows problem. It works fine if I run it from a cmd console, but if it's been initialised as a service, even running as that user or administrator, jconsole is unable to see the stack at all. not even jvisualvm can see the stack. They can see the process, but nothing else.

             

            I just want to know if anyone else has managed to get this going and how that works.

            • 3. Re: Running HornetQ as a windows service
              jaikiran

              Hugh Bragg wrote:

               

              This is a known Java/windows problem. It works fine if I run it from a cmd console, but if it's been initialised as a service, even running as that user or administrator, jconsole is unable to see the stack at all. not even jvisualvm can see the stack. They can see the process, but nothing else.

               

              Which exact approach did you use to run it as a service? And what exactly is the "known" Java/Windows problem - any links that you can point us to?

              • 4. Re: Running HornetQ as a windows service
                hughbragg

                I don't have much:

                This is by Thomas Hurka at Sun last year:

                quote:

                This is caused by native launcher. Native launchers often look up main   class using JNI FindClass() function and invoke main method using   CallStaticIntMethod(). With this approach VisualVM has no way to know   which is application main class. JVM arguments are passes to   JNI_CreateJavaVM function and therefor we can access and display them   is overview tab.

                 

                http://markmail.org/message/xe3btk7kxztdeqjk#query:VisualVM%20%22unknown%20application%22%20%22windows%20service%22+page:1+mid:xe3btk7kxztdeqjk+state:results

                 

                This problem is simple to reproduce and is always repeatable. I have some process that runs hornet as a service. It does the same for the producer/consumer and they all show the same problem. jconsole/jvisualvm cannot access any information about the process. jvisualvm says "unknown application" and jconsole says jmx isn't running, but I can access it throught the remote process connection.

                 

                I'll try to repeat this with the tomcat service installer and then the jboss one. As soon as I know anything else I'll post something else. For now I'm stuck accessing it remotly since I proposed we run hornet stand-alone and as a service. I wish I could use Linux, but that's not an option here sadly. I'm beginning to wish we went down the JBoss as road instead.

                • 5. Re: Running HornetQ as a windows service
                  jaikiran

                  Hugh Bragg wrote:

                   

                  I'm beginning to wish we went down the JBoss as road instead.

                  There's no point using JBoss AS if you are not going to use it for anything other than HornetQ.

                  • 6. Re: Running HornetQ as a windows service
                    timfox

                    HornetQ standalone process is just a simple script (batch file in Windows).

                     

                    To run a batch file you don't need to know a main class.

                     

                    If windows can run a batch file as a windows service then it should run HornetQ fine.

                     

                    I'm not a Windows expert but some simple googling shows this to be possible.

                    • 7. Re: Running HornetQ as a windows service
                      timfox

                      And as Jaikaran has pointed out, if you can't run HornetQ standalone as a service you won't have any luck with JBoss AS either - it's a batch file too. In fact you won't have any luck with any batch file.

                      • 8. Re: Running HornetQ as a windows service
                        hughbragg

                        @Jaikaran: I totally agree. That's why I went down this road originally.

                         

                        @Tim: I haven't said that it won't run. Only that when it does run, jconsole and jps both report that the process is inaccessible and jvisualvm won't run at all. I'd much rather run them on Linux, but the boss won't agree.

                         

                        I added to this bug on Sun:

                        http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6954420

                         

                        It's not a Hornet problem. I'm just asking if anyone has succeeded doing this before?

                        • 9. Re: Running HornetQ as a windows service
                          timfox

                          Ah, you're using Cygwin (I guess to run the scripts on Windows). Have you tried running the Windows batch files we provide directly?

                          • 10. Re: Running HornetQ as a windows service
                            david.taylor

                            There are quite a few Java service wrappers available that can run arbitrary Java classes as services. Here are a few links for reference:

                             

                            http://winrun4j.sourceforge.net

                            http://jslwin.sourceforge.net

                            http://commons.apache.org/daemon/procrun.html

                            http://wrapper.tanukisoftware.com/doc/english/download.jsp

                             

                            My recommendation normally would be the one from Tanuki Software, but they changed their license agreement and started charging foe their wrapper. If you can find the last free release before the license change, it is quite good and very stable based on real world usage.

                            1 of 1 people found this helpful
                            • 11. Re: Running HornetQ as a windows service
                              hughbragg

                              I don't use cygwin. I am using that batch file Hornet provides directly.

                              I will try some of the suggestions David provided. Thanks. I was already experimenting with procrun. Just haven't had time to finish yet.

                              I'll let you know the outcome.

                              • 12. Re: Running HornetQ as a windows service
                                hughbragg

                                I've tried Apache procrun.

                                Even though I have jboss-mc.jar in my classpath I get a classnotfoundexception for BasicKernelInitializer:

                                [Thread-1] 13:22:25,677 INFO [org.hornetq.integration.bootstrap.HornetQBootstrapServer]  Starting HornetQ Server

                                [Thread-1] 13:22:25,771 SEVERE [org.hornetq.integration.bootstrap.HornetQBootstrapServer]  Failed to start server

                                java.lang.RuntimeException: Unable to create a KernelInitializer based on the specified KernelConfig

                                    at org.jboss.kernel.KernelFactory.createKernelInitializer(KernelFactory.java:156)

                                    at org.jboss.kernel.KernelFactory.assembleNewKernel(KernelFactory.java:99)

                                    at org.jboss.kernel.KernelFactory.newInstance(KernelFactory.java:67)

                                    at org.jboss.kernel.plugins.bootstrap.AbstractBootstrap.bootstrap(AbstractBootstrap.java:114)

                                    at org.hornetq.integration.bootstrap.HornetQBootstrapServer.bootstrap(HornetQBootstrapServer.java:149)

                                    at org.jboss.kernel.plugins.bootstrap.AbstractBootstrap.run(AbstractBootstrap.java:83)

                                    at org.hornetq.integration.bootstrap.HornetQBootstrapServer.run(HornetQBootstrapServer.java:116)

                                    at org.hornetq.integration.bootstrap.HornetQBootstrapServer.main(HornetQBootstrapServer.java:73)

                                Caused by: java.lang.ClassNotFoundException: org/jboss/kernel/plugins/bootstrap/basic/BasicKernelInitializer

                                    at java.lang.Class.forName0(Native Method)

                                    at java.lang.Class.forName(Class.java:247)

                                     at  org.jboss.reflect.plugins.introspection.IntrospectionTypeInfoFactoryImpl.resolveComplexTypeInfo(IntrospectionTypeInfoFactoryImpl.java:419)

                                     at  org.jboss.reflect.plugins.introspection.IntrospectionTypeInfoFactoryImpl.getTypeInfo(IntrospectionTypeInfoFactoryImpl.java:388)

                                    at org.jboss.reflect.plugins.introspection.IntrospectionTypeInfoFactory.getTypeInfo(IntrospectionTypeInfoFactory.java:54)

                                    at org.jboss.classadapter.plugins.BasicClassAdapterFactory.getClassAdapter(BasicClassAdapterFactory.java:61)

                                    at org.jboss.config.plugins.AbstractConfiguration.getBeanInfo(AbstractConfiguration.java:68)

                                    at org.jboss.kernel.plugins.config.AbstractKernelConfig.getBeanInfo(AbstractKernelConfig.java:65)

                                    at org.jboss.kernel.plugins.config.property.PropertyKernelConfig.getImplementation(PropertyKernelConfig.java:175)

                                    at org.jboss.kernel.plugins.config.property.PropertyKernelConfig.createKernelInitializer(PropertyKernelConfig.java:120)

                                    at org.jboss.kernel.KernelFactory.createKernelInitializer(KernelFactory.java:150)

                                    ... 7 more

                                 

                                Perhaps it can't use jvm.dll?

                                 

                                Well, I'd  like to try the one from Tanuki Software David, but I wouldn't know  where to get the last free release before the license change. Any ideas?

                                 

                                I'll keep trying...

                                • 13. Re: Running HornetQ as a windows service
                                  timfox

                                  Check your classpath, it can't find the classes it needs. You'll need the exact same classpath from the batch file

                                  • 14. Re: Running HornetQ as a windows service
                                    hughbragg

                                    "C:\Apps\HornetQ\Wilsons\Taten\tomcat6.exe" //IS//HornetWT --Environment "HORNET_HOME=C:\Apps\HornetQ\hornetq-2.1.2.Final" --Classpath "C:\Apps\HornetQ\Wilsons\Taten;C:\Apps\HornetQ\hornetq-2.1.2.Final\schemas\;C:\Apps\HornetQ\hornetq-2.1.2.Final\lib\hornetq-bootstrap.jar;C:\Apps\HornetQ\hornetq-2.1.2.Final\lib\hornetq-core-client-java5.jar;C:\Apps\HornetQ\hornetq-2.1.2.Final\lib\hornetq-core-client.jar;C:\Apps\HornetQ\hornetq-2.1.2.Final\lib\hornetq-core.jar;C:\Apps\HornetQ\hornetq-2.1.2.Final\lib\hornetq-jboss-as-integration.jar;C:\Apps\HornetQ\hornetq-2.1.2.Final\lib\hornetq-jms-client-java5.jar;C:\Apps\HornetQ\hornetq-2.1.2.Final\lib\hornetq-jms-client.jar;C:\Apps\HornetQ\hornetq-2.1.2.Final\lib\hornetq
                                    -jms.jar;C:\Apps\HornetQ\hornetq-2.1.2.Final\lib\hornetq-logging.jar;C:\Apps\HornetQ\hornetq-2.1.2.Final\lib\hornetq-twitter-integration.jar;C:\Apps\HornetQ\hornetq-2.1.2.Final\lib\jboss-jms-api.jar;C:\Apps\HornetQ\hornetq-2.1.2.Final\lib\jboss-mc.jar;C:\Apps\HornetQ\hornetq-2.1.2.Final\lib\jnp-client.jar;C:\Apps\HornetQ\hornetq-2.1.2.Final\lib\jnpserver.jar;C:\Apps\HornetQ\hornetq-2.1.2.Final\lib\netty.jar;C:\Apps\HornetQ\hornetq-2.1.2.Final\lib\twitter4j-core.jar" ++JvmOptions "-XX:+UseParallelGC;-XX:+AggressiveOpts;-XX:+UseFastAccessorMethods;-Dhornetq.config.dir=C:\Apps\HornetQ\Wilsons\Taten;-Ddata.dir=C:\Apps\HornetQ\Wilsons\Taten\data;-Djava.util.logging.config.file=C:\Apps\HornetQ\Wilsons\Taten\logging.p
                                    roperties;-Djava.library.path=C:\Apps\HornetQ\hornetq-2.1.2.Final\bin" --StartPath "C:\Apps\HornetQ\hornetq-2.1.2.Final\bin" --StartMode jvm --StartClass org.hornetq.integration.bootstrap.HornetQBootstrapServer --StartParams hornetq-beans.xml --StdOutput auto --StdError auto

                                     

                                    This is the command which is passed to tomcat. As you can see, the entire classpath is in there just like the batch script that comes with Hornet. Actually, I borrowed the part which assembles the classpath from there.

                                     

                                    I tried this with the PR_ variables as well and every combination of quotes on --ClassPath.

                                     

                                    I was a bit dumbfounded since I was expecting it to work and I have no idea what else could be wrong. I might try culling JvmOptions tomorrow.

                                    1 2 Previous Next