Tags

,

Today, I am debugging the batch script that wraps the embedded jetty+solr application as windows service. The script looks like:
Windows BAT: Using Apache Procrun to Install Java Application As Windows Service

Then I run installService.bat -service_name service1 -start_params “start;-port;9753” -stop_params shutdown, it installs the service successfully. But when I click service1.exe and try to start the service, it fails silently. No any (error) message logged in commons-daemon.log or service1.stderr/stdout.log. But when I run prunsrv //TS//service1 to debug the service, it runs well.

Looks weird.
View Procrun Error Message in Event Viewer
To view the error log, we have to view Windows Event Log: Go to Control Panel, and search Event Viewer, open it. Select “Windows Log” -> “System”, reproduce the problem by starting the service in service1 service GUI, we can see one new error log:
The service1 service failed to start due to the following error: 
The system cannot find the file specified.

//<![CDATA[
if(showAdsense){
document.write("(adsbygoogle = window.adsbygoogle || []).push({});”)
} else {
if (window.CHITIKA === undefined) {
window.CHITIKA = { ‘units’ : [] };
};
var unit = {
‘publisher’ : “jefferyyuan”,
‘width’ : 728,
‘height’ : 90,
‘type’ : “mpu”,
‘sid’ : “Chitika Default”,
‘color_site_link’ : “FFFFFF”,
‘color_title’ : “FFFFFF”,
‘color_border’ : “FFFFFF”,
‘color_text’ : “4E2800”,
‘color_bg’ : “F7873D”
};
var placement_id = window.CHITIKA.units.length;
window.CHITIKA.units.push(unit);
document.write(“

“);
var s = document.createElement(‘script’);
s.type = ‘text/javascript’;
s.src = ‘http://scripts.chitika.net/getads.js&#8217;;
try {
document.getElementsByTagName(‘head’)[0].appendChild(s);
} catch(e) {
document.write(s.outerHTML);
}
}
//]]>

Root Cause of The system cannot find the file specified
Google search “The system cannot find the file specified”. Find post Build windows service from java application with procrun:
If you use (correct) relative paths to files(especially for prunmgr.exe) in the installation script, the service will install correctly and it will run fine in debugging mode. It will however fail when run normally with any administrative tooling you have.
Generally, you should use absolute paths with procrun.

Check the service1 GUI, in general tab. it indeed uses prunsrv //RS//service1.
Check the script, I use:
“%PRUNSRV%” //IS//%SERVICE_JAVA% –Install=”%MYPATH%prunsrv”
But I somehow I removed the definition of MYPATH in the script. Update the script:
set “PRUNSRV=%%~dp0/%prunsrv.exe”
“%PRUNSRV%” //IS//%SERVICE_JAVA% –Install=”%PRUNSRV%”
Now it works.
Lesson Learned
Use absolute path in installation script.
Use System Event Log to view prunsrv error message.

Resources
Build windows service from java application with procrun
https://github.com/lenhard/procrun-sample
Windows BAT: Using Apache Procrun to Install Java Application As Windows Service
http://commons.apache.org/proper/commons-daemon/procrun.html

via Blogger http://lifelongprogrammer.blogspot.com/2013/11/trouble-shooting-procrun-unable-start-service-problem.html

Advertisements