Link to home
Start Free TrialLog in
Avatar of Sarge516
Sarge516

asked on

jsvc.exec error: Cannot found Daemon Loader "version" entry point

OS Centos 6
commons-daemon-1.0.7.jar

I'm trying to use jsvc for the first time to help auto run a java program.  My program has the required methods (start(), etc. listed in the jsvc home web page.
I run as -debug and get the error listed in the title.

This is not related to running Tomcat, although I do have tomcat 6 installed and running. My classpath is auto created based on what jars are in my dir so I have not forced any jar ordering yet.


My Script is something like this :

JAVA_HOME=/usr/lib/jvm/jre-1.6.0-openjdk.x86_64
export JAVA_HOME
appdir=/opt/YOYO

myJars=`find $appdir *.jar`
for i in $myJars; do
    echo $i
    clp=$clp:$i
done

echo $clp

/usr/bin/jsvc  -cp $clp -version -debug  org.yoyol.v01_02.Server.Run.RunMe

So my question is what is needed to fix the missing "version" entry point ?

Thanks,
Sarge
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

>>myJars=`find $appdir *.jar`

looks suspect. Try the following and if that doesn't work, pass the -debug argument to jsvc
myJars=`find $appdir -type f -name '*.jar'`

Open in new window

Avatar of Sarge516
Sarge516

ASKER

That certainly cleans up the classpath which is good. However, I still get the same error.

To confirm the classpath is correct, I can replacing the jsvs line with the one below and it  works - but interactively ..

java -cp $clp -jar MyApp.jar
Try putting in -debug and see what happens
The daemon classes themselves have to be in the classpath too afaik
Here is the result of the debug. The commons-daemon is in the classpath. The Daemon load shows found.

05/11/2011 14:07:00 6358 jsvc.exec debug: +-- DUMPING JAVA VM CREATION ARGUMENTS -----------------
05/11/2011 14:07:00 6358 jsvc.exec debug: | Version:                       10004
05/11/2011 14:07:00 6358 jsvc.exec debug: | Ignore Unrecognized Arguments: False
05/11/2011 14:07:00 6358 jsvc.exec debug: | Extra options:                 2
05/11/2011 14:07:00 6358 jsvc.exec debug: |   "-Djava.class.path=:/opt/YOYO/commons-lang-2.1.jar:/opt/YOYO/mysql-connector-java-5.1.6-bin.jar:/opt/YOYO/YOYOServer.jar:/opt/YOYO/mail.jar:/opt/YOYO/YOYO_Interfaces.jar:/opt/YOYO/commons-daemon-1.0.7.jar:-0.91.jar:/opt/YOYO/log4j-1.2.14.jar
05/11/2011 14:07:00 6358 jsvc.exec debug: +-------------------------------------------------------
05/11/2011 14:07:00 6358 jsvc.exec debug: Java VM created successfully
05/11/2011 14:07:00 6358 jsvc.exec debug: Class org/apache/commons/daemon/support/DaemonLoader found
05/11/2011 14:07:00 6358 jsvc.exec debug: Native methods registered
05/11/2011 14:07:00 6358 jsvc.exec error: Cannot found Daemon Loader "version" entry point
05/11/2011 14:07:00 6357 jsvc.exec error: Service exit with a return value of 255
Also, MyApp.jar is in the classpath. I'm trying to simply what I'm posting.
Your classpath is somewhat mangled. Look at the last entry


/opt/YOYO/commons-lang-2.1.jar
/opt/YOYO/mysql-connector-java-5.1.6-bin.jar
/opt/YOYO/YOYOServer.jar
/opt/YOYO/mail.jar
/opt/YOYO/YOYO_Interfaces.jar
/opt/YOYO/commons-daemon-1.0.7.jar
-0.91.jar

Open in new window

I missed the last actual entry out accidentally but at least it draws attention to a problem
In fact you can simplify that with the following (the quotes are essential)
/usr/bin/jsvc  -cp '/opt/YOYO/*.jar' -version -debug  org.yoyol.v01_02.Server.Run.RunMe

Open in new window

Team,

      I appreciate the help but the mangled classpath was a cut/paste problem that I did. The classpath seems to be OK.  I've been trying many things now but still get the issue. Here is the last of the debug log.

06/11/2011 14:40:15 10625 jsvc.exec debug: +-- DUMPING JAVA HOME STRUCTURE ------------------------
06/11/2011 14:40:15 10625 jsvc.exec debug: | Java Home:       "/usr/lib/jvm/jre-1.6.0-openjdk.x86_64"
06/11/2011 14:40:15 10625 jsvc.exec debug: | Java VM Config.: "/usr/lib/jvm/jre-1.6.0-openjdk.x86_64/lib/amd64/jvm.cfg"
06/11/2011 14:40:15 10625 jsvc.exec debug: | Found JVMs:      1
06/11/2011 14:40:15 10625 jsvc.exec debug: | JVM Name:        "server"
06/11/2011 14:40:15 10625 jsvc.exec debug: |                  "/usr/lib/jvm/jre-1.6.0-openjdk.x86_64/lib/amd64/server/libjvm.so"
06/11/2011 14:40:15 10625 jsvc.exec debug: +-------------------------------------------------------
06/11/2011 14:40:15 10625 jsvc.exec debug: Running w/ LD_LIBRARY_PATH=/usr/lib/jvm/jre-1.6.0-openjdk.x86_64/lib/amd64/server:/usr/lib/jvm/jre-1.6.0-openjdk.x86_64/lib/amd64
06/11/2011 14:40:15 10625 jsvc.exec debug: redirecting stdout to /dev/null and stderr to /dev/null
06/11/2011 14:40:15 10626 jsvc.exec debug: Using default JVM in /usr/lib/jvm/jre-1.6.0-openjdk.x86_64/lib/amd64/server/libjvm.so
06/11/2011 14:40:15 10626 jsvc.exec debug: Attemtping to load library /usr/lib/jvm/jre-1.6.0-openjdk.x86_64/lib/amd64/server/libjvm.so
06/11/2011 14:40:15 10626 jsvc.exec debug: JVM library /usr/lib/jvm/jre-1.6.0-openjdk.x86_64/lib/amd64/server/libjvm.so loaded
06/11/2011 14:40:15 10626 jsvc.exec debug: JVM library entry point found (0x244E3C90)
06/11/2011 14:40:15 10626 jsvc.exec debug: +-- DUMPING JAVA VM CREATION ARGUMENTS -----------------
06/11/2011 14:40:15 10626 jsvc.exec debug: | Version:                       10004
06/11/2011 14:40:15 10626 jsvc.exec debug: | Ignore Unrecognized Arguments: False
06/11/2011 14:40:15 10626 jsvc.exec debug: | Extra options:                 2
06/11/2011 14:40:15 10626 jsvc.exec debug: |   "-Djava.class.path=:/opt/YOYO/commons-lang-2.1.jar:/opt/YOYO/mysql-connector-java-5.1.6-bin.jar:/opt/YOYO/YOYOServer.jar:/opt/YOYO/mail.jar:/opt/YOYO/activation.jar:/opt/YOYO/YOYO_Interfaces.jar:/opt/YOYO/commons-daemon-1.0.7.jar:/opt/YOYO/log4j-1.2.14.jar:/opt/YOYO/Mesp.jar" (0x00000000)
06/11/2011 14:40:15 10626 jsvc.exec debug: +-------------------------------------------------------
06/11/2011 14:40:15 10626 jsvc.exec debug: Java VM created successfully
06/11/2011 14:40:15 10626 jsvc.exec debug: Class org/apache/commons/daemon/support/DaemonLoader found
06/11/2011 14:40:15 10626 jsvc.exec debug: Native methods registered
06/11/2011 14:40:15 10626 jsvc.exec error: Cannot found Daemon Loader "version" entry point
06/11/2011 14:40:15 10625 jsvc.exec error: Service exit with a return value of 255

Not sure why DaemonLoader is found but missing "version entry point".  

Any help with the entry point issue would be appreciated.
Ok, I'm scaled down it way and I still get the Cannot found Daemon Loader "version" entry point

Test code is attached. Is it complete ?

 I've tested against the commons-deamon-1.0.5 and 1.0.7 jar versions.

I've change my JRE to be the Oracle Linux instead of Icetea.

What am I missing ?  Does anyone else run jsvc with success ?

Thanks.


Error is now

08/11/2011 12:33:00 3731 jsvc.exec debug: Using default JVM in /opt/java/jre1.6.0_29/lib/amd64/server/libjvm.so
08/11/2011 12:33:00 3731 jsvc.exec debug: Attemtping to load library /opt/java/jre1.6.0_29/lib/amd64/server/libjvm.so
08/11/2011 12:33:00 3731 jsvc.exec debug: JVM library /opt/java/jre1.6.0_29/lib/amd64/server/libjvm.so loaded
08/11/2011 12:33:00 3731 jsvc.exec debug: JVM library entry point found (0x8C11E570)
08/11/2011 12:33:00 3731 jsvc.exec debug: +-- DUMPING JAVA VM CREATION ARGUMENTS -----------------
08/11/2011 12:33:00 3731 jsvc.exec debug: | Version:                       10004
08/11/2011 12:33:00 3731 jsvc.exec debug: | Ignore Unrecognized Arguments: False
08/11/2011 12:33:00 3731 jsvc.exec debug: | Extra options:                 2
08/11/2011 12:33:00 3731 jsvc.exec debug: |   "-Djava.class.path=:/opt/jsvct1/commons-daemon-1.0.5.jar:/opt/jsvct1/testme.jar" (0x00000000)
08/11/2011 12:33:00 3731 jsvc.exec debug: +-------------------------------------------------------
08/11/2011 12:33:00 3731 jsvc.exec debug: Java VM created successfully
08/11/2011 12:33:00 3731 jsvc.exec debug: Class org/apache/commons/daemon/support/DaemonLoader found
08/11/2011 12:33:00 3731 jsvc.exec debug: Native methods registered
08/11/2011 12:33:00 3731 jsvc.exec error: Cannot found Daemon Loader "version" entry point
08/11/2011 12:33:00 3730 jsvc.exec error: Service exit with a return value of 255


package test1;

import org.apache.commons.daemon.Daemon;
import org.apache.commons.daemon.DaemonContext;
import org.apache.commons.daemon.DaemonInitException;

public class RunDaemon implements Daemon {

	RunMe rm = null;

	@Override
	public void destroy() {
		//rm = null;

	}

	@Override
	public void init(DaemonContext arg0) throws DaemonInitException, Exception {
		rm = new RunMe();

	}

	@Override
	public void start() throws Exception {
		rm.myStart();
	}

	@Override
	public void stop() throws Exception {
		rm.myStop();

	}

}

Open in new window

package test1;

import java.util.Date;


public class RunMe {


	boolean stopme = false;
	Date startDate = new Date();
	Date endDate = startDate;
	
	public void myStart() {

		
		startDate = new Date();
		while (false == stopme)
		{
//			System.out.println(new Date());
			try {
				Thread.sleep(1000);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
		endDate = new Date();
		System.out.println("END OF PROGRAM");
	}

	
	public void myStop() {
		System.out.println("MyStop");
		stopme = true;

	}
	
	public void status() {
		System.out.println("Start Date = "+startDate);
		System.out.println("End Date = "+endDate);
		
	}

	

}

Open in new window

I'll give it a try with Sun Java if i can
ASKER CERTIFIED SOLUTION
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
My problem was related to the -version option in the run line. "-version" shows to be a valid option under jsvc but was the reason the code could not start.

The javadoc http://commons.apache.org/daemon/apidocs/index.html refers to the version method, but not much is mentioned.

[root@bmMail001 BMO]# /usr/bin/jsvc --help
Usage: jsvc [-options] class [args...]

Where options include:

    -jvm <JVM name>
        use a specific Java Virtual Machine. Available JVMs:
            'server'
    -cp / -classpath <directories and zip/jar files>
        set search path for service classes and resouces
    -home <directory>
        set the path of your JDK or JRE installation (or set
        the JAVA_HOME environment variable)
    -version
        show the current Java environment version (to check
        correctness of -home and -jvm. Implies -nodetach)
    -help / -?
        show this help page (implies -nodetach)
Anyway i can tell you why  "Cannot found Daemon Loader "version" entry point" happens, but can't explain it. It happens when it can't get that static method via a jni call:

http://svn.apache.org/repos/asf/commons/proper/daemon/trunk/src/native/unix/native/java.c

Apart from having the same problem with using the -version parameter, i can manage to run your code ok with jsvc