简体   繁体   English

Google站点中的Java小程序和“不兼容的幻数”错误

[英]Java applet in Google Sites and the “Incompatible Magic Number” error

I've seen many questions around this topic, but not one which answered my specific situation. 我已经看到许多有关此主题的问题,但没有一个回答我的具体情况。 I've finished writing a Java applet that I want to embed on a Google Sites website. 我已经完成了要嵌入到Google Sites网站中的Java小程序。 I have packed the entire applet in a single .jar file, uploaded it as a general Attachment to the site, and used the CodeWrapper widget to link it into the page, by inserting the proper values for codebase and archive (basically, I picked the download link for the attachment and split it in two: the path for the "codebase", and the file name for the "archive"). 我将整个applet打包到一个.jar文件中,将其作为常规附件上传到该网站,并使用CodeWrapper小部件将其链接到页面,方法是为代码库和归档插入正确的值(基本上,我选择了下载附件的链接,并将其分为两部分:“代码库”的路径和“存档”的文件名)。 However, I get a: 但是,我得到:

Incompatible magic value 1008813135 in class file *my class file*

error when trying to run it. 尝试运行它时出错。 It seems like this number corresponds to ASCII <!DO , thus making many think that it actually stands for the beginning of a XML document, and that this is a 404: file not found error that I'm getting. 似乎此数字对应于ASCII <!DO ,因此使许多人认为它实际上代表XML文档的开头,并且这是我收到的404:找不到文件错误。 I thought this might be related to the structure of Google Sites, and tried uploading the .jar file on my Public Dropbox folder. 我认为这可能与Google协作平台的结构有关,因此尝试将.jar文件上传到我的Public Dropbox文件夹中。 In fact, by performing the same operation as said above (splitting path and filename between "codebase" and "archive") it works perfectly well! 实际上,通过执行与上述相同的操作(在“代码库”和“归档”之间分割路径和文件名),它可以很好地工作! So I am sure that the problem really is Google Sites. 因此,我可以确定问题确实出在Google协作平台上。 For now I will make use of the Dropbox solution, but it's not really something I want to rely on; 现在,我将使用Dropbox解决方案,但这并不是我真正想要依靠的。 I'd feel much better if I could just embed the file inside the site. 如果可以将文件嵌入网站中,我会感觉好多了。 Does anyone have any suggestions with regard to this? 有人对此有任何建议吗?

Hosting .jar files on Google Sites results in a caching effect with googlegroups.com. 在Google协作平台上托管.jar文件会对googlegroups.com产生缓存效果。 I can't say right now why this is, but you can see evidence of it in the Java console if you set the tracing level to 5. 我现在不能说这是为什么 ,但是如果将跟踪级别设置为5,则可以在Java控制台中看到它的证据。

For some applets I have, this poses no problem. 对于我拥有的一些小程序,这没有问题。 However, I encountered security exceptions with getSoundClip that I couldn't figure out in my applet. 但是,我在getSoundClip中遇到了安全异常,我无法在applet中getSoundClip该异常。 It always worked when I hosted it on a site set up by my ISP. 当我将其托管在由ISP设置的站点上时,它始终可以工作。 I noticed the odd googlegroups.com URLs coming from some kind of cache, appearing in the console. 我注意到奇怪的googlegroups.com网址来自某种缓存,出现在控制台中。 Default console settings don't show caching, if I'm not mistaken. 如果我没有记错的话,默认的控制台设置不会显示缓存。

Uploading the .jar file to code.google.com (and setting codebase, etc.) doesn't have any caching (that I can see) and my getSoundClip calls work with no security exceptions. 将.jar文件上传到code.google.com(并设置代码库等)没有任何缓存(我可以看到),并且getSoundClip调用在没有安全异常的情况下也可以正常工作。

In the following extract from the console of an applet that works for me on Google Sites, you can see an example of a URL on sites.google.com and its corresponding cache in bab6424e-a-62cb3a1a-s-sites.googlegroups.com . 在以下适用于我在Google协作平台上的小程序的控制台的摘录中,您可以在sites.google.com上看到URL的示例,以及在bab6424e-a-62cb3a1a-s-sites.googlegroups.com中对应的缓存。 Note: I replaced the true path in the URLs with X/Y and the jarfile with Z.jar 注意:我将网址中的真实路径替换为X/Y ,将jarfile替换为Z.jar

...
basic: Added progress listener: sun.plugin.util.ProgressMonitorAdapter@bc71bd
basic: Plugin2ClassLoader.addURL parent called for https://sites.google.com/site/X/Y/Z.jar
security: Accessing keys and certificate in Mozilla user profile: null
security: JSS is not configured
security: Blacklist revocation check is enabled
security: Trusted libraries list check is enabled
cache: Adding MemoryCache entry: https://bab6424e-a-62cb3a1a-s-sites.googlegroups.com/site/X/Y/Z.jar?attachauth=ANoY7cpwDuO2zcBBImZ-rJvrPReeiY0EyL874NTY538mtqnsfd-A6p4uVsSKbeO0jcW336bRzkmqoJSiKk3MgG6dxISu6iXodhaXlmyxEaZ2sZ8sSkEkABSMu89vHzugUVfF2m31qp3N5RFe5QSqVMoY2vMjf7HAjLVmObNEmp7J83khcV1jepHpudfPZXhYeXD89Bv6XbBaePhwoueUZT9ZPEwNvepaKwGIr2IsActrdYOtrjiRScAzyp2dr9EwhnZXXIv6KsKv&attredirects=0
network: Cache entry found [url: https://sites.google.com/site/X/Y/Z.jar, version: null] prevalidated=false/0
cache: Adding MemoryCache entry: https://sites.google.com/site/X/Y/Z.jar
...

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

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