aspose file tools*
The moose likes Java in General and the fly likes Windows Service for Java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Windows Service for Java" Watch "Windows Service for Java" New topic
Author

Windows Service for Java

paramu iyer
Greenhorn

Joined: May 13, 2006
Posts: 24
Hi,

I have a java application and I have to make a windows service for that.
My application is getting registered as a Windows Service but the problem is that it is not getting started.
The following error is reported : The service started and then stopped.Some service stop automatically if they have no work to do.
please suggest the reasons for the same.

Thanks,
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

I'm assuming you used one of the open source service wrappers? The ones I know (such as Java Service and the Java Service wrapper by tanuki software) are configurable to log what they are doing. You could start by looking there.
[ October 30, 2006: Message edited by: Paul Sturrock ]

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
paramu iyer
Greenhorn

Joined: May 13, 2006
Posts: 24
I have used them only , it is getting registered ie When I open the services window , I can find my app but when I try to start that it is getting the error that I posted before
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336


I have used them only

Which one? Or have you tried both?


it is getting registered ie When I open the services window , I can find my app but when I try to start that it is getting the error that I posted before

Like I said service wrappers typically include logging. Read the logs to see what they are doing.

Don't pay much attention to the message you get back from Windows. Windows Services are pretty dumb things - and won't tell you much themselves. They delegate to which ever process they manage to log what its up to.
paramu iyer
Greenhorn

Joined: May 13, 2006
Posts: 24
yes , I have tried with both the S/W's ( Tanuki and Object Web).

Both are giving out the same message.

In the event viwer for the windows service I am getting out the following error message : "The LoadLibrary function failed for the following reason: The specified module could not be found."
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14276
    
  21

Is there a native library (a DLL) included in those software packages? If yes, then you have to make sure that Windows can find the DLL while running your Java program as a service. You need to add the directory that contains the DLL to the PATH, or even put the DLL in the WINDOWS or WINDOWS\SYSTEM32 directory.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
paramu iyer
Greenhorn

Joined: May 13, 2006
Posts: 24
I tried that now(put the folder containing the dll's in the PATH and also included the dll in the Windows/System32 folder) but the error message is the same.
Ulas Ergin
Ranch Hand

Joined: Oct 10, 2002
Posts: 77
I used JSL - Java Service Launcher with no problems.
you may give it a try.
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336


In the event viwer for the windows service I am getting out the following error message : "The LoadLibrary function failed for the following reason: The specified module could not be found."

What Jasper writes is worth checking. Also both those service wrappers will ultimately call an executable - either the service wrapper executable itself or java.exe directly depending on which implementation you are using. For both I think you get a key called ImagePath which is the path to the executable that is being run. Check in your registry (HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services/<your_service_name> ) see what it says and make sure it is correct. Remember that any changes you make through the registry to a service will require you reboot Windows to take effect.
[ November 01, 2006: Message edited by: Paul Sturrock ]
paramu iyer
Greenhorn

Joined: May 13, 2006
Posts: 24
Hi Ulas,
Is it true that Java Service Launcher can be used only with Windows NT-4,Windows 2000 and Windows 2003.

I am using a Windows XP.
paramu iyer
Greenhorn

Joined: May 13, 2006
Posts: 24
quote
--------------------------------------------------------------------------
>>> For both I think you get a key called ImagePath which is the path to the executable that is being run. Check in your registry (HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services/<your_service_name> ) see what it says and make sure it is correct.
-------------------------------------------------------------------------

I have checked in the ImagePath and both of them seem to point to the right .exe files....
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Hmm. Well the service itself sounds like it can't find the executable. Unfortunately services are very difficult to debug. Cut and paste the value for the ImagePath into a command prompt - see if you can run the application that way. You should be able to run the process the service is managing directly. If you can't hopefully the process itself will give you a clue as to why not.
paramu iyer
Greenhorn

Joined: May 13, 2006
Posts: 24
Hi Ulas Ergin ,

You said you have tried out with Java Service Launcher(JSL). I tried that. The service is getting started but my application is not getting started.

I have a jar file (my application) and also many other jars on which this depends.In this case how should I set the Class path in the .ini file that comes along with the S/W
paramu iyer
Greenhorn

Joined: May 13, 2006
Posts: 24
Thanks Paul ......,

Your clues helped a lot. The problem was basically that the parameters in the registry were not getting set properly.They were jumbled.I corrected them in the registry it self and it is working.

I need to integrate it with a Java Installer like IzPack.. Please provide some tips or clues if any body has worked on that.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Windows Service for Java