jsrvany logo
t r o u b l e s h o o t i n g
 
The latest (1.0 alpha 2) release of jsrvany adds two new debugging modes:
  • A command-line executable that can read your service's registry entries and execute the service in the same way that jsrvany running as a service would. This allows you to see any error messages that are normally written to stdout or stderr and consequently hidden when invoked as a service.
To run jsrvany in this mode, ensure first that the service is stopped, then from a command-line prompt enter the following:
  cd <jsrvany-dir>/bin
  jsrvany_debug <servicename>

where <jsrvany-dir> is the directory in which you installed jsrvany and <servicename> is the name of the service which you are trying to debug.

Error messages produced by your application should now be visible in the console and should help you to debug the service configuration. Experience has shown that this is the best way to debug classpath and other configuration issues that may otherwise be hidden when invoked as a service.

  • The second debugging mode consists of a network-based service that runs as a service under jsrvany and listens for connections on a predefined port (23, the telnet port by default). This allows you to connect to the service across a socket connection (simple telnet is enough) and interactively query jsrvany's configuration. In addition, you can invoke the application, with stderr echoed down the socket to your terminal window, allowing you to debug your setup. You can also interactively trigger a ServiceControlEvent, and observe the system's behaviour.
To run jsrvany in this mode, either install it with the -g argument to instsrv, or add the following value to your service's registry key: debugPort 23. If you already have something running on port 23, you can simply choose another port number.

Stop and then start your service

Then connect to jsrvany using telnet or something equivalent:
  telnet 127.0.0.1 23
You should see a menu presented as follows:

		Connection from: Socket[addr=localhost/127.0.0.1,port=1122,localport=23]

		####################################
		Select one of the following options:
		  1.  show the JVMOptions
		  2.  show the arguments to the main class
		  3.  run the main class
		  4.  quit
		  5.  trigger a ServiceControlEvent
		  6.  show the listeners registered with the ServiceControlManager
		  7.  add this class to the ServiceControlManager
		  8.  remove this class from the ServiceControlManager
		####################################
		

Select one of the menu items by entering the corresponding number and entering return.

Item 1 displays all the java properties that the JVM is invoked with.
Item 3 allows you to invoke the main class as specified in the className registry key. Anything written to stderr or stdout will be redirected to the console.
Item 6 will query the ServiceControlManager and iterate through the listeners registered to be notified about ServiceControlEvents, your application class should be listed among them.
Items 7 and 8 allow you to register/deregister this application itself (it is called net.sourceforge.jsrvany.debug.Debugger) with the ServiceControlManager. Note that Debugger is an example of a ServiceControlListener class but is not registered with the ServiceControlManager by default. When it is, by selecting item 7, it will respond correctly to ServiceControlEvents.

When you have debugged your configuration, revert your setup to operate normally by removing the debugPort registry value.