raja
raja

Reputation: 4193

Doubt in Java Service wrapper while running jar application fom window service

I have a jar application which process and converts file into csv file. I have made it to run in windows service using Java Service Wrapper. It got installed my jar application successfully when I run "InstallApp-NT. Bat" file and starts running my application when I run "app" command.

But when I try to start the service in services, its not starting and showing following message in dialog box<

Windows could not start the generic Preprocessor application on Local Computer. For more information, review the System Event Log. If this is a non-microsoft service, contact the service vendor, and refer to service-specific error code1
I have the system log file and it showing the below error message
System Event log: 
--> Wrapper Started as Service
Java Service Wrapper Community Edition 3.3.2
Copyright (C) 1999-2009 Tanuki Software, Ltd. All Rights Reserved. 
http://wrapper.tanukisoftware.org
Launching a JVM... 
WrapperManager: Initializing... 
WrapperSimpleApp: 
WrapperSimpleApp: Encountered an error running main: 
WrapperSimpleApp: java. Lang. NullPointerException
WrapperSimpleApp: at java. Util. Hashtable. Put(Hashtable. Java: 396)
WrapperSimpleApp: at java. Util. Properties. SetProperty(Properties. Java: 128)
WrapperSimpleApp: at java. Lang. System. SetProperty(System. Java: 701)
WrapperSimpleApp: at com. Dnb. Genericpreprocessor. Process. ProcessRunner. Main(Unknown Source)
WrapperSimpleApp: at sun. Reflect. NativeMethodAccessorImpl. Invoke0(Native Method)
WrapperSimpleApp: at sun. Reflect. NativeMethodAccessorImpl. Invoke(NativeMethodAccessorImpl. Java: 39)
WrapperSimpleApp: at sun. Reflect. DelegatingMethodAccessorImpl. Invoke(DelegatingMethodAccessorImpl. Java: 25)          
WrapperSimpleApp: at java. Lang. Reflect. Method. Invoke(Method. Java: 585)
WrapperSimpleApp: at org. Tanukisoftware. Wrapper. WrapperSimpleApp. Run(WrapperSimpleApp. Java: 238)
WrapperSimpleApp: at java. Lang. Thread. Run(Thread. Java: 595)
<-- Wrapper Stopped

I don't think any error in application code because it running fine when run "app" command. Please help what I should now. Thanks in advance.


I am using the following code in com.dnb.genericpreprocessor.process.ProcessRunner class.

String projectHome = "D:\BL";
System.setProperty("project.home", projectHome);
System.setProperty("log.home",System.getenv("DBE")); ---> DBE is the envirinment variable I created in user variables.

When I run the application by giving app command... Its running the application by printing the environment value but showing the same error when I start it in service.

Upvotes: 0

Views: 2297

Answers (5)

imxylz
imxylz

Reputation: 7937

Maybe you should put your 'DBE' enviroment in the system variables not user variables. Windows service starts at system account.

Upvotes: 0

Eddie
Eddie

Reputation: 54421

Answering your question update that you phrased as an answer, you need to ensure that the variable is in fact set in the specific environment where you are running the application. It appears that it is not. In fact, to avoid the NullPointerException, I would modify your code to something like:

String loghome = System.getenv("DBE");
if (loghome == null) {
  // LOG A COMPLAINT that the environment variable is not set
  loghome = "some reasonable default value";
}
System.setProperty("log.home", loghome);

so at least your application won't fail with an obtuse NPE if it is executed in the wrong environment.

Upvotes: 1

Yuval Adam
Yuval Adam

Reputation: 165242

I am not familiar with the proprietary solution you are using, but it seems you somehow configured it wrong.

Looks like some parameter the wrapper should have is null and is propagating all the way up until the system is trying to set it as property.

Upvotes: 0

Rob Grant
Rob Grant

Reputation: 7348

Check your wrapper.config; you need to have all the necessary jars in order, and each with their own index number (for some reason):

wrapper.java.classpath.1=../lib/wrapper.jar

wrapper.java.classpath.2=%JAVA_HOME%/lib/tools.jar

...

Just a first thought.

Upvotes: 0

Bhushan Bhangale
Bhushan Bhangale

Reputation: 10987

Check com.dnb.genericpreprocessor.process.ProcessRunner if that is your code and see what data you are setting in System property. NullPointer is telling that the key or the value you passed is Null.

Upvotes: 0

Related Questions