|
From: Nick R. <nic...@em...> - 2004-06-30 17:46:23
|
Thanks for your reply Leif. I'm running the app simply as "java Pserver.class" in the console. The Pserver.java looks like: import java.io.*; import java.net.*; public class Pserver { public static void main(String[] args) { ServerSocket serverSocket; Socket client; Pthread thClient; try { serverSocket=new ServerSocket(39823); while(true) { client=serverSocket.accept(); thClient = new Pthread(client); thClient.run(); } } catch(Exception e) { e.printStackTrace(); } } } Can u please give me an example on the above code, as to how to implement the helper class and what configuration to use for the wrapper. Maybe I am thinking too hard :) Thanks for your help mate! ------------------------------------- Nick, How are you running your application without the Wrapper? If you use method 1, with the WrapperSimpleApp helper class, there is zero special coding that you will have to do. You simply specify your main class as the argument to the WrapperSimpleApp helper class and you are up and running. It sounds like your Pserver and Pthread classes are both running in the same JVM? Correct? Post how you normally run them from a console and I"ll tell you what you need to do to use the Wrapper. I have a feeling that you are just thinking too hard :-) Cheers, Leif Nick Rice wrote: >Hello All, > >This wrapper is exactly what I"ve was looking for. But I need some help >on how to go about integrating it with my application. See, I have a two >java class files (say Pserver.class and Pthread.class). Pserver listens >as a server socket (i.e. in a while loop), and it passes the socket >client to the Pthread class which processes the incoming data. Now, in >this scenario, how can I go about integrating the Pserver as an >unmanaged service. I read the docs but I"m not sure which of the three >integration methods is most suitable in my case. I tried playing with >the first (simpler) integration method but due to my limited Java >knowledge I could not get it to run as a service. I guess what I"m >missing is hot to integrate the wrapper and my Pserver class. Can >someone provide more details on how to impelment the helper class in my >Pserver class and then finally where to specify the wrapper to use the >modified Pserver. > >Any help is much appreciated. Thanks :) -- Nick Rice nic...@em... |
|
From: Nick R. <nic...@em...> - 2004-07-03 06:19:39
|
Thanks for your assistance Leif. The instructions helped me setup the
wrapper and get it to work. Its working fine now. Once small issue I
came across was that if I manually deleted all the logs while the
wrapper service was running (as a daemon on Linux in this case), the
service would somehow stop on its own.
I will definately tell others about this neat utility and I will also
consider donating in the coming time.
Thanks again :)
--
Nick Rice
nic...@em...
----- Original message -----
Nick,
You sound new to Java, so I"ll walk you through what is covered on
the following
page :-)
http://wrapper.tanukisoftware.org/doc/english/integrate.html
When you get things working, please do think about remembering our
helpfulness here :-)
http://wrapper.tanukisoftware.org/doc/english/donate.html
:
:
:
http://sourceforge.net/mailarchive/forum.php?thread_id=5037527&forum_id=11948
:
:
:
|
|
From: Leif M. <le...@ta...> - 2004-07-03 13:37:43
|
Nick, >Thanks for your assistance Leif. The instructions helped me setup the >wrapper and get it to work. Its working fine now. > Great glad you got things working. > Once small issue I >came across was that if I manually deleted all the logs while the >wrapper service was running (as a daemon on Linux in this case), the >service would somehow stop on its own. > > I just reverified this on a Linux machine and it appears to be working for me. You should be able to delete the wrapper.log file at any time without causing any problems. Exactly what file are you deleting? Even if there was an error of some kind which caused the Wrapper to shutdown, it should be recreating the wrapper.log as it writes out messages as it shuts down. Do you have any other log files that are created by your Java application. Deleting one of those could cause errors in your application depending on how it is written? The new 3.1.1 version can be configured to create an anchor file. If you delete that then the Wrapper will shutdown. But that is by design. Cheers, Leif |
|
From: Leif M. <le...@ta...> - 2004-07-01 06:52:15
|
Nick,
You sound new to Java, so I'll walk you through what is covered on
the following
page :-)
http://wrapper.tanukisoftware.org/doc/english/integrate.html
When you get things working, please do think about remembering our
helpfulness here :-)
http://wrapper.tanukisoftware.org/doc/english/donate.html
1) Lets start out by creating a directory structure where %APP_HOME% is
the base
directory of your application.
%APP_HOME%\bin
%APP_HOME%\conf
%APP_HOME%\lib
%APP_HOME%\lib\classes
%APP_HOME%\logs
2) First we need want to put your two class files into the
%APP_HOME%\lib\classes
directory. I would suggest eventually putting them into a jar file and
making use
of package names, but that is not necessary.
3) Copy the 3 template batch files from the Wrapper distribution into
your bin directory
as follows. Replace MyApp with the name of your application:
copy %WRAPPER_HOME%\src\bin\App.bat.in %APP_HOME%\bin\MyApp.bat
copy %WRAPPER_HOME%\src\bin\InstallApp-NT.bat.in
%APP_HOME%\bin\InstallMyApp-NT.bat
copy %WRAPPER_HOME%\src\bin\UninstallApp-NT.bat.in
%APP_HOME%\bin\UninstallMyApp-NT.bat
4) Copy the following 3 binary files from the Wrapper distribution into
your bin and
lib directories as follows:
copy %WRAPPER_HOME%\bin\Wrapper.exe %APP_HOME%\bin\Wrapper.exe
copy %WRAPPER_HOME%\lib\wrapper.dll %APP_HOME%\lib\wrapper.dll
copy %WRAPPER_HOME%\lib\wrapper.jar %APP_HOME%\lib\wrapper.jar
5) Copy the template wrapper.conf file as follows:
copy %WRAPPER_HOME%\src\conf\wrapper.conf.in %APP_HOME%\conf\wrapper.conf
6) Ok, now all of your files are in place. We now need to edit the
wrapper.conf file
so it will work with your application.
6a) Depending on how your system is set up, you may need to hard code in the
location of the java.exe on your system. Realize that it may or may not be
configured correctly on your path when running as a service.
The following default may work correctly.
wrapper.java.command=java
But you may need to set it to something like:
wrapper.java.command=%JAVA_HOME%/bin/java
Or even:
wrapper.java.command=C:/j2sdk1.4.2_04/bin/java
6b) In this case, for the main java class, we are going to be using
integration
method #1, so we will set it as follows:
wrapper.java.mainclass=org.tanukisoftware.wrapper.WrapperSimpleApp
6c) The classpath will need to include both the wrapper.jar file and
your classes
directory. These paths and all other paths can either be hard coded or
defined
relative to the location of the Wrapper.exe file. I would suggest the
later as it
enables you to install your application on any machine at any location
without any
changes to the configuration file.
wrapper.java.classpath.1=../lib/wrapper.jar
wrapper.java.classpath.2=../lib/classes
6d) The library path specifies the location of wrapper.dll and any other
native
libraries that your application may use. In this case, the default is ok.
wrapper.java.library.path.1=../lib
6e) The above WrapperSimpleApp helper class expects that its first argument
will be the name of your application's main class. We specify this as
follows.
If you need to pass any arguments to your main method, then add them after
the main class, incrementing the .1 number after each property
wrapper.java.additional.1=Pserver
6f) For now, we can leave the logging properties alone. But if you run
into any
problems then you will want to set the following property and try
again. If the
resulting %APP_HOME%/logs/wrapper.log file contents do not make sense,
then I will need to see that file and the wrapper.conf file you are
currently editing
to be able to help further.
6g) At the bottom of the file, we want to set the following properties
do define
how your application is registered as an NT service.
wrapper.ntservice.name=myapp
wrapper.ntservice.displayname=My Application
wrapper.ntservice.description=My Application Server
6h) Save the wrapper.conf file.
7) We are now ready to run. Start out by opening a command prompt
and cd-ing into your %APP_HOME%/bin directory.
Try running the application in console mode by running the MyApp.bat
file. Your application should start up and work correctly.
8) Stop your program with CTRL-C. Because your main runner thread
is not configured as a Daemon thread, the java application may or may
not shutdown promptly. Let me know if after 30 seconds you are getting
a message about the JVM not shutting down cleanly. The Wrapper will
forcibly kill the JVM process in such situations.
9) If everything is going well to this point, we are ready to try
running your
application as a service. First we need to install it by running
InstallMyApp-NT.bat
Next you can start it by running "net start myapp" from the console, or
starting the service from within the Services control panel.
You should see a message saying that the service was started.
Try testing it out. And review the contents of the wrapper.log file to see
if you are getting any unexpected errors.
The service is now configured to startup when the system is rebooted.
10) You can stop the service from the control panel or by executing
"net stop myapp" from a console. Running UninstallMyApp-NT.bat
will of course uninstall the service.
That should cover it. See 0 lines of Java code involved :-) Let me know
if I missed anything or if you run into any problems.
Cheers,
Leif
Nick Rice wrote:
>Thanks for your reply Leif.
>
>I'm running the app simply as "java Pserver.class" in the console. The
>Pserver.java looks like:
>
>import java.io.*;
>import java.net.*;
>
>public class Pserver {
>
> public static void main(String[] args)
> {
> ServerSocket serverSocket;
> Socket client;
> Pthread thClient;
>
> try
> {
>
> serverSocket=new ServerSocket(39823);
> while(true)
> {
> client=serverSocket.accept();
> thClient = new Pthread(client);
> thClient.run();
> }
>
> }
> catch(Exception e)
> {
> e.printStackTrace();
> }
> }
>
>}
>
>
>Can u please give me an example on the above code, as to how to
>implement the helper class and what configuration to use for the
>wrapper. Maybe I am thinking too hard :)
>
>Thanks for your help mate!
>
>
>
>-------------------------------------
>
>
>Nick,
> How are you running your application without the Wrapper? If you
> use method 1,
> with the WrapperSimpleApp helper class, there is zero special coding
> that you will
> have to do.
> You simply specify your main class as the argument to the
> WrapperSimpleApp
> helper class and you are up and running.
>
> It sounds like your Pserver and Pthread classes are both running in
> the same
> JVM? Correct? Post how you normally run them from a console and I"ll
> tell
> you what you need to do to use the Wrapper. I have a feeling that you
> are just
> thinking too hard :-)
>
> Cheers,
> Leif
>
> Nick Rice wrote:
>
> >Hello All,
> >
> >This wrapper is exactly what I"ve was looking for. But I need some help
> >on how to go about integrating it with my application. See, I have a two
> >java class files (say Pserver.class and Pthread.class). Pserver listens
> >as a server socket (i.e. in a while loop), and it passes the socket
> >client to the Pthread class which processes the incoming data. Now, in
> >this scenario, how can I go about integrating the Pserver as an
> >unmanaged service. I read the docs but I"m not sure which of the three
> >integration methods is most suitable in my case. I tried playing with
> >the first (simpler) integration method but due to my limited Java
> >knowledge I could not get it to run as a service. I guess what I"m
> >missing is hot to integrate the wrapper and my Pserver class. Can
> >someone provide more details on how to impelment the helper class in my
> >Pserver class and then finally where to specify the wrapper to use the
> >modified Pserver.
> >
> >Any help is much appreciated. Thanks :)
>
>
|
|
From: Leif M. <le...@ta...> - 2004-07-01 07:51:23
|
Nick,
I noticed one mistake in step 6e. See below. I want to keep this
together
for the archives.
Leif Mortenson wrote:
> Nick,
> You sound new to Java, so I'll walk you through what is covered on
> the following
> page :-)
> http://wrapper.tanukisoftware.org/doc/english/integrate.html
>
> When you get things working, please do think about remembering our
> helpfulness here :-)
> http://wrapper.tanukisoftware.org/doc/english/donate.html
>
> 1) Lets start out by creating a directory structure where %APP_HOME%
> is the base
> directory of your application.
>
> %APP_HOME%\bin
> %APP_HOME%\conf
> %APP_HOME%\lib
> %APP_HOME%\lib\classes
> %APP_HOME%\logs
>
> 2) First we need want to put your two class files into the
> %APP_HOME%\lib\classes
> directory. I would suggest eventually putting them into a jar file
> and making use
> of package names, but that is not necessary.
>
> 3) Copy the 3 template batch files from the Wrapper distribution into
> your bin directory
> as follows. Replace MyApp with the name of your application:
> copy %WRAPPER_HOME%\src\bin\App.bat.in %APP_HOME%\bin\MyApp.bat
> copy %WRAPPER_HOME%\src\bin\InstallApp-NT.bat.in
> %APP_HOME%\bin\InstallMyApp-NT.bat
> copy %WRAPPER_HOME%\src\bin\UninstallApp-NT.bat.in
> %APP_HOME%\bin\UninstallMyApp-NT.bat
>
> 4) Copy the following 3 binary files from the Wrapper distribution
> into your bin and
> lib directories as follows:
> copy %WRAPPER_HOME%\bin\Wrapper.exe %APP_HOME%\bin\Wrapper.exe
> copy %WRAPPER_HOME%\lib\wrapper.dll %APP_HOME%\lib\wrapper.dll
> copy %WRAPPER_HOME%\lib\wrapper.jar %APP_HOME%\lib\wrapper.jar
>
> 5) Copy the template wrapper.conf file as follows:
> copy %WRAPPER_HOME%\src\conf\wrapper.conf.in %APP_HOME%\conf\wrapper.conf
>
> 6) Ok, now all of your files are in place. We now need to edit the
> wrapper.conf file
> so it will work with your application.
>
> 6a) Depending on how your system is set up, you may need to hard code
> in the
> location of the java.exe on your system. Realize that it may or may
> not be
> configured correctly on your path when running as a service.
>
> The following default may work correctly.
> wrapper.java.command=java
>
> But you may need to set it to something like:
> wrapper.java.command=%JAVA_HOME%/bin/java
>
> Or even:
> wrapper.java.command=C:/j2sdk1.4.2_04/bin/java
>
> 6b) In this case, for the main java class, we are going to be using
> integration
> method #1, so we will set it as follows:
> wrapper.java.mainclass=org.tanukisoftware.wrapper.WrapperSimpleApp
>
> 6c) The classpath will need to include both the wrapper.jar file and
> your classes
> directory. These paths and all other paths can either be hard coded
> or defined
> relative to the location of the Wrapper.exe file. I would suggest the
> later as it
> enables you to install your application on any machine at any location
> without any
> changes to the configuration file.
> wrapper.java.classpath.1=../lib/wrapper.jar
> wrapper.java.classpath.2=../lib/classes
>
> 6d) The library path specifies the location of wrapper.dll and any
> other native
> libraries that your application may use. In this case, the default is
> ok.
> wrapper.java.library.path.1=../lib
>
> 6e) The above WrapperSimpleApp helper class expects that its first
> argument
> will be the name of your application's main class. We specify this as
> follows.
> If you need to pass any arguments to your main method, then add them
> after
> the main class, incrementing the .1 number after each property
> wrapper.java.additional.1=Pserver
This should have been the following:
wrapper.app.parameter.1=Pserver
The java additional properties are for setting options to the JVM itself.
> 6f) For now, we can leave the logging properties alone. But if you
> run into any
> problems then you will want to set the following property and try
> again. If the
> resulting %APP_HOME%/logs/wrapper.log file contents do not make sense,
> then I will need to see that file and the wrapper.conf file you are
> currently editing
> to be able to help further.
>
> 6g) At the bottom of the file, we want to set the following properties
> do define
> how your application is registered as an NT service.
> wrapper.ntservice.name=myapp
> wrapper.ntservice.displayname=My Application
> wrapper.ntservice.description=My Application Server
>
> 6h) Save the wrapper.conf file.
>
> 7) We are now ready to run. Start out by opening a command prompt
> and cd-ing into your %APP_HOME%/bin directory.
> Try running the application in console mode by running the MyApp.bat
> file. Your application should start up and work correctly.
>
> 8) Stop your program with CTRL-C. Because your main runner thread
> is not configured as a Daemon thread, the java application may or may
> not shutdown promptly. Let me know if after 30 seconds you are getting
> a message about the JVM not shutting down cleanly. The Wrapper will
> forcibly kill the JVM process in such situations.
>
> 9) If everything is going well to this point, we are ready to try
> running your
> application as a service. First we need to install it by running
> InstallMyApp-NT.bat
> Next you can start it by running "net start myapp" from the console, or
> starting the service from within the Services control panel.
> You should see a message saying that the service was started.
> Try testing it out. And review the contents of the wrapper.log file
> to see
> if you are getting any unexpected errors.
> The service is now configured to startup when the system is rebooted.
>
> 10) You can stop the service from the control panel or by executing
> "net stop myapp" from a console. Running UninstallMyApp-NT.bat
> will of course uninstall the service.
>
> That should cover it. See 0 lines of Java code involved :-) Let me know
> if I missed anything or if you run into any problems.
>
> Cheers,
> Leif
>
> Nick Rice wrote:
>
>> Thanks for your reply Leif.
>>
>> I'm running the app simply as "java Pserver.class" in the console. The
>> Pserver.java looks like:
>>
>> import java.io.*;
>> import java.net.*;
>>
>> public class Pserver {
>>
>> public static void main(String[] args) {
>> ServerSocket serverSocket;
>> Socket client;
>> Pthread thClient;
>>
>> try
>> {
>>
>> serverSocket=new ServerSocket(39823);
>> while(true)
>> {
>> client=serverSocket.accept();
>> thClient = new Pthread(client);
>> thClient.run();
>> }
>>
>> }
>> catch(Exception e)
>> {
>> e.printStackTrace();
>> }
>> }
>>
>> }
>>
>>
>> Can u please give me an example on the above code, as to how to
>> implement the helper class and what configuration to use for the
>> wrapper. Maybe I am thinking too hard :)
>>
>> Thanks for your help mate!
>>
>>
>>
>> -------------------------------------
>>
>>
>> Nick,
>> How are you running your application without the Wrapper? If you
>> use method 1,
>> with the WrapperSimpleApp helper class, there is zero special coding
>> that you will
>> have to do.
>> You simply specify your main class as the argument to the
>> WrapperSimpleApp
>> helper class and you are up and running.
>>
>> It sounds like your Pserver and Pthread classes are both running
>> in the same
>> JVM? Correct? Post how you normally run them from a console and I"ll
>> tell
>> you what you need to do to use the Wrapper. I have a feeling that
>> you are just
>> thinking too hard :-)
>>
>> Cheers,
>> Leif
>>
>> Nick Rice wrote:
>>
>> >Hello All,
>> >
>> >This wrapper is exactly what I"ve was looking for. But I need some help
>> >on how to go about integrating it with my application. See, I have a
>> two
>> >java class files (say Pserver.class and Pthread.class). Pserver listens
>> >as a server socket (i.e. in a while loop), and it passes the socket
>> >client to the Pthread class which processes the incoming data. Now, in
>> >this scenario, how can I go about integrating the Pserver as an
>> >unmanaged service. I read the docs but I"m not sure which of the three
>> >integration methods is most suitable in my case. I tried playing with
>> >the first (simpler) integration method but due to my limited Java
>> >knowledge I could not get it to run as a service. I guess what I"m
>> >missing is hot to integrate the wrapper and my Pserver class. Can
>> >someone provide more details on how to impelment the helper class in my
>> >Pserver class and then finally where to specify the wrapper to use the
>> >modified Pserver.
>> >
>> >Any help is much appreciated. Thanks :)
>>
>
|