简体   繁体   English

部署的JNLP小程序找不到库:不兼容的魔术值1130458734

[英]Deployed JNLP applet cannot find library: Incompatible magic value 1130458734

I am trying to deploy my applet using JNLP . 我正在尝试使用JNLP部署我的applet。 I have tried using Eclipse Run Jetty Run plugin and it worked okay. 我已经尝试过使用Eclipse Run Jetty Run插件,它工作正常。 But now with deployment at a real web server I am really stuck. 但是现在在真正的Web服务器上进行部署时,我真的很受困扰。

My jnlp file sketch is like this (I hava edited some names). 我的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>

I keep libraries in the same folder with applet.jar . 我将库与applet.jar同一文件夹中。

About manifest file in applet.jar I am not sure, I have tried many options, like specifying libraries, or just . 关于applet.jar清单文件,我不确定,我尝试了许多选项,例如指定库或just . Currently it is like below in Ant script 目前它就像下面的Ant脚本中的

Java applet jnlp + libraries Java Applet Jnlp +库

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

All jars are signed and this is what I get from console log: 所有罐子均已签名,这是我从控制台日志中得到的:

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

Line 32 is 第32行是

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

it is first class in applet which should be loaded from external library. 它是applet中的第一类,应该从外部库中加载。

All jars, htmls and jnlps are in http://mydomain.com/play/ and I access applet http://mydomain.com/play/applet.html 所有的jar,html和jnlps都位于http://mydomain.com/play/并且我访问applet http://mydomain.com/play/applet.html

From Incompatible magic value 1008813135 I have learned that 1130458734 means Cann and I really get Cannot find block '__global__' if access http://mydomain.com/play/org/apache/log4j/Logger.class . 从不兼容的魔术值1008813135中,我了解到1130458734含义是,如果访问http://mydomain.com/play/org/apache/log4j/Logger.class1130458734 Cann和我真的会Cannot find block '__global__'

But I don't understand why searching a class in jar fails, and why it tries to access http://mydomain.com/play/org/apache/log4j/Logger.class which never exist on the server. 但是我不明白为什么在jar中搜索类失败,为什么它尝试访问服务器上不存在的http://mydomain.com/play/org/apache/log4j/Logger.class

EDIT: 编辑:

My html file somewhere from Oracle tutorials: 我的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>

Peter Lawrey: 彼得·劳瑞:

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. 我假定该URL位于applet的类路径中,并且由于Web服务器返回消息而不是一些HTTP File Not Found状态代码,因此它认为它具有可以使用的类。

That was a good guess! 那是一个很好的猜测! The webserver didn't not return 404 error in header for any non found resource, it was returning only some text. 对于未找到的资源,Web服务器的标头未返回404错误,它仅返回一些文本。 So Java interpreted it as if resource was found and was failing trying to load it as Java class. 因此,Java将其解释为好像已找到资源,并且尝试将其作为Java类加载失败。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM