0 Replies Latest reply on Apr 28, 2002 7:49 AM by lionelsiau

    New NT Service HOWTO : Simplest One Yet

    lionelsiau

      I spent most of my Sunday doing this. I know of the javants.exe in the /contrib but that infernal thing has almost no documentation (some separate hyperlink) and bombs mysteriously.

      Instead, I got fed up and tried alternatives. Several in the FAQ for jboss but all 'convoluted' for just a simple developer like me who doesn't have a C++ compiler. Then I found this : JSL by Michael R

      http://www.roeschter.com/index.html

      I got it working in 1 hrs after tinkering only. It doesn't address jboss specifically but it was so simple, I easily adapted. My jsl.ini file is reproduced below. It isn't production quality but if u're using jboss, u're got enough IQ for it..;)


      [service]
      appname = jboss
      servicename = jboss
      displayname = jboss

      ;port used to communicate stop command to JVM
      ;Must be unique for each JSL instance installed
      ;Used 8466 for jboss
      stopport = 8466

      ;service dependencies can be added
      ;as a comma separated string "dep1,dep2"
      ;dependencies=TinyHttp

      ;service start type
      ;auto demand disabled
      ;default is auto
      starttype=auto

      ;load ordering group
      loadordergroup=someorder

      ;account under which service runs
      ;default is system
      ;account=.\administrator

      ;password for above account
      ;system need not provide a password
      ;password=somewpd

      ;Allocate a console and register a console event handler to catch shutdown events.
      ;Default is true; options are FALSE TRUE false true YES NO yes no
      ;This option has two effects:
      ;1. If active it catches the logoff events and prevents the service from erroneously stopping in this case.
      ;2. It creates a console window if interaction with the desktop is allowd.
      ;Effect 1 can be achieved in Java 1.3.1 and higher by using the -Xrs option.
      ;Effect 2 may or may not be desired.
      useconsolehandler=false

      ;Call . through JNI so stop the JVM.
      ;This can be used an alternative to the ServiceStopper
      ;When all three parameters are defined the JSL will try to use JNI to stop the service.
      ;If not it will use a tcp/ip connection to the stopport.
      ;The simplest way to use this functionality is to use the Systen.exit() call as specified below.
      ;Nevertheless you can call any static method in your code.
      ;The method called is expected to terminate the JVM one way or the other. It can directly
      ;call System.exit() or make another Thread do it make the main method return.
      ;The method can return imediately if desired. If the JVM doesn't stop another attempt can be made to
      ;stop the service at a later time.

      stopclass=java/lang/System
      stopmethod=exit

      ;Take care to specify the right signature for your method. void System.exit( int code ) has
      ;the sifnature specified below. void myMethod() has the signature ()V. Please refer to the
      ;JNI documentation for details.
      stopsignature=(I)V

      ;Value of the PATH environement variable being set by the service.
      ;PATH will remain unchanged if this is empty.
      ;path=c:\util

      ;Redirect stdout and stderr to the specified files
      ;Leave empty for no redirection
      ;stdout=e:\stdout.log
      ;stderr=e:\stderr.log

      ;Behaviour in case of JVM exiting with an error
      ;Define whether an execption in the main method should be considered an error
      ;Use this exit code in case of an exception.
      ;exceptionerrorcode=0

      ;Desired behaviour for a non zero exit code (including exceptions as specified above)
      ;Options:
      ;ignore terminate without error (default)
      ;returncode exit with error code reported by the JVM to to the service manager
      ;fatal don't report regular service stop to service manager making it believe
      ;a fatal error had occured in the service (this is sometimes desirable if fatal error
      ;recovery mechanisms are in place)
      ;onexiterror=fatal

      ;Use this executable for registering the service.
      ;Default is the executable used for installation
      ;modulepath=e:\java\test\jsl_0_9_9a\release\jsl.exe

      [java]
      ;Path to the java runtime used
      ;If this option is not used the default from the registry will be used
      ;jrepath=E:\java\jdk13

      ;working directory
      wrkdir=D:\JBoss-2.4.5_Tomcat-4.0.3\jboss\bin

      ;the number of paramters passed to the java application
      ;parameters must be numbered param00, param01 ...
      params = 6
      param00 = -Djavax.xml.parsers.DocumentBuilderFactory=org.apache.crimson.jaxp.DocumentBuilderFactoryImpl
      param01 = -Djavax.xml.parsers.SAXParserFactory=org.apache.crimson.jaxp.SAXParserFactoryImpl
      param02 = -cp
      param03 = D:\JBoss-2.4.5_Tomcat-4.0.3\jboss\bin;D:\jdk\jdk1.3.1_03\lib\tools.jar;run.jar;D:\JBoss-2.4.5_Tomcat-4.0.3\jboss\lib\crimson.jar
      param04 = org.jboss.Main
      param05 = catalina