|
From: <SA...@sy...> - 2007-04-17 15:11:40
|
Hi guys,
Thank you for your help.
Since the Java code, that I used in my example, is written by another
project, I'm not allowed to change it
so I had to come up with something else.
If I remember correctly win32 services are console applications
so in my configuration file I set the following properties:
# Allow the service to interact with the desktop.
wrapper.ntservice.interactive=true
wrapper.ntservice.console=TRUE
wrapper.ntservice.hide-console=FALSE
and it works!!
Regards,
Sabina Albu
Developer, Financial Capture Solutions, Technology Services
Symcor Inc.
wrapper-user-requ
es...@li...
orge.net To
Sent by: wra...@li...
wrapper-user-boun cc
ce...@li...
orge.net Subject
Wrapper-user Digest, Vol 11, Issue
5
11/04/2007 06:17
PM
Please respond to
wrapper-user@list
s.sourceforge.net
Send Wrapper-user mailing list submissions to
wra...@li...
To subscribe or unsubscribe via the World Wide Web, visit
https://lists.sourceforge.net/lists/listinfo/wrapper-user
or, via email, send a message with subject or body 'help' to
wra...@li...
You can reach the person managing the list at
wra...@li...
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Wrapper-user digest..."
Today's Topics:
1. Re: Executing code upon termination of NT service (Leif Mortenson)
2. Exception thrown when invoking
Thread.currentThread().sleep(250) with message "The handle is
invalid" (SA...@sy...)
3. Re: Exception thrown when invoking
Thread.currentThread().sleep(250) with message "The handle is
invalid" (David Hayes)
4. Re: Exception thrown when invoking
Thread.currentThread().sleep(250) with message "The handle is
invalid" (Andreas Wendt)
5. Re: Exception thrown when invoking
Thread.currentThread().sleep(250) with message "The handle is
invalid" (Leif Mortenson)
----------------------------------------------------------------------
Message: 1
Date: Tue, 10 Apr 2007 07:58:00 +0900
From: Leif Mortenson <le...@ta...>
Subject: Re: [Wrapper-user] Executing code upon termination of NT
service
To: wra...@li...
Message-ID: <461...@ta...>
Content-Type: text/plain; charset=windows-1252; format=flowed
Raymond,
WrapperListener.stop() is called by the WrapperManager class when it is
attempting to
shut down your java application cleanly. In the case of the
WrapperSimpleApp
implementation, the stop() method does not do anything. Applications
using the
WrapperSimpleStop helper class are expected to clean themselves up via a
shutdown
hook. As a general rule though, startup methods should call the super
class's method
at the beginning of the method and shutdown methods should do so at the
end. So
follow that pattern and call super.stop() after your code has executed.
That said however, the stop() method is called when the Wrapper wants to
stop the
JVM. This can happen in response to an external event like CTRL-C being
pressed,
or the service manager attempting to stop the service. It can also
happen if the
Wrapper's internal shutdown hook is started in response to the JVM
shutdown starting
on its own via a call to System.exit or something.
Important note is that the stop() method will ONLY be called for clean
shutdowns
of the JVM. If the JVM crashes or is killed because it has hung, the
stop() method
will never be called.
I have been working on a feature to allow the execution of external
applications
in response to things like the JVM being restarted or stopped. This
needs to happen
from the wrapper process, implemented in C, to make sure that those
applications
are always launched.
Cheers,
Leif
Raymond Bleach wrote:
>
> We have set up the wrapper as an NT service using the WrapperSimpleApp
> class. This is used to start a vendor supplied process that handles
> RPC requests.
>
> Now I have a need to execute some custom code whenever the NT service
> is stopped so that I can perform some cleanup and rolling of logs
> after the vendors? process terminates.
>
> I am looking at extending the WrapperSimpleApp and adding my custom
> code into the stop() method. I need to execute my code after the
> vendor?s code has stopped.
>
> Q: Is the stop() method called after the wrapper.app.parameter.1 has
> completed ?
>
> Q: Should I call the super.stop() method before or after execution of
> my custom code?
>
------------------------------
Message: 2
Date: Wed, 11 Apr 2007 10:51:54 -0400
From: SA...@sy...
Subject: [Wrapper-user] Exception thrown when invoking
Thread.currentThread().sleep(250) with message "The handle is
invalid"
To: wra...@li...
Message-ID:
<OF6...@sy...>
Content-Type: text/plain; charset=US-ASCII
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
------------------------------
Message: 3
Date: Wed, 11 Apr 2007 16:18:30 +0100
From: David Hayes <da...@sm...>
Subject: Re: [Wrapper-user] Exception thrown when invoking
Thread.currentThread().sleep(250) with message "The handle is
invalid"
To: wra...@li...
Message-ID: <461...@sm...>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
I just wanted to clarify something from you:
You have a run() method inside your service app, that you call directly
from the main() method. Are you intending this run() method to be
running in it's own thread, (whilst the starting thread, that executes
main() continues). If this is the case you should be calling
myService.start(); (and also be making the MyServiceApp extend Thread).
When the wrapper runs an application using method 1, it doesn't exactly
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
than there is without the wrapper. I suspect that you calling the
Thread.currentThread.sleep(250) is causing a wrapper thread to sleep,
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=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
>
>
>
>
------------------------------
Message: 4
Date: Wed, 11 Apr 2007 09:05:35 -0700
From: "Andreas Wendt" <And...@ag...>
Subject: Re: [Wrapper-user] Exception thrown when invoking
Thread.currentThread().sleep(250) with message "The handle is
invalid"
To: wra...@li...
Message-ID:
<7C7...@KH...>
Content-Type: text/plain; charset=us-ascii
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
from the main() method. Are you intending this run() method to be
running in it's own thread, (whilst the starting thread, that executes
main() continues). If this is the case you should be calling
myService.start(); (and also be making the MyServiceApp extend Thread).
When the wrapper runs an application using method 1, it doesn't exactly
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
than there is without the wrapper. I suspect that you calling the
Thread.currentThread.sleep(250) is causing a wrapper thread to sleep,
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=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
>
>
>
>
-------------------------------------------------------------------------
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
------------------------------
Message: 5
Date: Thu, 12 Apr 2007 07:14:08 +0900
From: Leif Mortenson <le...@ta...>
Subject: Re: [Wrapper-user] Exception thrown when invoking
Thread.currentThread().sleep(250) with message "The handle is
invalid"
To: wra...@li...
Message-ID: <461...@ta...>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
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
>
>
------------------------------
-------------------------------------------------------------------------
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
End of Wrapper-user Digest, Vol 11, Issue 5
*******************************************
|