|
From: Leif M. <le...@ta...> - 2007-04-11 22:17:17
|
Sabina,
Looking over your code, I do not see anything that you are doing "wrong"
when using the WrapperSimpleApp (Method 1) integration method.
Calling sleep in the main method of your application is perfectly valid.
Your use of the run() method name is a bit non-java standard in that it is
usually the method name called for the root of a new thread. But the way
you are calling it, it is just another method name, so no problem. Nothing
you are doing in your code snippet should be affecting the Wrapper.
You did not send the beginning of your run method, most likely because
you feel it does not affect things. My guess is that something there may
be causing this, but I can't think off the top of my head what it would be.
I have seen cases in the past where an exception was being thrown from
a different location than I had thought due to ambiguous message text.
Could
you change your code as follows. The first is to make sure that sleep is
working before you do anything else, the second block is to see what the
exact exception is and what its full call stack is.
---
public class MyServiceApp{
public static void main(String[] args) {
System.out.println("MAIN1");
try {
Thread.sleep(250);
} catch (Exception e) {
log.error("Interrupted Main. " + e);
e.printStackTrace();
}
System.out.println("MAIN2");
MyServiceApp myService = new MyServiceApp();
myService .run();
}
public void run(){
System.out.println("HERE1");
try {
Thread.sleep(250);
} catch (Exception e) {
log.error("Interrupted1. " + e);
e.printStackTrace();
}
System.out.println("HERE2");
//create new threads here
....
//sleep
System.out.println("HERE3");
try {
Thread.sleep(250);
} catch (Exception e) {
log.error("Interrupted. " + e);
e.printStackTrace();
}
System.out.println("HERE4");
}
}
---
Does anything happen in your MyServiceApp constructor?
Cheers,
Leif
SA...@sy... wrote:
> Hi,
>
> I'm using the service wrapper as described in Method 1 - WrapperSimpleApp
> Integration (Win32).
> I used the templates provided in the /src/bin directory to create
> MyService.bat
> InstallMyService.bat
> UninstallMyService.bat
>
> However, when I run MyService from the Administrative tools>Services
> an exception is thrown when I invoke Thread.currentThread().sleep(250);
> with the message: The handle is invalid.
> after which the service stops, following a normal shutdown routine.
>
> I'm running on Win XP SP2
> Java Service Wrapper 3.2.3
> JDK 1.5.0_11
>
> Bellow is a snippet from the log file:
>
> INFO | jvm 1 | 2007/04/11 09:39:12 | WrapperSimpleApp: invoking main
> method
> INFO | jvm 1 | 2007/04/11 09:39:12 | 09:39:12,960 ERROR
> MyServiceApp:80 - Interrupted. The handle is invalid
> INFO | jvm 1 | 2007/04/11 09:39:12 | WrapperSimpleApp: main method
> completed
> INFO | jvm 1 | 2007/04/11 09:39:12 | WrapperSimpleApp: start(args)
> end. Main Completed=true, exitCode=null
> INFO | jvm 1 | 2007/04/11 09:39:12 | WrapperListener.start runner
> thread stopped.
> INFO | jvm 1 | 2007/04/11 09:39:12 | returned from
> WrapperListener.start()
> INFO | jvm 1 | 2007/04/11 09:39:12 | Send a packet STARTED :
> DEBUG | wrapperp | 2007/04/11 09:39:12 | read a packet STARTED :
> DEBUG | wrapper | 2007/04/11 09:39:12 | JVM signalled that it was
> started.
> INFO | jvm 1 | 2007/04/11 09:39:13 | Startup runner thread stopped.
> INFO | jvm 1 | 2007/04/11 09:39:13 | Wrapper Manager: ShutdownHook
> started
> INFO | jvm 1 | 2007/04/11 09:39:13 | WrapperManager.stop(0) called by
> thread: Wrapper-Shutdown-Hook
> INFO | jvm 1 | 2007/04/11 09:39:13 | Send a packet STOP : 0
> DEBUG | wrapperp | 2007/04/11 09:39:13 | read a packet STOP : 0
> DEBUG | wrapper | 2007/04/11 09:39:13 | JVM requested a shutdown. (0)
>
>
> and a snippet from my java class:
>
>
> public class MyServiceApp{
> public static void main(String[] args) {
> MyServiceApp myService = new MyServiceApp();
> myService .run();
> }
>
> public void run(){
> //create new threads here
> ....
> //sleep
> try {
> Thread.currentThread().sleep(250);
> } catch (Exception e) {
> log.error("Interrupted. " + e.getMessage());
> }
> }
> }
>
>
> Any ideas are welcomed.
>
>
> Regards,
> Sabina Albu
>
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share your
> opinions on IT & business topics through brief surveys-and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> _______________________________________________
> Wrapper-user mailing list
> Wra...@li...
> https://lists.sourceforge.net/lists/listinfo/wrapper-user
>
>
|