|
From: Leif M. <lei...@ta...> - 2009-01-16 02:28:09
|
Larry,
The problem is that even though you have overridden your start method,
the main method is still the same. This means that when you execute
Test.main(), it is really executing the WrapperSimpleApp.main()
method. That method in turn instantiates an instance of
WrapperSimpleApp directly so your Test class instance is never
created.
To fix this, create the following method and place it into your Test class:
public static void main( String args[] )
{
new Test( args );
}
I added a note about this to the javadocs for the next release.
Hope this helps.
Cheers,
Leif
On Fri, Jan 16, 2009 at 7:26 AM, Larry Shatzer, Jr. <la...@gm...> wrote:
> I am trying to subclass WrapperSimpleApp and running into problems. I
> have read the javadoc where it says it is possible and to make sure
> any overridden method calls the super method. I have done that, and it
> still is not working the way I want it.
>
> Here is a stripped down example:
>
> package test;
>
> import org.tanukisoftware.wrapper.WrapperSimpleApp;
>
> public class Test extends WrapperSimpleApp {
>
> protected Test(String[] args) {
> super(args);
> }
>
> public Integer start(String[] args) {
> System.out.println("I should see this in the output!");
> return super.start(args);
> }
>
> }
>
> In my wrapper.conf file:
>
> wrapper.java.mainclass=test.Test
>
> And I include the jar in the wrapper.java.classpath array.
>
> The wrapper starts up, and runs fine as a service and from the
> console, but I never see the System.out.println statement in the log
> (or on the console). I tried DEBUG log level as well.
>
> If I copy ALL of the source code of WrapperSimpleApp and modify where
> necessary (class names, and copy over the WrapperPrintStream), and
> enter my System.out.println's where I need them, it works then.
>
> It seems that the WrapperManager (or whatever calls the start (or any
> of the other methods subclassed from WrapperSimpleApp) never get
> called on my subclass.
>
> Is the javadoc just wrong on the code, and the class cannot be
> subclassed, or are there some hoops you have to jump through?
>
> -- Larry
|