|
From: Andreas W. <And...@ag...> - 2007-04-11 16:05:59
|
Hi Sabina, As I assume that the run() method is not intended to be run inside an = own thread, it runs inside the main thread. Therefore, calling a Thread.sleep() in the main thread is not a good = idea as it may interfere with the JVM or the wrapper. You should only call the sleep() method in the context of an own = thread's run() method to ensure that the proper thread is sleeping. You should also not use Thread.currentThread().sleep(250) as sleep() is = a static method and prefixing it with currentThread() will have no = effect (see http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Thread.html#sleep(long)= ). If you would provide more info about what you are trying to achieve, I = could be more of a help. --Andreas -----Original Message----- From: wra...@li... = [mailto:wra...@li...] On Behalf Of David = Hayes Sent: Wednesday, April 11, 2007 17:19 To: wra...@li... Subject: Re: [Wrapper-user] Exception thrown when invoking = Thread.currentThread().sleep(250) with message "The handle is invalid" I just wanted to clarify something from you: You have a run() method inside your service app, that you call directly=20 from the main() method. Are you intending this run() method to be=20 running in it's own thread, (whilst the starting thread, that executes=20 main() continues). If this is the case you should be calling=20 myService.start(); (and also be making the MyServiceApp extend Thread). When the wrapper runs an application using method 1, it doesn't exactly=20 run the same way as it would without the wrapper. For a start, there are = other threads running by the time the code reaches your main() method=20 than there is without the wrapper. I suspect that you calling the=20 Thread.currentThread.sleep(250) is causing a wrapper thread to sleep,=20 and thus to lose a handle to some native resource. David Hayes 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=3Dtrue, exitCode=3Dnull > 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 =3D 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=3Djoin.php&p=3Dsourceforge&CID=3D= DEVDEV > _______________________________________________ > Wrapper-user mailing list > Wra...@li... > https://lists.sourceforge.net/lists/listinfo/wrapper-user > > > > =20 -------------------------------------------------------------------------= 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=3Djoin.php&p=3Dsourceforge&CID=3D= DEVDEV _______________________________________________ Wrapper-user mailing list Wra...@li... https://lists.sourceforge.net/lists/listinfo/wrapper-user |