当用户启动程序(JWS / JNLP)时,通常只需在自己登录的窗口中输入凭据,按登录按钮开始工作.由于7u21,因为某些原因(可能是因为7u21的安全性改变),所以我得到了一个额外的Java“需要验证”弹出窗口.
为了确保它与Java版本之间的兼容性问题无关,我更新了服务器以及7u21,所以:
>客户端:更新java从7u17到7u21
>服务器:更新java从7u09到7u21,调整glassfish asenv.bat文件使用新的jdk
如果我在上面显示的“需要验证”窗口中点击取消按钮,程序将会开始,但是在执行请求时不能稳定运行:
java.io.IOException: stream is closed file:/D:/NetBeansProjects/MIT_20130516/CL_KenoM/dist/CL_KenoM.jar!/GUI/cow/ListCow.fxml at com.sun.jersey.api.client.ClientResponse.close(ClientResponse.java:615) at com.sun.jersey.api.client.ClientResponse.getEntity(ClientResponse.java:570) at com.sun.jersey.api.client.ClientResponse.getEntity(ClientResponse.java:535) at com.sun.jersey.api.client.WebResource.handle(WebResource.java:696) at com.sun.jersey.api.client.WebResource.access$300(WebResource.java:74) at com.sun.jersey.api.client.WebResource$Builder.get(WebResource.java:512) at DA.CowsClient.getCowsByUserId(CowsClient.java:96) at GUI.cow.ListCowController.initialize(ListCowController.java:728) at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2152) at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2028) at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2744) at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2723) at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2709) at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2696) at Classes.Context.showContentPane(Context.java:186) at GUI.user.ListUserController.openAddData(ListUserController.java:389) at GUI.user.ListUserController.access$100(ListUserController.java:55) at GUI.user.ListUserController$8.handle(ListUserController.java:657) at GUI.user.ListUserController$8.handle(ListUserController.java:652) at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:69) at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:217) at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:170) at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:38) at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:37) at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92) at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:35) at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92) at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:35) at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92) at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:53) at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:33) at javafx.event.Event.fireEvent(Event.java:171) at javafx.scene.Scene$ClickGenerator.postProcess(Scene.java:3117) at javafx.scene.Scene$ClickGenerator.access$8600(Scene.java:3055) at javafx.scene.Scene$MouseHandler.process(Scene.java:3337) at javafx.scene.Scene$MouseHandler.process(Scene.java:3168) at javafx.scene.Scene$MouseHandler.access$1900(Scene.java:3123) at javafx.scene.Scene.impl_processMouseEvent(Scene.java:1563) at javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2265) at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:250) at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:173) at java.security.AccessController.doPrivileged(Native Method) at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:292) at com.sun.glass.ui.View.handleMouseEvent(View.java:528) at com.sun.glass.ui.View.notifyMouse(View.java:922) at com.sun.glass.ui.win.WinApplication._runLoop(Native Method) at com.sun.glass.ui.win.WinApplication.access$100(WinApplication.java:29) at com.sun.glass.ui.win.WinApplication$3$1.run(WinApplication.java:73) at java.lang.Thread.run(Unknown Source) com.sun.jersey.api.client.ClientHandlerException: java.io.IOException: stream is closed
当使用GET方法(没有使用PUT或DELETE测试)时,会出现此错误,在这种情况下,它是getCowsByUserId()方法:
public List<Cows> getCowsByUserId(int id) throws UniformInterfaceException { WebResource resource = webResource; resource = resource.path(java.text.MessageFormat.format("cows/user/{0}",String.valueOf(id))); //this is line 96 List<Cows> list = resource.accept(javax.ws.rs.core.MediaType.APPLICATION_XML).get(new GenericType<List<Cows>>() { }); return list; }
有趣的是,当我通过Netbeans或.jar文件而不是.jnlp启动程序时,所有的工作都是按照预期的(没有额外的身份验证弹出窗口,没有错误)…所以这必须用Java做一些事情Webstart我猜?
编辑2013年5月28日:
我通过比较来自7u17和7u21的java控制台跟踪/调试日志进行了进一步的研究.我在7u21日志中注意到以下内容:
security: Trust for: http://<url>/lib/jersey-core-1.17.jar has ended: Thu Jan 01 01:00:00 CET 1970 security: Validate the certificate chain using CertPath API security: SHA-256 finger print: <bunch of chars> security: The certificate hasnt been expired,no need to check timestamping info security: The CRL support is disabled security: The OCSP support is disabled security: This OCSP End Entity validation is disabled security: Start comparing to jurisdiction list with this certificate basic: Plugin2ClassLoader.getPermissions CeilingPolicy allPerms security: JAVAWS AppPolicy Permission requested for: http://<url>/lib/jersey-core-1.17.jar
第一行没有显示在7u17日志中,所以它必须做些什么来签名罐子?它显示了多个jar文件相同的东西.在构建项目时,所有的东西都用自己编写的密钥库签名,这是大问题吗?这是否意味着JNLP只有在使用由可靠的CA(不是免费的)创建的证书进行签名的情况下才能正常工作?
EDIT 04六月2013:
我自己从GlobalSign购买了一个代码签名证书,将其安装到我的机器上.将PFX证书文件转换为Java Key Store(JKS),并将其用于签名我的jar(在Netbeans中).之后验证了罐子,似乎都没有了.
但是,我更新了网络服务器上的文件,通过JNLP文件启动程序,但仍然是相同的行为..时间来绝望!
EDIT 06六月2013:
好的,开始了一种不同的方法.作为测试,我尝试使用HTTPUrlConnection()而不是Jersey获取XML数据:
当使用7u21进行http GET请求时,我得到相同的“验证必需”窗口.有了7u17我得到了XML响应.还没有人知道可能是错的?这可能有什么要做,因为我使用BASIC身份验证?这可能与服务器相关吗?这可能与JNLP文件有关吗?更多的答案我搜索这个问题,我有更多的问题看起来:)
解决方法
简而言之:Java Web Start在JDK7中默认缓存HTTP响应,您必须将客户端请求以及Jersey REST服务的响应设置为“no-cache,no-store”.