2

I have a Jar file that needs to be installed as a windows service. I'm using Apache commons daemon procrun.

Though the service appears in the Services tab in task manager its not running. Its in stopped state and attempting to start it seems not working.

*In commons daemons logs I noticed that it cannot load the main class which is the "AgentApp".

I installed 32bit jre too.

Mentioned here under the log file contents.

imageprocagent stderr:

2015-01-07 15:47:47 Commons Daemon procrun stderr initialized
java.lang.NoClassDefFoundError: org/apache/commons/daemon/Daemon
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(Unknown Source)
    at java.security.SecureClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.access$100(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.daemon.Daemon
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    ... 12 more
Exception in thread "main" 

crawford-daemon:

[2015-01-07 15:47:47] [info]  Commons Daemon procrun (1.0.10.0 32-bit) started
[2015-01-07 15:47:47] [info]  Running 'ImageProcAgent' Service...
[2015-01-07 15:47:47] [info]  Starting service...
[2015-01-07 15:47:49] [error] FindClass com/fx358/fx9/agent/AgentApp failed
[2015-01-07 15:47:49] [error] Failed to start Java
[2015-01-07 15:47:49] [error] ServiceStart returned 4
[2015-01-07 15:47:49] [info]  Run service finished.
[2015-01-07 15:47:49] [info]  Commons Daemon procrun finished
  • `[2015-01-07 15:47:49] [error] FindClass com/fx358/fx9/agent/AgentApp failed

Here is the script I'm using to install the agent:

SET DISPLAYNAME="ImageProcAgent"
SET DESCRIPTION="FX9 image processing Agent"
SET LOGPATH="C:\FX9\logs\ImageProcAgent"
SET STARTPATH=
SET JVMLOCATION="C:\Program Files (x86)\Java\jre7\bin\client\jvm.dll"
SET CUSTCLASSPATH="C:\FX9\release\ImageProcAgent\GenericAgent_jar\GenericAgent.jar;C:\FX9\release\ImageProcAgent\GenericAgent_jar\ImageProcAgent.jar;."
ECHO ON
ImageProcAgent.exe //IS//ImageProcAgent --DisplayName=%DISPLAYNAME% --Description=%DESCRIPTION% --Startup=auto --LogPath=%LOGPATH% --LogLevel=INFO --LogPrefix=crawford-daemon --StdOutput=auto --StdError=auto --StartPath=%STARTPATH% --StartClass=com.fx358.fx9.agent.AgentApp --StartMethod=main --StartParams=start --StartMode=jvm --StopPath=%% --StopClass=com.fx358.fx9.agent.AgentApp  --StopMethod=stop  --StopMode=jvm --Jvm=%JVMLOCATION% --Classpath=%CUSTCLASSPATH% --JvmOptions=-Xmx512M  ++JvmOptions=-Djava.util.logging.config.file=logging.properties

` Can someone point me out what I'm doing wrong? thanks in advance.

4

3 に答える 3

0

クラスパス宣言には、jar エントリが 2 つしかありません。

CUSTCLASSPATH="C:\FX9\release\ImageProcAgent\GenericAgent_jar\GenericAgent.jar;C:\FX9\release\ImageProcAgent\GenericAgent_jar\ImageProcAgent.jar;."

アプリケーションのビルドは、すべてのコンパイルとランタイムの依存関係を含む fat-jar としてビルドされていますか? それ以外の場合は、サービスの実行時に必要な各 JAR をクラスパスに追加する必要があります。例えば:

CUSTCLASSPATH="C:\FX9\release\ImageProcAgent\GenericAgent_jar\GenericAgent.jar;C:\FX9\release\ImageProcAgent\GenericAgent_jar\ImageProcAgent.jar;C:\FX9\release\ImageProcAgent\GenericAgent_jar\lib\commons-daemon-1.0.15.jar;<PROBABLY_MORE_JARS_NEED_TO_BE_ADDED_HERE>;."

さらに.、サービスのクラスパスで使用することは、おそらく良い考えではありません。そこでは完全修飾パスのみを使用する必要があります。そうしないと、Windows によってサービスが実行される場所に依存することになります。

于 2016-02-05T12:01:28.060 に答える
0

同じエラーが発生しました。結局のところ、私は Commons-logging と log4j を Service クラス内で直接使用しようとしていました。しかし、log4j が適切に初期化されていなかったため、ロード エラーが発生していました。

すべての log4j を削除し、単純な System.out.* に置き換えたところ、機能しました。

于 2015-06-05T23:15:07.780 に答える