You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Konstantin Kolinko <kn...@gmail.com> on 2011/01/16 14:27:56 UTC

Re: [DAEMON] procrun - java Property File

2011/1/16 Andreas Mielke <an...@googlemail.com>:
> I use Apache Common Daemon to install a java application as a windows service. The problem is i have a java properties file to setup few parameters and i don't know how to describe the location of the property file in the command line. My installation of the service is like
>
> prunsrv //IS//TestService --DisplayName="Test Service" --Install=prunsrv.exe --Jvm=auto --StartMode=jvm --StopMode=jvm --StartClass=org.apache.SomeStartClass.
>

If you want to pass it as a system property, use "JvmOptions" [1] to
specify -D.

Is it what you are asking? If you were running your app with
java(w).exe, what would be your command line?

[1] http://commons.apache.org/daemon/procrun.html

Best regards,
Konstantin Kolinko

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


RE: [DAEMON] procrun - java Property File

Posted by Adam Mlodzinski <Ad...@quest.com>.
> From: Andreas Mielke [mailto:andreasmielke@googlemail.com]
> > My problem is to tell the Apache Common Daemon where is my property file.

No, this is not your problem. The Commons Daemon does not care about your property file. The Java program that the Commons Daemon will run *does* care. 

> I don't posted the --Classpath, sorry. The complete command is:
> 
> prunsrv //IS --Description="DMSImport" --DisplayName="startImport"
> --Startup=auto --Type=interactiv --Install=java.exe --Jvm=auto
> --StartMode=Java --StopMode=Java --StartClass=dmswrapper.DMSImporter
> --Classpath=%CLASSPATH%;C:\Programme\DMS_ImageBrowser\DMSWrapper-binary-
> 1.2\DMSWrapper.jar;C:\Programme\DMS_ImageBrowser\DMSWrapper-binary-1.2\log4j-
> 1.2.15.jar;C:\Programme\DMS_ImageBrowser\DMSWrapper-binary-1.2\log4j-
> extensions.jar;C:\Programme\DMS_ImageBrowser\DMSWrapper-binary-1.2\commons-codec-
> 1.3.jar;C:\Programme\DMS_ImageBrowser\DMSWrapper-binary-1.2\commons-httpclient-
> 3.1.jar;C:\Programme\DMS_ImageBrowser\DMSWrapper-binary-1.2\commons-logging-
> 1.1.1.jar;C:\Programme\DMS_ImageBrowser\DMSWrapper-binary-1.2\commons-net-
> 2.0.jar;C:\Programme\DMS_ImageBrowser\DMSWrapper-binary-1.2\EloixClient.jar;
> ++JvmOptions
> -D=C:\Programme\DMS_ImageBrowser\DMSWrapper-binary-1.2\DMSWrapper.properties;
> --LogPath="C:\Programme\commons-daemon-1.0.5-bin-windows\logs"
> --LogLevel=Debug --StdOutput=auto --ServiceUser=********
> --ServicePassword=*******(private ;-) )
> 
> 
> 
> This is the foreign program, I know the principal functions but no lines of
> code.

This is not a problem either. If you do not know how to run a Java program in general, that could be a problem.

> > How is that application run when you do not use your wrapper?
> 
> yes. A CMD- File with the command java -cp ... .


Ahh - here is your answer. You must translate every option of the 'java -cp ...' which is produced by the CMD-File into options that the Commons Daemon installer understands.
Try adding an "echo on" just before the 'java -cp ...' command inside the CMD-File. When you run it, you will see the entire java command that is launched, along with every option that you must translate.
You will also need to add some new information to describe the service itself - the service name, description, log files, service user, etc. But, focus on the Java-specific pieces first.


For example, here is a result of putting an 'echo on' inside catalina.bat (for Tomcat 5.5.31):

Mon 19:17:06>"c:\jdk1.6.0_12\bin\java"  -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.util.logging.config.file="C:\work\appservers\tomcat\5.5\apache-tomcat-5.5.31\conf\logging.properties"   -Djava.endorsed.dirs="C:\work\appservers\tomcat\5.5\apache-tomcat-5.5.31\common\endorsed" -classpath "C:\work\appservers\tomcat\5.5\apache-tomcat-5.5.31\bin\bootstrap.jar" -Dcatalina.base="C:\work\appservers\tomcat\5.5\apache-tomcat-5.5.31" -Dcatalina.home="C:\work\appservers\tomcat\5.5\apache-tomcat-5.5.31" -Djava.io.tmpdir="C:\work\appservers\tomcat\5.5\apache-tomcat-5.5.31\temp" org.apache.catalina.startup.Bootstrap  start

To make this command run as a Windows Service started by Apache Commons Daemon, you could use the following command to install it (to use prunsrv.exe + jvm.dll):


prunsrv //IS ^
--Jvm=c:\jdk1.6.0_12\jre\bin\server.jvm.dll ^
++JvmOptions=-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager ^
++JvmOptions=-Djava.util.logging.config.file="C:\work\appservers\tomcat\5.5\apache-tomcat-5.5.31\conf\logging.properties"^
++JvmOptions=-Djava.endorsed.dirs="C:\work\appservers\tomcat\5.5\apache-tomcat-5.5.31\common\endorsed" ^
--Classpath="C:\work\appservers\tomcat\5.5\apache-tomcat-5.5.31\bin\bootstrap.jar" ^
++JvmOptions=-Dcatalina.base="C:\work\appservers\tomcat\5.5\apache-tomcat-5.5.31" ^
++JvmOptions=-Dcatalina.home="C:\work\appservers\tomcat\5.5\apache-tomcat-5.5.31" ^
++JvmOptions=-Djava.io.tmpdir="C:\work\appservers\tomcat\5.5\apache-tomcat-5.5.31\temp" ^
--StartMode=jvm ^
--StartClass=org.apache.catalina.startup.Bootstrap ^
++StartParams start


Next, add options for logging and for stopping the service.


To be more precise (ie - use the JDKs 'default' jvm, as the original command does), you would want to use a start mode of Java:

prunsrv //IS ^
--JavaHome=c:\jdk1.6.0_12 ^
--StartMode=Java ^

That would launch c:\jdk1.6.0_12\bin\java.exe as a separate process.

Hopefully this helps.


--
Adam M.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Re: [DAEMON] procrun - java Property File

Posted by Andreas Mielke <an...@googlemail.com>.
2011/1/17 Konstantin Kolinko <kn...@gmail.com>

> 2011/1/17 Andreas Mielke <an...@googlemail.com>:
> > Hello JP,
> >
> > I look at the files and the loading of the properties files is like me.
> My
> > problem is to tell the Apache Common Daemon where is my property file.
> >
> > @ Konstantin I try the JvmOption like prunsrv //IS
> --Description="DMSImport"
> > --DisplayName="startImport" --Startup=auto --Type=interactiv
> > --Install=java.exe --Jvm=auto --StartMode=Java --StopMode=Java
> ++JvmOptions
>
> You are not specifying "--Classpath". How java is supposed to find your
> program?
>

I don't posted the --Classpath, sorry. The complete command is:

prunsrv //IS --Description="DMSImport" --DisplayName="startImport"
--Startup=auto --Type=interactiv --Install=java.exe --Jvm=auto
--StartMode=Java --StopMode=Java --StartClass=dmswrapper.DMSImporter
--Classpath=%CLASSPATH%;C:\Programme\DMS_ImageBrowser\DMSWrapper-binary-1.2\DMSWrapper.jar;C:\Programme\DMS_ImageBrowser\DMSWrapper-binary-1.2\log4j-1.2.15.jar;C:\Programme\DMS_ImageBrowser\DMSWrapper-binary-1.2\log4j-extensions.jar;C:\Programme\DMS_ImageBrowser\DMSWrapper-binary-1.2\commons-codec-1.3.jar;C:\Programme\DMS_ImageBrowser\DMSWrapper-binary-1.2\commons-httpclient-3.1.jar;C:\Programme\DMS_ImageBrowser\DMSWrapper-binary-1.2\commons-logging-1.1.1.jar;C:\Programme\DMS_ImageBrowser\DMSWrapper-binary-1.2\commons-net-2.0.jar;C:\Programme\DMS_ImageBrowser\DMSWrapper-binary-1.2\EloixClient.jar;
++JvmOptions
-D=C:\Programme\DMS_ImageBrowser\DMSWrapper-binary-1.2\DMSWrapper.properties;
--LogPath="C:\Programme\commons-daemon-1.0.5-bin-windows\logs"
--LogLevel=Debug --StdOutput=auto --ServiceUser=********
--ServicePassword=*******(private ;-) )


>
> > -D=C:\Programme\DMS_ImageBrowser\DMSWrapper-binary-1.2\log4j.properties;
> >
> -D=C:\Programme\DMS_ImageBrowser\DMSWrapper-binary-1.2\DMSWrapper.properties;
> >
> >
> > But I have a FileNotFoundException.
> >
> > Of Course I try ++JvmOptions
> >
> -D="C:\Programme\DMS_ImageBrowser\DMSWrapper-binary-1.2\log4j.properties;C:\Programme\DMS_ImageBrowser\DMSWrapper-binary-1.2\DMSWrapper.properties;"
>
> That quotes would be
>
> --JvmOptions
> "-D=C:\Programme\DMS_ImageBrowser\DMSWrapper-binary-1.2\log4j.properties#-D=C:\Programme\DMS_ImageBrowser\DMSWrapper-binary-1.2\DMSWrapper.properties"
>
> but anyway, your "-D" makes no sense: you are not specifying the name
> of a system property.
>
>
> > One point the Javaapplication is not writen by me.
>
> Is "DMSWrapper" your program, or it is a part of the "not writen by
> me" application?
>

This is the foreign program, I know the principal functions but no lines of
code.

>
> How is that application run when you do not use your wrapper?


I start a cmd-file (), one command line starts and the properties are load
automatical without problems.


> -- Does
> it load those properties files? How does it find them?   Ask the
> developers of the original app. That is why I already asked you:
>
> >> If you were running your app with java(w).exe, what would be your
> command line?
>

yes. A CMD- File with the command java -cp ... .

>
>
> The log4j.properties file is usually placed into a directory that is
> added to the ClassPath (and thus there is no need to specify its
> location explicitly).
>
>
> Best regards,
> Konstantin Kolinko
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>
>

Re: [DAEMON] procrun - java Property File

Posted by Konstantin Kolinko <kn...@gmail.com>.
2011/1/17 Andreas Mielke <an...@googlemail.com>:
> Hello JP,
>
> I look at the files and the loading of the properties files is like me. My
> problem is to tell the Apache Common Daemon where is my property file.
>
> @ Konstantin I try the JvmOption like prunsrv //IS --Description="DMSImport"
> --DisplayName="startImport" --Startup=auto --Type=interactiv
> --Install=java.exe --Jvm=auto --StartMode=Java --StopMode=Java ++JvmOptions

You are not specifying "--Classpath". How java is supposed to find your program?

> -D=C:\Programme\DMS_ImageBrowser\DMSWrapper-binary-1.2\log4j.properties;
> -D=C:\Programme\DMS_ImageBrowser\DMSWrapper-binary-1.2\DMSWrapper.properties;
>
>
> But I have a FileNotFoundException.
>
> Of Course I try ++JvmOptions
> -D="C:\Programme\DMS_ImageBrowser\DMSWrapper-binary-1.2\log4j.properties;C:\Programme\DMS_ImageBrowser\DMSWrapper-binary-1.2\DMSWrapper.properties;"

That quotes would be

--JvmOptions "-D=C:\Programme\DMS_ImageBrowser\DMSWrapper-binary-1.2\log4j.properties#-D=C:\Programme\DMS_ImageBrowser\DMSWrapper-binary-1.2\DMSWrapper.properties"

but anyway, your "-D" makes no sense: you are not specifying the name
of a system property.


> One point the Javaapplication is not writen by me.

Is "DMSWrapper" your program, or it is a part of the "not writen by
me" application?

How is that application run when you do not use your wrapper? -- Does
it load those properties files? How does it find them?   Ask the
developers of the original app. That is why I already asked you:

>> If you were running your app with java(w).exe, what would be your command line?


The log4j.properties file is usually placed into a directory that is
added to the ClassPath (and thus there is no need to specify its
location explicitly).


Best regards,
Konstantin Kolinko

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Re: [DAEMON] procrun - java Property File

Posted by Andreas Mielke <an...@googlemail.com>.
Hello JP,

I look at the files and the loading of the properties files is like me. My
problem is to tell the Apache Common Daemon where is my property file.

@ Konstantin I try the JvmOption like prunsrv //IS --Description="DMSImport"
--DisplayName="startImport" --Startup=auto --Type=interactiv
--Install=java.exe --Jvm=auto --StartMode=Java --StopMode=Java ++JvmOptions
-D=C:\Programme\DMS_ImageBrowser\DMSWrapper-binary-1.2\log4j.properties;
-D=C:\Programme\DMS_ImageBrowser\DMSWrapper-binary-1.2\DMSWrapper.properties;


But I have a FileNotFoundException.

Of Course I try ++JvmOptions
-D="C:\Programme\DMS_ImageBrowser\DMSWrapper-binary-1.2\log4j.properties;C:\Programme\DMS_ImageBrowser\DMSWrapper-binary-1.2\DMSWrapper.properties;"


But the in this case i have a ClassNotFoundException.

One point the Javaapplication is not writen by me. I have to run the program
only as awindows service.

I need a idea/Examples for the Problem.

Regards Andreas



2011/1/16 Juan Pablo Pizarro <ju...@gmail.com>

> Into the zip you will find two classes. This was my post:
>
> I attached two classes to get properties from a jar. You can modify its to
> get other kind of files (I did it).
> Finally, you can get content from the package and file into the jar.
>
> In the properties case, you can get a property with something like that:
>
> private static final String LDAP_CASA =
> PropertyReaderHelper.getProperty("PROVIDER_URL_CASA");
> private static final String CASA_CONTEXT_SEARCH_1 =
> PropertyReaderHelper.getProperty("CONTEXT_SEARCH_CASA_1");
> private static final String CASA_CONTEXT_SEARCH_2 =
> PropertyReaderHelper.getProperty("CONTEXT_SEARCH_CASA_2");
> private static final String CASA_PRINCIPAL =
> PropertyReaderHelper.getProperty("PRINCIAL_CASA");
> private static final String CASA_CREDENTIALS =
> PropertyReaderHelper.getProperty("CREDENTIALS_CASA");
>
> I hope it helps you.
>
> Regards,
>
> JP
>
>
>
>
> 2011/1/16 Andreas Mielke <an...@googlemail.com>
>
>> Hello JP,
>>
>> Please write me a example?
>>
>> Andreas
>>
>>
>>
>> Am 16.01.2011 um 20:37 schrieb Juan Pablo Pizarro <
>> juanpablo.pizarro@gmail.com>:
>>
>> > Andreas, you can use a resource bundle to obtain the .properties from
>> the
>> > jar.. i mean, you put the .properties into the file and you can read
>> from
>> > it.
>> >
>> > I posted some classes to do that some months ago.
>> >
>> > Regards.
>> >
>> > JP
>> >
>> > 2011/1/16 Konstantin Kolinko <kn...@gmail.com>
>> >
>> >> 2011/1/16 Andreas Mielke <an...@googlemail.com>:
>> >>> I use Apache Common Daemon to install a java application as a windows
>> >> service. The problem is i have a java properties file to setup few
>> >> parameters and i don't know how to describe the location of the
>> property
>> >> file in the command line. My installation of the service is like
>> >>>
>> >>> prunsrv //IS//TestService --DisplayName="Test Service"
>> >> --Install=prunsrv.exe --Jvm=auto --StartMode=jvm --StopMode=jvm
>> >> --StartClass=org.apache.SomeStartClass.
>> >>>
>> >>
>> >> If you want to pass it as a system property, use "JvmOptions" [1] to
>> >> specify -D.
>> >>
>> >> Is it what you are asking? If you were running your app with
>> >> java(w).exe, what would be your command line?
>> >>
>> >> [1] http://commons.apache.org/daemon/procrun.html
>> >>
>> >> Best regards,
>> >> Konstantin Kolinko
>> >>
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>> >> For additional commands, e-mail: user-help@commons.apache.org
>> >>
>> >>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>> For additional commands, e-mail: user-help@commons.apache.org
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>

Re: [DAEMON] procrun - java Property File

Posted by Juan Pablo Pizarro <ju...@gmail.com>.
Into the zip you will find two classes. This was my post:

I attached two classes to get properties from a jar. You can modify its to
get other kind of files (I did it).
Finally, you can get content from the package and file into the jar.

In the properties case, you can get a property with something like that:

private static final String LDAP_CASA =
PropertyReaderHelper.getProperty("PROVIDER_URL_CASA");
private static final String CASA_CONTEXT_SEARCH_1 =
PropertyReaderHelper.getProperty("CONTEXT_SEARCH_CASA_1");
private static final String CASA_CONTEXT_SEARCH_2 =
PropertyReaderHelper.getProperty("CONTEXT_SEARCH_CASA_2");
private static final String CASA_PRINCIPAL =
PropertyReaderHelper.getProperty("PRINCIAL_CASA");
private static final String CASA_CREDENTIALS =
PropertyReaderHelper.getProperty("CREDENTIALS_CASA");

I hope it helps you.

Regards,

JP




2011/1/16 Andreas Mielke <an...@googlemail.com>

> Hello JP,
>
> Please write me a example?
>
> Andreas
>
>
>
> Am 16.01.2011 um 20:37 schrieb Juan Pablo Pizarro <
> juanpablo.pizarro@gmail.com>:
>
> > Andreas, you can use a resource bundle to obtain the .properties from the
> > jar.. i mean, you put the .properties into the file and you can read from
> > it.
> >
> > I posted some classes to do that some months ago.
> >
> > Regards.
> >
> > JP
> >
> > 2011/1/16 Konstantin Kolinko <kn...@gmail.com>
> >
> >> 2011/1/16 Andreas Mielke <an...@googlemail.com>:
> >>> I use Apache Common Daemon to install a java application as a windows
> >> service. The problem is i have a java properties file to setup few
> >> parameters and i don't know how to describe the location of the property
> >> file in the command line. My installation of the service is like
> >>>
> >>> prunsrv //IS//TestService --DisplayName="Test Service"
> >> --Install=prunsrv.exe --Jvm=auto --StartMode=jvm --StopMode=jvm
> >> --StartClass=org.apache.SomeStartClass.
> >>>
> >>
> >> If you want to pass it as a system property, use "JvmOptions" [1] to
> >> specify -D.
> >>
> >> Is it what you are asking? If you were running your app with
> >> java(w).exe, what would be your command line?
> >>
> >> [1] http://commons.apache.org/daemon/procrun.html
> >>
> >> Best regards,
> >> Konstantin Kolinko
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> >> For additional commands, e-mail: user-help@commons.apache.org
> >>
> >>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>
>

Re: [DAEMON] procrun - java Property File

Posted by Andreas Mielke <an...@googlemail.com>.
Hello JP,

Please write me a example?

Andreas 



Am 16.01.2011 um 20:37 schrieb Juan Pablo Pizarro <ju...@gmail.com>:

> Andreas, you can use a resource bundle to obtain the .properties from the
> jar.. i mean, you put the .properties into the file and you can read from
> it.
> 
> I posted some classes to do that some months ago.
> 
> Regards.
> 
> JP
> 
> 2011/1/16 Konstantin Kolinko <kn...@gmail.com>
> 
>> 2011/1/16 Andreas Mielke <an...@googlemail.com>:
>>> I use Apache Common Daemon to install a java application as a windows
>> service. The problem is i have a java properties file to setup few
>> parameters and i don't know how to describe the location of the property
>> file in the command line. My installation of the service is like
>>> 
>>> prunsrv //IS//TestService --DisplayName="Test Service"
>> --Install=prunsrv.exe --Jvm=auto --StartMode=jvm --StopMode=jvm
>> --StartClass=org.apache.SomeStartClass.
>>> 
>> 
>> If you want to pass it as a system property, use "JvmOptions" [1] to
>> specify -D.
>> 
>> Is it what you are asking? If you were running your app with
>> java(w).exe, what would be your command line?
>> 
>> [1] http://commons.apache.org/daemon/procrun.html
>> 
>> Best regards,
>> Konstantin Kolinko
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>> For additional commands, e-mail: user-help@commons.apache.org
>> 
>> 

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Re: [DAEMON] procrun - java Property File

Posted by Juan Pablo Pizarro <ju...@gmail.com>.
Andreas, you can use a resource bundle to obtain the .properties from the
jar.. i mean, you put the .properties into the file and you can read from
it.

I posted some classes to do that some months ago.

Regards.

JP

2011/1/16 Konstantin Kolinko <kn...@gmail.com>

> 2011/1/16 Andreas Mielke <an...@googlemail.com>:
> > I use Apache Common Daemon to install a java application as a windows
> service. The problem is i have a java properties file to setup few
> parameters and i don't know how to describe the location of the property
> file in the command line. My installation of the service is like
> >
> > prunsrv //IS//TestService --DisplayName="Test Service"
> --Install=prunsrv.exe --Jvm=auto --StartMode=jvm --StopMode=jvm
> --StartClass=org.apache.SomeStartClass.
> >
>
> If you want to pass it as a system property, use "JvmOptions" [1] to
> specify -D.
>
> Is it what you are asking? If you were running your app with
> java(w).exe, what would be your command line?
>
> [1] http://commons.apache.org/daemon/procrun.html
>
> Best regards,
> Konstantin Kolinko
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>
>