• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Windows Service for Java

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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,
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
paramu iyer
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


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
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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."
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
paramu iyer
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I used JSL - Java Service Launcher with no problems.
you may give it a try.
 
Paul Sturrock
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


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
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
So it takes a day for light to pass through this glass? So this was yesterday's tiny ad?
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic