0

I have an applet packaged with a third part dll (from JTwain). My applet scans documents from the TWAIN compatible default printer. The applet fails on a paper jam and won't recover. The user navigates away from the page and the applet is destroyed. When returning to the page it fails again. Closing the browser (which kills java.exe process on the pc), and then returning to the page clears the problem and everything works.

I want to restart everything without requiring users to close down the browser. I've added a GUID query string to the URL's from which the applets resources are loaded - so I know nothing is being cached. I've checked in the windows task manager and there is no process created by the dll, it's all happening within the main java.exe process. I tried wrapping the scanning process in a thread so I could interrupt it in the stop or destroy methods (just in case the applets thread weren't stopped when the applet was destroyed), but that didn't work.

Any suggest would be greatly appreciated. Ideally I'd like some way to restart java when the applet unloads (but I doubt that's possible).

UPDATE

I've spent a couple of days trying to identify what causes the applet to fail. I still don't know :(

When the paper jam occurs something (not my code), is producing a couple of popups. The first alerts the user of the jam, and can be closed by clicking the OK button. The second says 'reading from device' and hangs. It cannot be close with the red, close window, icon in the top corner - I kill it from the task manager and windows asks to send a report regarding the 'non-responsive program'. I assume these popups are produced by the dll. And given that the second hangs, my assumption is that a thread started by the dll has hung while retaining a lock on some component of the TWAIN application. I get

com.asprise.util.jtwain.JTwainException: Failed to open the specified data source:
    Source: TW-Brother MFC-9970CDW LAN Thrown

..when I try to access the scanner.

I'm at a bit of a loss as to how I can get more information. I'm testing my applet on a windows virtual pc (so as to use ie7), and don't have a method for step debugging in this environment. (And it's crashing on third party code for which I have no source anyway)

4

1 回答 1

1

我在这里只看到两个实用的选择:

  1. 使用可以毫无问题地处理卡纸的 API。当然,这说起来容易(获得健壮的 API),但很难找到。
  2. 启动应用程序。使用Java Web Start自由浮动。如果它冻结,用户可以将其杀死并单击新 JVM 中另一个实例的链接。或者,BasicService.showDocument(URLof.jnlp)如果小程序可以检测到 DLL 的问题并且它本身没有被冻结,它也可能会调用。

当然,您还应该向 ..Asprise(?) 开发人员报告该错误。最佳解决方案是从源头上解决问题。我们在这里所做的任何事情都是“解决方法”。

于 2012-09-07T13:20:32.087 回答