简体   繁体   English

类文件中的魔术值21877456不兼容

[英]Incompatible magic value 21877456 in class file

Im trying to use java applet on my web page. 我试图在我的网页上使用Java applet。 I try/search lots of thing but no chance. 我尝试/搜索了很多东西,但没有机会。 So here is the case. 情况就是这样。

My applet code is simple in app.html : 我的applet代码在app.html中很简单:

    <applet codebase="." archive="applet.jar" code="de.escape.quincunx.dxf.apViewer" width="640" height="480" name="TEST">
    <param name="file"               value="40.dxf">
    <param name="framed"             value="false">
    <param name="frameWidth"         value="800">
    <param name="frameHeight"        value="600">
    </applet>

This html file is working when i directly open in browser. 当我直接在浏览器中打开时,此html文件正在工作。 Its working when i serve it with apache but its not working and give error "Incompatible magic value 21877456 in class file" when i try to serve with IIS. 当我使用apache服务时它会工作,但无法正常工作,当我尝试使用IIS时会给出错误“类文件中的不兼容魔术值21877456”。 In apache i try php and html, both is working. 在Apache中,我尝试使用PHP和HTML,两者都在工作。

Is there any special configuration need on IIS when i try to serve applet? 当我尝试提供applet时,IIS是否需要任何特殊的配置?

Thank you for your answers. 谢谢您的回答。

I think IIS is not serving the right file for a .class, probably it is returning a 404 error or something similar, since it cannot find the file. 我认为IIS无法为.class提供正确的文件,可能是因为它找不到文件而返回404错误或类似的错误。

That error means that Java was expecting a .class file, all class files start with 0xCAFEBABE, which is a magic number with which Java can check that the file it is receiving is in fact a class file. 该错误意味着Java期望使用.class文件,所有类文件均以0xCAFEBABE开头,这是一个神奇的数字,Java可以使用它检查接收到的文件是否实际上是类文件。 In your case, however, the file returned by IIS is not a class file, it does not start with 0xCAFEBABE, and Java is unable to parse it. 但是,就您而言,IIS返回的文件不是类文件,它不是以0xCAFEBABE开头,并且Java无法对其进行解析。

The most common reason for it is that the web server is not able to serve the file, often because of a 404 error. 最常见的原因是Web服务器通常由于404错误而无法提供文件。

You should check what happens under the hood, search in IIS logs for requests of .class files, or use a tool (maybe even firebug) to see what is returned to the browser. 您应该检查实际情况,在IIS日志中搜索.class文件的请求,或者使用工具(甚至是Firebug)查看返回给浏览器的内容。

Finally i found a solution. 终于我找到了解决方案。 Actually its not the exact solution but thank you for your answer Simone Gianni. 实际上,这不是确切的解决方案,但感谢您的回答西蒙娜·吉安尼(Simone Gianni)。 His answer lead me to deeply search in IIS access logs and compare them with APACHE access logs. 他的回答使我深入搜索IIS访问日志,并将它们与APACHE访问日志进行比较。 And yes, both was same and looks like couple of classes are not in place in the JAR file. 是的,两者都是相同的,并且看起来JAR文件中没有几个类。 So apVPORT.class is not in the jar file and developer who wrote this applet leave the calls for those classes in the other part of applet even he is not using them. 因此apVPORT.class不在jar文件中,编写此applet的开发人员即使不在使用中,也将对这些类的调用留在applet的另一部分中。

If someone can answer the reason why apache don't send any information or "its okey" information to java and continue loading rest of the applet even it see the 404 for apVPORT.class but IIS send 404 to java, this will be the final answer for this question. 如果有人可以回答apache不向Java发送任何信息或“其正常”信息并继续加载小程序的原因,即使它看到apVPORT.class的404信息,但IIS却向java发送404信息,这将是最终的回答这个问题。

Incompatible magic value 21877456 in class file : I found that this error comes when page is not able to reach /read the jar file. 类文件中的魔术值21877456不兼容:我发现当页面无法访问/读取jar文件时出现此错误。

in aspx page - 在aspx页面中-

   <applet code="FileAccess.class"
   archive="../applet/SignFileAccessApplet.jar" width="325" height="325">  
   </applet>

in archive check whether url is proper or not by using "pickurl" option provided by intellisense of Visual Studio. 在存档中,使用Visual Studio intellisense提供的“ pickurl”选项检查url是否正确。 class file path in jar file need to be given in code attribute. jar文件中的class文件路径需要在code属性中给出。

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

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