代理后面的Java小程序在实例化新类时会暂时冻结 介绍
客户办公室的Java小程序有一些问题。小程序用于通过定期截图记录屏幕。它已签名,应该以提升的权限运行 我们遇到的问题是:代理后面的Java小程序在实例化新类时会暂时冻结 介绍,java,proxy,applet,classloader,Java,Proxy,Applet,Classloader,客户办公室的Java小程序有一些问题。小程序用于通过定期截图记录屏幕。它已签名,应该以提升的权限运行 我们遇到的问题是: Java小程序有时可能根本无法启动。如果Java控制台出现,它可能很快就会消失。感觉整个JVM都崩溃了 如果Java小程序启动,它有时会在启动10秒后崩溃 如果Java小程序启动,它几乎总是会经历长达12秒的临时冻结 (小程序启动有点慢。) 典型的情况是,启动Windows后,小程序在第一次尝试时不会加载。刷新/重新登录/重新启动浏览器(我不完全确定需要什么)后,小程序启动,
ping www.google.com
将在超时后失败,因为无法解析主机www.google.com。我找到了一些描述Java和Blue Coat代理问题的页面。我认为这些没有提供多少有用的信息,但它们强化了我的信念,即代理与问题有关
HTTP/1.1 407 Proxy Authentication Required
Proxy-Authenticate: NTLM TlRMTVNTUAACAAAADAAMADgAAAAFgokC/+XiO/tpmQMAAAAAAAAAAKQApABEAAAABQLODgAAAA9KAEEATQBQAFQASQACAAwASgBBAE0AUABUAEkAAQASAFAASwBIAEsASQBEAEMAMAAxAAQAHgBwAHUAdQBrAGUAcwBrAHUAcwAuAGwAbwBjAGEAbAADADIAcABrAGgAawBpAGQAYwAwADEALgBwAHUAdQBrAGUAcwBrAHUAcwAuAGwAbwBjAGEAbAAFAB4AcAB1AHUAawBlAHMAawB1AHMALgBsAG8AYwBhAGwAAAAAAA==
环境
我当时在客户的办公场所,亲自在笔记本电脑上体验问题。我的设置是在虚拟机中运行Ubuntu Linux 12.04和Windows 7。大多数测试我都使用Windows和Java1.6.35。我确实在Linux中运行过一次小程序(我想是使用OracleJava1.7.007),它没有冻结,但小程序拍摄的屏幕截图可能是空白或损坏的
我在Java设置中取消选中了“在我的计算机上保留临时文件”框,因为缓存的Java小程序有时会干扰开发。我在客户办公室调试小程序时禁用了临时文件,但我不认为此设置会影响问题,因为我们的客户可能启用了临时文件,并且他们总是遇到这些问题
问题似乎并不取决于浏览器。我试过IE9、Firefox、Chrome和Opera
观察
在Windows中运行小程序时,我将Eclipse调试器附加到小程序。当小程序被冻结时,我暂停了它的执行,并检查了它在做什么。这是堆栈的外观。“OurOwnClass.doStillMoreSomething”是我们自己代码中执行的最后一行,它创建了一个类的新实例
Thread [AWT-EventQueue-2] (Suspended)
Inet6AddressImpl.lookupAllHostAddr(String) line: not available [native method]
InetAddress$1.lookupAllHostAddr(String) line: not available
InetAddress.getAddressFromNameService(String, InetAddress) line: not available
InetAddress.getAllByName0(String, InetAddress, boolean) line: not available
InetAddress.getAllByName(String, InetAddress) line: not available
InetAddress.getAllByName(String) line: not available
InetAddress.getByName(String) line: not available
Handler(URLStreamHandler).getHostAddress(URL) line: not available
Handler(URLStreamHandler).hostsEqual(URL, URL) line: not available
Handler(URLStreamHandler).sameFile(URL, URL) line: not available
Handler(URLStreamHandler).equals(URL, URL) line: not available
URL.equals(Object) line: not available
JarVerifier$VerifierCodeSource(CodeSource).equals(Object) line: not available
JarVerifier$VerifierCodeSource.equals(Object) line: not available
HashMap<K,V>.getEntry(Object) line: not available
HashMap<K,V>.containsKey(Object) line: not available
HashSet<E>.contains(Object) line: not available
CPCallbackHandler.isTrusted(CodeSource) line: not available
CPCallbackHandler.access$1200(CPCallbackHandler, CodeSource) line: not available
CPCallbackHandler$ChildElement.checkResource(String) line: not available
DeployURLClassPath$JarLoader.checkResource(String, boolean, JarEntry, JarFile, DeployURLClassPath$PathIterator) line: not available
DeployURLClassPath$JarLoader.getResource(String, boolean, DeployURLClassPath$PathIterator) line: not available
DeployURLClassPath.getResource(String, boolean) line: not available
Plugin2ClassLoader$2.run() line: not available
AccessController.doPrivileged(PrivilegedExceptionAction<T>, AccessControlContext) line: not available [native method]
Applet2ClassLoader(Plugin2ClassLoader).findClassHelper(String) line: not available
Applet2ClassLoader.findClass(String, boolean) line: not available
Applet2ClassLoader(Plugin2ClassLoader).loadClass0(String, boolean, boolean) line: not available
Applet2ClassLoader(Plugin2ClassLoader).loadClass(String, boolean, boolean) line: not available
Applet2ClassLoader(Plugin2ClassLoader).loadClass(String, boolean) line: not available
Applet2ClassLoader(ClassLoader).loadClass(String) line: not available
OurOwnClass.doStillMoreSomething(String) line: 701
OurOwnClass.doMoreSomething() line: 671
OurOwnClass.doSometihng() line: 655
OurOwnClass.handleTimer() line: 510
OurOwnClass.actionPerformed(ActionEvent) line: 391
Timer.fireActionPerformed(ActionEvent) line: not available
Timer$DoPostEvent.run() line: not available
InvocationEvent.dispatch() line: not available
EventQueue.dispatchEventImpl(AWTEvent, Object) line: not available
EventQueue.access$400(EventQueue, AWTEvent, Object) line: not available
EventQueue$2.run() line: not available
EventQueue$2.run() line: not available
AccessController.doPrivileged(PrivilegedAction<T>, AccessControlContext) line: not available [native method]
AccessControlContext$1.doIntersectionPrivilege(PrivilegedAction<T>, AccessControlContext, AccessControlContext) line: not available
EventQueue.dispatchEvent(AWTEvent) line: not available
EventDispatchThread.pumpOneEventForFilters(int) line: not available
EventDispatchThread.pumpEventsForFilter(int, Conditional, EventFilter) line: not available
EventDispatchThread.pumpEventsForHierarchy(int, Conditional, Component) line: not available
EventDispatchThread.pumpEvents(int, Conditional) line: not available
EventDispatchThread.pumpEvents(Conditional) line: not available
EventDispatchThread.run() line: not available
线程[AWT-EventQueue-2](挂起)
Inet6AddressImpl.lookupAllHostAddr(字符串)行:不可用[本机方法]
InetAddress$1.lookupAllHostAddr(字符串)行:不可用
InetAddress.getAddressFromNameService(字符串,InetAddress)行:不可用
InetAddress.getAllByName0(字符串、InetAddress、布尔值)行:不可用
InetAddress.getAllByName(字符串,InetAddress)行:不可用
InetAddress.getAllByName(字符串)行:不可用
InetAddress.getByName(字符串)行:不可用
处理程序(URLStreamHandler).getHostAddress(URL)行:不可用
处理程序(URLStreamHandler).hostsEqual(URL,URL)行:不可用
处理程序(URLStreamHandler).sameFile(URL,URL)行:不可用
处理程序(URLStreamHandler).equals(URL,URL)行:不可用
URL.equals(对象)行:不可用
JarVerifier$VerifierCodeSource(CodeSource).等于(对象)行:不可用
JarVerifier$VerifierCodeSource.equals(对象)行:不可用
HashMap.getEntry(对象)行:不可用
HashMap.containsKey(对象)行:不可用
HashSet.contains(对象)行:不可用
CPCallbackHandler.isTrusted(CodeSource)行:不可用
CPCallbackHandler.access$1200(CPCallbackHandler,CodeSource)行:不可用
CPCallbackHandler$ChildElement.checkResource(字符串)行:不可用
DeployURLClassPath$JarLoader.checkResource(字符串、布尔值、JarEntry、JarFile、DeployURLClassPath$PathIterator)行:不可用
DeployURLClassPath$JarLoader.getResource(字符串、布尔值、DeployURLClassPath$PathIterator)行:不可用
DeployURLClassPath.getResource(字符串,布尔值)行:不可用
Plugin2ClassLoader$2.run()行:不可用
AccessController.doPrivileged(PrivilegedExceptionAction,AccessControlContext)行:不可用[本机方法]
Applet2ClassLoader(Plugin2ClassLoader)。findClassHelper(字符串)行:不可用
Applet2ClassLoader.findClass(字符串,布尔值)行:不可用
Applet2ClassLoader(Plugin2ClassLoader).loadClass0(字符串、布尔值、布尔值)行:不可用
Applet2ClassLoader(Plugin2ClassLoader).loadClass(字符串、布尔值、布尔值)行:不可用
Applet2ClassLoader(Plugin2ClassLoader)。loadClass(字符串,布尔值)行:不可用
Applet2ClassLoader(类装入器)。装入类(字符串)行:不可用
OurOwnClass.doStillMoreSomething(字符串)行:701
OurOwnClass.doMoreSomething()行:671
OurOwnClass.dosomething()行:655
行:510
OurOwnClass.actionPerformed(ActionEvent)行:391
计时器.fireActionPerformed(ActionEvent)行:不可用
计时器$DoPostEvent.run()行:不可用
InvocationEvent.dispatch()行:不可用
事件
worker = new SwingWorker<Void,Void>() {
@Override
public Void doInBackground() {
// Do stuff.
return null;
}
};
protected synchronized InetAddress getHostAddress(URL u) {
if (u.hostAddress != null)
return u.hostAddress;
String host = u.getHost();
if (host == null || host.equals("")) {
return null;
} else {
try {
u.hostAddress = InetAddress.getByName(host); // Hanging here
} catch (UnknownHostException ex) {
return null;
} catch (SecurityException se) {
return null;
}
}
return u.hostAddress;
}