2

我们在 Windows 2012 R2 服务器上运行 Oracle 独立 OC4J J2EE Web 应用程序服务器。启动oc4j服务器的命令行如下:

`java -jar %J2EE_HOME%\oc4j.jar`

J2EE_HOME 系统范围的环境变量已正确设置,我们可以从命令行启动 Web 服务器。

System Environment Variables:
`JAVA_HOME=C:\Progra~1\Java\jdk1.7.0_65\jre\bin`
`J2EE_HOME=E:\OC4J\j2ee\home`

现在我们需要将 OC4J 服务器作为 Windows 服务运行。为此,我们下载了 WinRun4J 开源应用程序。按照 winrun4j 的指示,我执行了以下操作:

1) Created a new folder:  E:\Custom_Apps
2) Copied the WinRun4J64 executable to the new folder
3) Renamed the WinRun4J64 executable to OC4J_WebServer
4) Copied the WinRun4J icon to the new folder and renamed it OC4J_WebServer
5) Created an initialization file in the E:\Custom_Apps folder named OC4J_WebServer.

初始化文件包含以下几行:

>working.directory=E:\Custom_Apps\working\
>vm.location=C:\Program Files\Java\jdk1.7.0_65\jre\bin\server\jvm.dll
>service.class=%J2EE_HOME%\oc4j.jar
>service.id=OC4JWebServer
>service.name=WinRun4J_OC4J_Service
>service.description=the OC4J Web Server service launched using winRun4J64.
>classpath.1=%JAVA_HOME%\*.jar
>classpath.2=e:\OC4J\*.jar
>classpath.3=e:\Software\WinRun4J\winrun4j\
>vmarg.1=-Xdebug
>vmarg.2=-Xnoagent
>vmarg.3=-Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n

我在命令行执行了以下命令,将图标和初始化文件绑定到可执行文件:

RCEDIT64.exe /I OC4J_WebServer.exe OC4J_WebServer.ico RCEDIT64.exe /N OC4J_WebServer.exe OC4J_WebServer.ini

最后,我运行了OC4J_WebServer.exe --WinRun4J64:RegisterService创建 Windows 服务的命令。我收到以下错误:

>E:\Custom_Apps[info] Module Name: E:\Custom_Apps\OC4J_WebServer.exe
>[info] Module INI:  E:\Custom_Apps\OC4J_WebServer.ini
>[info] Module Dir:  E:\Custom_Apps
>[info] INI Dir: E:\Custom_Apps
>[info] Working directory set to: E:\Custom_Apps\working
>[info] Configured vm.location:  C:\Program Files\Java\jdk1.7.0_65\jre\bin\server\jvm.dll
>[info] Found VM:  C:\Program Files\Java\jdk1.7.0_65\jre\bin\server\jvm.dll
>[info] Expanding Classpath:  C:\Progra~1\Java\jdk1.7.0_65\jre\bin\*.jar
>[info] Expanding Classpath:  E:\Software\WinRun4J\winrun4j\
>[info] Generated Classpath:
>[info] VM Args:
>[info] vmarg.0=-Xdebugvmarg.2=-Xnoagent
>vmarg.3=-Xrunjdwp:transport=dt_socket,address=8787,
>server=y,suspend=n
>[info] vmarg.1=-Djava.class.path=
>[info] Registering natives for Native class
> [warn] Could not find Native class
>  [err] Could not find service class
>  [err] Failed to initialize service: 1
    `java.lang.NoClassDefFoundError: e:\OC4J\j2ee\home\oc4j/jar
    `Caused by: java.lang.ClassNotFoundException: e:\OC4J\j2ee\home\oc4j.jar
    `at java.net.URLClassLooader$1.run(URLClassLoader.java:366)
    `at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    `at java.security.AccessController.doPrivileged(Native method)
    `at java.net.URLClassLoader.findclass(URLClassLoader.java:354)
    `at java.lang.ClassLoader.loadclass(ClassLoader.java:425)
    `at sun.misc.Launcher$AppClassLoader.loadclass(Launcher.java:308)
    `at java.lang.ClassLoader.loadclass(ClassLoader.java:358)

我没有声称自己是 Java 开发人员,并希望有人能帮助我。我想做的就是能够从java -jar %J2EE_HOME%\oc4j.jar命令中创建一个 Windows 服务。

对于如何设置它,我将不胜感激。

4

0 回答 0