jnlp log4j ClassNotFoundException

时间:2016-04-17 08:30:43

标签: java log4j java-web-start classnotfoundexception jnlp

我尝试使用Java Web Start部署Java应用程序,但不断收到错误。当我从Eclipse或命令行运行它时,应用程序正常工作。我的应用程序使用我在单独的jnlp文件中定义的一些第三方库。如果您有任何想法或建议,请分享。 我使用的是Tomcat 7.0,在ROOT文件夹中复制了jnlp文件,所有的lib都在ROOT中的单独的lib文件夹中。

这是我的主要jnlp文件 - main.jnlp:

<?xml version="1.0" encoding="UTF-8"?>
<jnlp spec="1.7+" codebase="http://localhost:8080/" href="main.jnlp">
    <information>
          <title>Sample</title>
          <vendor>None</vendor>
     </information>

<security>
    <all-permissions/>
</security>

<resources>
    <extension name="other-libs" href="other-libs.jnlp"/>
    <extension name="log4j" href="log4j.jnlp"/>
    <jar href="lib/sample.jar" main="true"/>
    <j2se version="1.7+" java-vm-args="-ea"  href="http://java.sun.com/products/autodl/j2se"/>
</resources>

 <application-desc main-class="org.slt.sample.SampleFile">
    <argument>C:/sample.pdf</argument>
    <argument>sample.pdf</argument>
  </application-desc>

其他-libs.jnlp:

<?xml version="1.0" encoding="UTF-8"?>
<jnlp spec="1.7+" codebase="http://localhost:8080/" href="other-libs.jnlp">
    <information>
          <title>Others</title>
          <vendor>None</vendor>
     </information>

<security>
    <all-permissions/>
</security>

<resources>
    <jar href="lib/tflander-pdfbox-2.0.2.jar"/>
    <jar href="lib/log4j-1.2.17.jar" download="eager"/>
    <jar href="lib/slf4j-api-1.7.7.jar" download="eager"/>
    <jar href="lib/slf4j-log4j12-1.7.7.jar" download="eager"/>
</resources>
<component-desc/>

这里是log4j.jnlp:

<?xml version="1.0" encoding="UTF-8"?>
<jnlp spec="1.7+" codebase="http://localhost:8080/" href="log4j.jnlp">
    <information>
          <title>Log</title>
          <vendor>None</vendor>
     </information>

<security>
    <all-permissions/>
</security>

<resources>
    <property name="log4j.configuration" value="log4j.xml" />
</resources>
<component-desc/>

这是启动main.jnlp时出现的错误:

java.lang.NoClassDefFoundError: org/apache/log4j/Logger
at org.tflander.org.apache.commons.logging.Log.<clinit>(Unknown Source)
at org.tflander.org.apache.commons.logging.LogFactory.getLog(Unknown Source)
at org.tflander.org.apache.pdfbox.pdmodel.PDDocument.<clinit>(Unknown Source)
at org.tflander.pdf.PdfDocument.<init>(PdfDocument.java:70)
at org.slt.sample.SampleFile.main(SampleFile.java:78)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.sun.javaws.Launcher.executeApplication(Unknown Source)
at com.sun.javaws.Launcher.executeMainClass(Unknown Source)
at com.sun.javaws.Launcher.doLaunchApp(Unknown Source)
at com.sun.javaws.Launcher.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Logger
    at java.net.URLClassLoader.findClass(Unknown Source)
    at com.sun.jnlp.JNLPClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    ... 14 more
org.tflander.pdf.PdfException: Reason 11: org/apache/log4j/Logger
    at org.tflander.pdf.PdfException.A(PdfException.java:60)
    at org.tflander.pdf.PdfDocument.<init>(PdfDocument.java:90)
    at org.slt.sample.SampleFile.main(SampleFile.java:78)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at com.sun.javaws.Launcher.executeApplication(Unknown Source)
    at com.sun.javaws.Launcher.executeMainClass(Unknown Source)
    at com.sun.javaws.Launcher.doLaunchApp(Unknown Source)
    at com.sun.javaws.Launcher.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NoClassDefFoundError: org/apache/log4j/Logger
    at org.tflander.org.apache.commons.logging.Log.<clinit>(Unknown Source)
    at org.tflander.org.apache.commons.logging.LogFactory.getLog(Unknown Source)
    at org.tflander.org.apache.pdfbox.pdmodel.PDDocument.<clinit>(Unknown Source)
    at org.tflander.pdf.PdfDocument.<init>(PdfDocument.java:70)
    ... 10 more
Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Logger
    at java.net.URLClassLoader.findClass(Unknown Source)
    at com.sun.jnlp.JNLPClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    ... 14 more
Finished

0 个答案:

没有答案