You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Ian Emmons <ie...@bbn.com> on 2013/03/01 22:06:38 UTC

[daemon] jsvc won't recognize my entry point class

I am trying to use jsvc to launch my program on Ubuntu 12.10 with Java 7:

$ java -version
java version "1.7.0_15"
OpenJDK Runtime Environment (IcedTea7 2.3.7) (7u15-2.3.7-0ubuntu1~12.10)
OpenJDK 64-Bit Server VM (build 23.7-b01, mixed mode)

With the -debug flag, jsvc reports that it correctly finds and loads the JVM shared lib:

/usr/lib/jvm/java-6-openjdk/jre/lib/amd64/server/libjvm.so

At the very end of the log, jsvc reports the following:

Java VM created successfully
Cannot find daemon loader org/apache/commons/daemon/support/DaemonLoader
java_init failed

I am not surprised that jsvc can't find DaemonLoader, since I only built the native part of commons-daemon.  However, I thought I understood from the docs that I didn't need DaemonLoader if the entry point class on the jsvc command line implemented the magic four methods.  The public interface of my entry point class looks like this:

public class JettyDaemon {
   public void init(String[] args) { ... }
   public void start() { ... }
   public void stop() { ... }
   public void destroy() { ... }
}

Why does jsvc not load and execute this class directly?  Is there a way to get jsvc to print diagnostics about the loading process?  Or is it the case that jsvc requires the DaemonLoader Java class to be available?

Thanks,

Ian
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Re: [daemon] jsvc won't recognize my entry point class

Posted by Ian Emmons <ie...@bbn.com>.
On Mar 5, 2013, at 11:36 AM, Mladen Turk <mt...@apache.org> wrote:
> On 03/04/2013 06:00 PM, Ian Emmons wrote:
>> Update:  I've done some digging in the jsvc source code, and it appears to be at odds with the documentation [1].  The docs indicate that I can (a) write a Java class that implements the Daemon interface, or (b) define a class that implements four specific methods (init, start, stop, destroy, with specific signatures).
>> 
>> If I choose (a), the docs say I needs to put the commons-daemon jar on my classpath (an obvious requirement), but if I choose (b), then the jar is not needed.  However, the jsvc source code seems to load the DaemonLoader class in both cases, and so therefore the jar is always required.
>> 
>> Can a someone familiar with the jsvc internals confirm this analysis?  If I am correct, then I will enter a JIRA issue against the docs.
> 
> Yes, commons-daemon is always required.  If you do not specify Daemon interface, it's still created internally and calls your methods.  I don't see anything that says that its not required. It's your presumption, so perhaps a statement that its always needed would be more clear.  You are welcome to write something and if it make sense, I'll commit it.

The part of the docs I'm referring to is [1], where it shows two examples of invoking jsvc, one corresponding to case (a) and the other to case (b).  The only difference between the two is that the example for case (b) omits the commons-daemon jar from the class path.  The change I would suggest it to make the second example identical to the first.

[1] http://commons.apache.org/proper/commons-daemon/jsvc.html#Using_jsvc
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Re: [daemon] jsvc won't recognize my entry point class

Posted by Mladen Turk <mt...@apache.org>.
On 03/04/2013 06:00 PM, Ian Emmons wrote:
> Update:  I've done some digging in the jsvc source code, and it appears to be at odds with the documentation [1].  The docs indicate that I can (a) write a Java class that implements the Daemon interface, or (b) define a class that implements four specific methods (init, start, stop, destroy, with specific signatures).
>
> If I choose (a), the docs say I needs to put the commons-daemon jar on my classpath (an obvious requirement), but if I choose (b), then the jar is not needed.  However, the jsvc source code seems to load the DaemonLoader class in both cases, and so therefore the jar is always required.
>
> Can a someone familiar with the jsvc internals confirm this analysis?  If I am correct, then I will enter a JIRA issue against the docs.
>

Yes, commons-daemon is always required.
If you do not specify Daemon interface, it's still created internally and calls your methods.
I don't see anything that says that its not required. It's your presumption, so perhaps
a statement that its always needed would be more clear.
You are welcome to write something and if it make sense, I'll commit it.


Regards
-- 
^TM

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Re: [daemon] jsvc won't recognize my entry point class

Posted by Ian Emmons <ie...@bbn.com>.
Update:  I've done some digging in the jsvc source code, and it appears to be at odds with the documentation [1].  The docs indicate that I can (a) write a Java class that implements the Daemon interface, or (b) define a class that implements four specific methods (init, start, stop, destroy, with specific signatures).

If I choose (a), the docs say I needs to put the commons-daemon jar on my classpath (an obvious requirement), but if I choose (b), then the jar is not needed.  However, the jsvc source code seems to load the DaemonLoader class in both cases, and so therefore the jar is always required.

Can a someone familiar with the jsvc internals confirm this analysis?  If I am correct, then I will enter a JIRA issue against the docs.

Thanks,

Ian

[1] http://commons.apache.org/proper/commons-daemon/jsvc.html#Using_jsvc


On Mar 1, 2013, at 4:06 PM, Ian Emmons <ie...@bbn.com> wrote:
> I am trying to use jsvc to launch my program on Ubuntu 12.10 with Java 7:
> 
> $ java -version
> java version "1.7.0_15"
> OpenJDK Runtime Environment (IcedTea7 2.3.7) (7u15-2.3.7-0ubuntu1~12.10)
> OpenJDK 64-Bit Server VM (build 23.7-b01, mixed mode)
> 
> With the -debug flag, jsvc reports that it correctly finds and loads the JVM shared lib:
> 
> /usr/lib/jvm/java-6-openjdk/jre/lib/amd64/server/libjvm.so
> 
> At the very end of the log, jsvc reports the following:
> 
> Java VM created successfully
> Cannot find daemon loader org/apache/commons/daemon/support/DaemonLoader
> java_init failed
> 
> I am not surprised that jsvc can't find DaemonLoader, since I only built the native part of commons-daemon.  However, I thought I understood from the docs that I didn't need DaemonLoader if the entry point class on the jsvc command line implemented the magic four methods.  The public interface of my entry point class looks like this:
> 
> public class JettyDaemon {
>   public void init(String[] args) { ... }
>   public void start() { ... }
>   public void stop() { ... }
>   public void destroy() { ... }
> }
> 
> Why does jsvc not load and execute this class directly?  Is there a way to get jsvc to print diagnostics about the loading process?  Or is it the case that jsvc requires the DaemonLoader Java class to be available?
> 
> Thanks,
> 
> Ian


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org