我有以下问题:我在 Tomcat 中部署了一个 JNLP 和一个可执行的 JAR 文件。JNLP 文件应该会自动下载 JAR 文件并执行它。JAR 文件经过签名和验证。这完成了(下载部分)。但是当执行JAR主类(在JNLP文件中指定)时,出现了一个问题:执行了部分主类代码。之后,当它尝试加载一个声明了 static final org.apache.log4j.Logger 实例的类时,它会说一个错误。
下面是 JNLP 文件的代表部分、代码和错误。
JNLP
<?xml version='1.0' encoding='UTF-8'?>
<jnlp spec="1.5+" codebase="http://localhost:8080/examples" href="DemoInstaller.jnlp" download="eager" main="true">
<information>
<title>Demo Installer</title>
<vendor>Codemart [www.codemart.ro]</vendor>
<homepage>https://sourceforge.net/projects/cminstall/</homepage>
<description>This is a demo installer built using Codemart Installer framework with JavaFX</description>
<description kind="tooltip">Codemart Demo Installer</description>
<offline-allowed />
<shortcut online="true">
<desktop />
</shortcut>
</information>
<security>
<all-permissions />
</security>
<update check="background" />
<resources>
<j2se href="http://java.sun.com/products/autodl/j2se" version="1.6+" />
<jar href="DemoInstaller.jar" main="true" download="eager" />
</resources>
<application-desc main-class="ro.codemart.installer.packer.ant.impl.nestedjar.Main" />
主要类:
public class Main {
public static void main(String[] args) throws Exception {
final Main main = new Main();
//this is the problem class !
Class clazz = Class.forName("WizardRunner");
Method m = clazz.getMethod("main", new Class[]{args.getClass()});
m.invoke(null, new Object[]{args});
...
}
}
问题类:
public class WizardRunner{
private final static Logger log = Logger.getLogger(WizardRunner.class);
...
}
和错误:
log4j:错误找不到 [log4j.dtd]。在搜索中使用了 [sun.misc.Launcher$AppClassLoader@d9f9c3] 类加载器。log4j:ERROR 无法解析 url [jar: http://localhost:8080/examples/DemoJar.jar!/log4j.xml]. java.io.FileNotFoundException:在 com.sun.jnlp.JNLPCachedJarURLConnection.getInputStream(Unknown Source) 的 com.sun.jnlp.JNLPCachedJarURLConnection.connect(Unknown Source) 中找不到 JAR 条目 log4j.dtd .xerces.internal.impl.XMLEntityManager.setupCurrentEntity(Unknown Source) at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.startEntity(Unknown Source) at com.sun.org.apache.xerces.internal.impl .XMLEntityManager.startDTDEntity(Unknown Source) at com.sun.org.apache.xerces.internal.impl.XMLDTDScannerImpl.setInputSource(Unknown Source) at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$DTDDriver.dispatch (未知来源)在 com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$DTDDriver.next(未知来源)在 com.sun.org.apache.xerces.internal.impl。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) log4j:WARN No appenders can be found for logger (巫师跑者)。log4j:WARN 请正确初始化 log4j 系统。lang.Thread.run(Unknown Source) log4j:WARN 找不到记录器(WizardRunner)的附加程序。log4j:WARN 请正确初始化 log4j 系统。lang.Thread.run(Unknown Source) log4j:WARN 找不到记录器(WizardRunner)的附加程序。log4j:WARN 请正确初始化 log4j 系统。
谢谢!