|
From: Leif M. <le...@ta...> - 2007-04-12 08:14:25
|
Almond,
I think you are pretty much correct. See the source example on the
following page:
http://wrapper.tanukisoftware.org/doc/english/integrate-listener.html
The only think I was unsure of from your mail is the contents of the
WrapperListener.start
method. See the javadocs for the WrapperListener interface. The start
method MUST
return null or an exit code within a timely matter. This means that if
your StartTomCat()
method does not return, it needs to be launched in a worker thread.
If you are interested in seeing the source, you can download one of
the source distributions
or view the source directly on line:
http://wrapper.svn.sourceforge.net/viewvc/wrapper/trunk/wrapper/src/java/org/tanukisoftware/wrapper/
http://wrapper.svn.sourceforge.net/viewvc/wrapper/trunk/wrapper/src/java/org/tanukisoftware/wrapper/WrapperSimpleApp.java?view=markup
Cheers,
Leif
Almond Khan wrote:
> Thanks Leif for such a detailed reply.
>
> The first step I did was to follow point 4 suggested by you. I started
> a non-daemon thread from my main method then my service was not
> stopped automatically until I stopped it.
>
> Most of the steps you told me were about clean up and I was able to do
> them simply.
>
> I have confusion about point 3. Please let me tell you about some
> context. I am going to use embedded Tom Cat in my application and I
> need it to install my program as Windows Service.
>
> So what I did initially was this.
> http://wrapper.tanukisoftware.org/doc/english/integrate-listener.html
>
> I created my application class "MyApp" with two methods StartTomCat()
> and StopTomCat() and I instantiated an object of my application in
> Main class (given by you as example).
>
> The log is as follows:
>
> STATUS | wrapper | 2007/03/19 12:06:56 | CP30 Service installed.
> STATUS | wrapper | 2007/03/19 12:06:59 | Starting the CP30 Service
> service...
> STATUS | wrapper | 2007/03/19 12:06:59 | --> Wrapper Started as Service
> STATUS | wrapper | 2007/03/19 12:06:59 | Launching a JVM...
> INFO | jvm 1 | 2007/03/19 12:06:59 | Wrapper (Version 3.2.3)
> http://wrapper.tanukisoftware.org
> INFO | jvm 1 | 2007/03/19 12:06:59 | Copyright 1999-2006 Tanuki
> Software, Inc. All Rights Reserved.
> INFO | jvm 1 | 2007/03/19 12:06:59 |
> INFO | wrapper | 2007/03/19 12:07:04 | Waiting to start...
> INFO | jvm 1 | 2007/03/19 12:07:00 |
> INFO | jvm 1 | 2007/03/19 12:07:00 | Constructor is called!
> INFO | jvm 1 | 2007/03/19 12:07:00 | Application is started!
> INFO | jvm 1 | 2007/03/19 12:07:06 | InThread !InThread !InThread
> !InThread
> INFO | jvm 1 | 2007/03/19 12:07:47 | Application is stopped!
> INFO | jvm 1 | 2007/03/19 12:07:47 | InThread !InThread !
> INFO | jvm 1 | 2007/03/19 12:07:48 | InThread !InThread
> STATUS | wrapper | 2007/03/19 12:07:48 | <-- Wrapper Stopped
>
> In conf file , I defined
>
> wrapper.java.mainclass=com.myappl.vcp.service.Main
>
> but I did not define any thing for wrapper.app.parameter.1
>
> I did not use WrapperSimpleApp instead I used class implementing
> WrapperListener and was able to achieve the expected results. Now
> source code for WrapperSimpleApp is not given so I do not know if I am
> missing some things in my WrapperListener class. I want Start() and
> Stop() methods of myself so I want to go with Integration method 3.
>
> So my understanding is that once I implement the interface
> WrapperListner then I have to make sure that I call startTomCat() from
> start() of it and StopTomCat() from stop() method of it and the
> interface will take care every thing itself. Basically my whole logic
> is floating around this code
> http://wrapper.tanukisoftware.org/doc/english/integrate-listener.html
> . Even my application class does not have main method because it has
> only two methods StartTomCat() and STopTomCat() .
>
> Please let me know if there is a flaw in my understanding.
>
> Thanks,
>
> Almond
>
>
> */Leif Mortenson <le...@ta...>/* wrote:
>
> Almond,
> You need to read the documentation again :-)
> http://wrapper.tanukisoftware.org/doc/english/integrate.html
>
> Most likely method #1 will work for you:
> http://wrapper.tanukisoftware.org/doc/english/integrate-simple-win.html
>
> There were a few problems with what you said below:
> 1) You should start with a clean directory and copy the required
> Wrapper
> files into your
> application rather than the other way around. There are some things
> that you will not
> need such as the wrappertest.jar file.
>
> 2) You should create your wrapper.conf file based on the template
> file:
> WRAPPER_HOME/src/conf/wrapper.conf.in rather than using
> WRAPPER_HOME/conf/wrapper.conf.
>
> 3) As specified in the documentation and in the wrapper.conf file,
> the wrapper.java.mainclass property is used to specify the main class
> passed to the JVM. In most cases however, this is not your
> application's
> main class. The Wrapper has some code which must be initialized in the
> JVM first. This is covered clearly in the above documentation. Try
> this:
> wrapper.java.mainclass=org.tanukisoftware.wrapper.WrapperSimpleApp
>
> Your main method is then specified as the first parameter to the
> above main
> class.
> wrapper.app.parameter.1=
>
> 4) From the output that you sent however, it looks like your main
> class
> starts, prints a startup message, a shutdown message and then exits.
> Even if you do all of the above correctly, your application will
> still quit
> immediately because your main method does not appear to be designed
> to stay running. Running your class standalone in Java would have the
> same effect.
>
> The Wrapper works correctly in cases like this. But from your post, it
> sounds like you are expecting that the JVM stay running. Your
> application
> needs to start at least one non-daemon thread within the JVM that
> does not
> terminate. When all such threads have terminated, the JVM things the
> application has completed and the JVM will exit.
>
> 5) When you are still trying to get things working, I suggest
> running the
> application in a console window using TestWrapper.bat rather than
> running
> as a service. It is easier to see what is happening. Once that is all
> working,
> THEN, you should try it as a service.
>
> 6) Not required, but I suggest copying your bat files out of the
> WRAPPER_HOME/src/bin and then naming them after your application.
>
> Let me know if you have more questions...After checking out the
> docs of
> course.
>
> Cheers,
> Leif
>
>
> Almond Khan wrote:
> > All, I downloaded the source code and made my simple example
> with help
> > of code given on site(jar file is attached). That is very simple
> > example. My start method and stop method simply print message
> and then
> > exit.
> >
> > 1- I created jar file
> > 2- I put jar file in lib with wrapper.jar and wrappertest.jar
> > 3- I added classpath in conf file
> > wrapper.java.classpath.3=../lib/myexample.jar
> > 4- I modified Main class in conf file and pointed it to my example
> > wrapper.java.mainclass=org.tanukisoftware.wrapper.example.Main
> >
> > But when I am running , my service starts and stops(I assume).
> How did
> > I figure it out ??
> >
> >
> C:\wrapper-delta\wrapper-delta-pack-3.2.3\bin>InstallTestWrapper-NT.bat
> > wrapper | Test Wrapper Sample Application installed.
> >
> >
> C:\wrapper-delta\wrapper-delta-pack-3.2.3\bin>StartTestWrapper-NT.bat
> > wrapper | Starting the Test Wrapper Sample Application service...
> > wrapper | Test Wrapper Sample Application started.
> >
> > C:\wrapper-delta\wrapper-delta-pack-3.2.3\bin>StopTestWrapper-NT.bat
> > wrapper | The Test Wrapper Sample Application service was not
> running.
> >
> >
> C:\wrapper-delta\wrapper-delta-pack-3.2.3\bin>UninstallTestWrapper-NT.bat
> > wrapper | Test Wrapper Sample Application removed.
> >
> > So service was started but it stopped itself. I tried to start
> service
> > from windows service controller, it showed it was started but
> when I
> > refreshed service controller, it was not running.
> >
> > I looked at log and it also says the same thing.(Application is
> > started and Application is stopped are my custom messages)
> >
> > STATUS | wrapper | 2007/03/16 12:53:08 | Test Wrapper Sample
> > Application installed.
> > STATUS | wrapper | 2007/03/16 12:53:12 | Starting the Test Wrapper
> > Sample Application service...
> > STATUS | wrapper | 2007/03/16 12:53:12 | --> Wrapper Started as
> Service
> > STATUS | wrapper | 2007/03/16 12:53:12 | Launching a JVM...
> > INFO | jvm 1 | 2007/03/16 12:53:12 | Wrapper (Version 3.2.3)
> > http://wrapper.tanukisoftware.org
> > INFO | jvm 1 | 2007/03/16 12:53:12 | Copyright 1999-2006 Tanuki
> > Software, Inc. All Rights Reserved.
> > INFO | jvm 1 | 2007/03/16 12:53:12 |
> > INFO | jvm 1 | 2007/03/16 12:53:13 |
> > INFO | jvm 1 | 2007/03/16 12:53:13 | Application is started!
> > INFO | jvm 1 | 2007/03/16 12:53:14 |
> > INFO | jvm 1 | 2007/03/16 12:53:14 | Application is stopped!
> > STATUS | wrapper | 2007/03/16 12:53:14 | Test Wrapper Sample
> > Application started.
> > STATUS | wrapper | 2007/03/16 12:53:15 | <-- Wrapper Stopped
> >
> >
> >
> > I wonder why stop() method is getting called and why service is
> > stopping itself.
> >
> > Any help would be really appreciated. Please find an attached
> jar file
> > and conf for my code
> >
> > Thanks,
> >
> > Khan
> >
> > */Chuck Williams /* wrote:
> >
> > Wrapper is great to run your app as either a windows service or
> > linux daemon.� To try something quickly, read the Quick Start on
> > the project home page at
> > http://wrapper.tanukisoftware.org/doc/english/introduction.html
> >
> > Chuck
> >
> > Almond Khan wrote on 03/14/2007 01:47 PM:
> >> Hi,
> >>
> >> I googled for converting java application and ended with this
> >> project.
> >>
> >> We have embedded tomcat in our application and we use console to
> >> start/stop it.
> >>
> >> Now we are moving forward and we want to run applictaion as
> >> Windows service and I am wondering how can I convert my .class
> >> into Windows service.
> >>
> >> "So question is that how can I convert .class file into windows
> >> service"
> >>
> >> Any help is appreciated
> >>
> >> Thanks,
> >>
> >> Noman
> >
>
|