简体   繁体   English

Java 小程序不工作

[英]Java Applet not working

A client noticed that one of our java applets wasn't working anymore.一位客户注意到我们的 java 小程序之一不再工作。 However, we are not able to tell what the problem is.但是,我们无法判断问题所在。

Specs眼镜

The webapp is tiparlo . webapp 是Tiparlo It is used to record and organize spoken language and mainly used at schools to train language and store for evaluation later.它用于记录和组织口语,主要用于学校训练语言和存储以供以后评估。 The app consists of an HTML interface, which is managed by JavaScript.该应用程序包含一个 HTML 接口,由 JavaScript 管理。 The sound playing and recording is done via an in-house developed java applet .声音播放和录音是通过内部开发的java 小程序完成的。 As you can see on the test-page, the applet itself is in a working state.正如您在测试页面上看到的那样,小程序本身位于有效的 state 中。

In tiparlo however, the applet (further called soundrecorder) doesn't have a preloaded sound file.然而,在tiparlo 中,小程序(进一步称为录音机)没有预加载的声音文件。 Since tiparlo consists of multiple sound files, JavaScript tells soundrecorder what file to play.由于tiparlo 包含多个声音文件,JavaScript 告诉录音机播放什么文件。 For instance, if you want foo.ogg to be played, javascript tells soundrecorder to play http://url/path/foo.ogg .例如,如果你想播放 foo.ogg , javascript 告诉录音机播放http://url/path/foo.ogg

This worked for some years now but not anymore.这已经工作了几年,但不再有效了。

Bugtracking错误跟踪

The problem is that it does work under certain conditions.问题是它在某些条件下确实有效。 For instance, it works on our local dev-machines, and on our public test-env.例如,它适用于我们的本地开发机器和我们的公共测试环境。 It just ceased to work for our clients.它只是停止为我们的客户工作。

Working example: http://test.s2.olefa.com/cgi-bin/apps/tiparlo?projectid=3&mode=viewer工作示例: http://test.s2.olefa.com/cgi-bin/apps/tiparlo?projectid=3&mode=viewer
Non-working example: http://www.ecoles-dudelange.lu/cgi-bin/apps/tiparlo?projectid=1594&mode=viewer非工作示例: http://www.ecoles-dudelange.lu/cgi-bin/apps/tiparlo?projectid=1594&mode=viewer

Some useful facts:一些有用的事实:

  • both examples are running on the same server两个示例都在同一台服务器上运行

  • the java applet, the js code, the html parser and the source code are shared resources. java 小程序、js 代码、html 解析器和源代码是共享资源。 Hence, both examples are running the exact same code因此,两个示例都运行完全相同的代码

  • the relevant files to the problem are: soundrecorder.js and jrecord.jar.问题的相关文件是:soundrecorder.js 和 jrecord.jar。 The play command is in soundrecorder.js:line 112 play命令在 soundrecorder.js:line 112

What we know so far到目前为止我们所知道的

  • Browsers react differently to the non-working example.浏览器对非工作示例的反应不同。 Safari/Mac plays everything right. Safari/Mac 一切正常。 Safari/Win however freezes on play.然而,Safari/Win 在播放时冻结。 Firefox 4 doesn't play anything at all. Firefox 4 根本不播放任何东西。 Firefox 3.5/Mac does everything right again. Firefox 3.5/Mac 一切正常。 However Firefox3.5/Win doesn't play anything at all.然而 Firefox3.5/Win 根本不播放任何东西。 IE9 has the same problem. IE9 也有同样的问题。 Same goes for Chrome. Chrome 也是如此。 Opera crashes outright and needs to be restarted. Opera 彻底崩溃,需要重新启动。 We haven't yet found a browser on linux that works on the non-working example.我们还没有在 linux 上找到适用于非工作示例的浏览器。 To clarify: the working example works with all browsers on all platforms, except for Safari/Win (meh).澄清一下:工作示例适用于所有平台上的所有浏览器,Safari/Win (meh) 除外。 UPDATE: It depends on the java version.更新:这取决于 java 版本。 With java 6.20, all the non-working example works on all browsers.使用 java 6.20,所有非工作示例都适用于所有浏览器。 With java 6.24, only the working example works.对于 java 6.24,只有工作示例有效。

  • We tried using the alternative server-url for our non-working example (webX.sX.olefa.com), which is similar to the working example.我们尝试为我们的非工作示例 (webX.sX.olefa.com) 使用替代服务器 URL,这与工作示例类似。 This attempt failed.这次尝试失败了。

  • We tried using relative paths for soundrecorder (eg /path/foo.ogg).我们尝试使用录音机的相对路径(例如 /path/foo.ogg)。

  • We tried updating Java to the latest version.我们尝试将 Java 更新到最新版本。

  • We tried accessing the applet differently.我们尝试以不同的方式访问小程序。

  • We had a similar problem 6 months ago, that was caused by a java update. 6 个月前我们遇到了类似的问题,这是由 java 更新引起的。 We tried the non-working example on a VM with an older java-version.我们在具有较旧 java 版本的 VM 上尝试了不工作的示例。 It works.有用。 However, we suspect that java alone is not the culprit here since the same java-version/browser works on the working example.但是,我们怀疑 java 本身并不是罪魁祸首,因为相同的 java-version/browser 在工作示例上工作。

  • Soundrecorder only refuses to play files that are loaded dynamically via JS. Soundrecorder 只拒绝播放通过 JS 动态加载的文件。 If it loads a file on init, there is no bug.如果它在初始化时加载文件,则没有错误。

  • The applet itself is loaded.小程序本身已加载。 You can make it visible by giving it a width/height.您可以通过为其指定宽度/高度来使其可见。 I suspect that there is a problem in the java/js intercommunication (js is telling java what to play but the communication is faulty?).我怀疑java/js互通有问题(js告诉java玩什么但是通信有问题?)。 However I can't confirm this as of yet.但是,我目前还不能证实这一点。

Generally speaking, we can't find out why the exact same code running under the exact same conditions works on one site, but doesn't on the other.一般来说,我们无法找出为什么在完全相同的条件下运行的完全相同的代码在一个站点上可以工作,而在另一个站点上却不行。

Solution解决方案

The solution is part of a comment.解决方案是评论的一部分。 The problem and solution can be found here .问题和解决方案可以在这里找到。 Thanks to Ryan for pointing us in the right direction.感谢 Ryan 为我们指明了正确的方向。

I'm using FF4 on windows (Java 1.6.0_24) and was able to see the applet at http://www.ecoles-dudelange.lu/cgi-bin/apps/tiparlo?projectid=1594&mode=viewer .我在 windows (Java 1.6.0_24) 上使用 FF4 并且能够在http://www.ecoles-dudelange.lu/cgi-bin/apps/tiparlo?projectid=1594&mode=viewer上看到小程序。

However, when I clicked on the big blue play icon at the bottom of the page all the smilies in the pane above the button seem to glow - 'mexican wave' style.然而,当我点击页面底部的蓝色大播放图标时,按钮上方窗格中的所有表情符号似乎都在发光——“墨西哥波浪”风格。 Impressive:)感人的:)

I did peek into the java applet console and noticed the following errors once the button was clicked:我确实查看了 java 小程序控制台,并在单击按钮后注意到以下错误:

network: Cache entry not found [url: http://www.ecoles-dudelange.lu/resources/audio/_tiparlo_1594/ismael_20110405_11-17-47_3129344.ogg, version: null]
network: Connecting http://www.ecoles-dudelange.lu/resources/audio/_tiparlo_1594/ismael_20110405_11-17-47_3129344.ogg with proxy=DIRECT
network: Cache entry not found [url: http://85.119.157.43/crossdomain.xml, version: null]
network: Connecting http://85.119.157.43/crossdomain.xml with proxy=DIRECT
network: Connecting http://85.119.157.43:80/ with proxy=DIRECT

java.security.AccessControlException: access denied (java.net.SocketPermission 85.119.157.43 resolve)
    at java.security.AccessControlContext.checkPermission(Unknown Source)
    at java.security.AccessController.checkPermission(Unknown Source)
    at java.lang.SecurityManager.checkPermission(Unknown Source)
    at java.lang.SecurityManager.checkConnect(Unknown Source)
    at sun.plugin2.applet.Applet2SecurityManager.checkConnect(Unknown Source)
    at sun.net.www.http.HttpClient.New(Unknown Source)
    at sun.net.www.http.HttpClient.New(Unknown Source)
    at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(Unknown Source)
    at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
    at sun.net.www.protocol.http.HttpURLConnection.connect(Unknown Source)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
    at java.net.URL.openStream(Unknown Source)
    at lu.educdesign.audio.gui.JRecordApplet.load(Unknown Source)

... ...

The URL http://85.119.157.43/crossdomain.xml loads an html page that redirects to http://confixx.s2.olefa.com prompting for a username/password. The URL http://85.119.157.43/crossdomain.xml loads an html page that redirects to http://confixx.s2.olefa.com for a username/password.

Maybe there's a good explanation for this, but it seems to me, prima facie, that this could be a problem也许对此有一个很好的解释,但在我看来,初步看来,这可能是一个问题

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

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