gpt4 book ai didi

java - 部署的 JNLP 小程序找不到库 : Incompatible magic value 1130458734

转载 作者:行者123 更新时间:2023-11-29 09:06:41 24 4
gpt4 key购买 nike

我正在尝试使用 JNLP 部署我的小程序.我试过使用 Eclipse Run Jetty Run插件,它工作正常。但现在在真正的网络服务器上部署后,我真的被困住了。

我的 jnlp 文件草图是这样的(我已经编辑了一些名字)。

<?xml version="1.0" encoding="UTF-8"?>
<jnlp spec="1.0+" href="MyApplet.jnlp">
<information>
<title>MyApplet</title>
<vendor>Me</vendor>
<offline-allowed/>
</information>
<security>
<j2ee-application-client-permissions/>
</security>
<resources>
<!-- Application Resources -->
<j2se version="1.6+" href="http://java.sun.com/products/autodl/j2se"/>
<jar href="applet.jar" part="true" main="true"/>
<jar href="log4j-1.2.16.jar" part="true"/>
<jar href="slf4j-api-1.6.1.jar" part="true"/>
<jar href="slf4j-log4j12-1.6.1.jar" part="true"/>
</resources>
<!-- Generate values dynamically -->
<applet-desc main-class="org.project.applet.AppletMain" name="MyApplet" width="1600" height="860"/>
</jnlp>

我将库保存在与 applet.jar 相同的文件夹中.

关于 applet.jar 中的 list 文件我不确定,我尝试了很多选项,比如指定库,或者只是 .目前在 Ant 脚本中如下所示

Java applet jnlp + libraries

<manifest>
<attribute name="Class-Path" value="."/>
<attribute name="Rsrc-Class-Path" value="./"/>
</manifest>

所有 jar 都已签名,这是我从控制台日志中得到的:

basic: Applet loaded.
basic: Applet resized and added to parent container
basic: PERF: AppletExecutionRunnable - applet.init() BEGIN ; jvmLaunch dt 134206 us, pluginInit dt 7621660339 us, TotalTime: 7621794545 us
network: Cache entry not found [url: http://mydomain.com/play/, version: null]
network: Cache entry not found [url: http://mydomain.com/play/org/apache/log4j/Logger.class, version: null]
network: Connecting http://mydomain.com/play/org/apache/log4j/Logger.class with proxy=DIRECT
network: Connecting http://mydomain.com/play/org/apache/log4j/Logger.class with cookie "PHPSESSID=fe5gv8p4hp013r6i9p5aqjska5"
network: Connecting http://mydomain.com:80/ with proxy=DIRECT
network: Connecting http://mydomain.com/play/org/apache/log4j/Logger.class with cookie "PHPSESSID=fe5gv8p4hp013r6i9p5aqjska5"
basic: JNLP2ClassLoader.findClass: org.apache.log4j.Logger: try again ..
network: Cache entry not found [url: http://mydomain.com/play/org/apache/log4j/Logger.class, version: null]
network: Connecting http://mydomain.com/play/org/apache/log4j/Logger.class with proxy=DIRECT
network: Connecting http://mydomain.com/play/org/apache/log4j/Logger.class with cookie "PHPSESSID=fe5gv8p4hp013r6i9p5aqjska5"
basic: Dialog type is not candidate for embedding
basic: JNLP2ClassLoader.getPermissions() ..
network: Cache entry not found [url: http://mydomain.com/play/org/apache/log4j/Logger.class, version: null]
security: JAVAWS AppPolicy Permission requested for: http://mydomain.com/play/org/apache/log4j/Logger.class
basic: JNLP2ClassLoader.getPermissions() X
java.lang.ClassFormatError: Incompatible magic value 1130458734 in class file org/apache/log4j/Logger
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 sun.reflect.GeneratedMethodAccessor7.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.defineClassHelper(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.access$100(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader$2.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at sun.plugin2.applet.Plugin2ClassLoader.findClassHelper(Unknown Source)
at sun.plugin2.applet.JNLP2ClassLoader.findClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at org.project.applet.AppletMain.init(AppletMain.java:32)
at com.sun.deploy.uitoolkit.impl.awt.AWTAppletAdapter.init(Unknown Source)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
security: Reset deny session certificate store

第32行是

Logger.getRootLogger().setLevel(Level.OFF);

它是小程序中的第一个类,应该从外部库加载。

所有 jar、html 和 jnlps 都在 http://mydomain.com/play/ 中然后我访问小程序 http://mydomain.com/play/applet.html

来自 Incompatible magic value 1008813135我了解到 1130458734表示 Cann我真的得到了Cannot find block '__global__'如果访问http://mydomain.com/play/org/apache/log4j/Logger.class .

但我不明白为什么在 jar 中搜索类会失败,以及为什么它会尝试访问 http://mydomain.com/play/org/apache/log4j/Logger.class服务器上永远不存在。

编辑:

我的 html 文件来自 Oracle 教程:

<html>
<head>
<title>MyApplet</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<script src="http://www.java.com/js/deployJava.js"></script>
</head>
<body>
<script>
var attributes = {code:'org.project.applet.AppletMain', width:1600, height:860} ;
var parameters = {jnlp_href: 'MyApplet.jnlp'} ;
deployJava.runApplet(attributes, parameters, '1.6');
</script>
</body>
</html>

最佳答案

彼得劳瑞:

I assume the URL in the class path of applet and since the web server returns a message rather than some HTTP File Not Found status code it thinks it has a class it can use.

猜对了!对于任何未找到的资源,网络服务器并未在 header 中返回 404 错误,它仅返回一些文本。因此 Java 将其解释为好像已找到资源,但未能尝试将其作为 Java 类加载。

关于java - 部署的 JNLP 小程序找不到库 : Incompatible magic value 1130458734,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14660563/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com