过去 6 个月我一直在做一个项目。对于这个项目,我有一个部署了 web 服务的 glassfish 服务器实例。在客户端,我使用的是 JavaFX2.2,它使用 Jersey(XML 请求/响应,无 JSON)通过 BASIC 身份验证执行 REST 请求。
当用户启动程序 (JWS/JNLP) 时,通常他们只需在自己制作的登录窗口中输入凭据,按下登录按钮并开始工作。但是,从 7u21 开始,由于某种原因(可能是因为 7u21 中安全性发生了变化),我得到了一个额外的 Java“需要身份验证”弹出窗口。
为了确保它与 Java 版本之间的兼容性问题无关,我将服务器也更新为 7u21,因此:
如果我在上面显示的“需要身份验证”窗口中点击取消按钮,程序确实会启动,但在执行请求时它运行不稳定:
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 日志中,所以它必须对 jars 进行签名吗?它为多个 jar 文件显示相同的内容。构建项目时,所有内容都使用自己制作的 keystore 进行签名,这是大问题吗?这是否意味着 JNLP 只有在使用受信任的 CA(当然不是免费的)创建的证书签名的情况下才能正常工作?
2013 年 6 月 4 日编辑:
我从 GlobalSign 给自己买了一个代码签名证书,并将其安装到我的机器上。将 PFX 证书文件转换为 Java keystore (JKS),并使用该文件对我的 jar 进行签名(在 Netbeans 中)。之后验证了 jar ,一切似乎都没问题。 然而,我更新了网络服务器上的文件,通过 JNLP 文件启动了程序,但仍然是同样的行为……绝望的时候到了!
2013 年 6 月 6 日编辑:
好吧,开始另一种方法。作为测试,我尝试使用 HTTPUrlConnection() 而不是 Jersey 来获取 XML 数据:
在使用 7u21 时执行 http GET 请求时,我会看到相同的“需要身份验证”窗口。使用 7u17 我得到了 XML 响应。仍然没有人知道可能出了什么问题?这可能与我使用 BASIC 身份验证有关吗?这可能与服务器有关吗?这可能与 JNLP 文件有关吗?我搜索这个问题的答案越多,我的问题似乎就越多:)
最佳答案
我对您的回答follow-up question也应该回答这个问题。
简而言之:Java Web Start 在 JDK7 中默认缓存 HTTP 响应,您必须在客户端请求和 Jersey REST 服务的响应中将 Cache-Control header 设置为“no-cache, no-store”。
关于java - 7u21 更新后弹出需要身份验证的窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16626676/
当我使用Bundler时,是否需要在我的Gemfile中将其列为依赖项?毕竟,我的代码中有些地方需要它。例如,当我进行Bundler设置时:require"bundler/setup" 最佳答案 没有。您可以尝试,但首先您必须用鞋带将自己抬离地面。 关于ruby-我需要将Bundler本身添加到Gemfile中吗?,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/4758609/
给定这段代码defcreate@upgrades=User.update_all(["role=?","upgraded"],:id=>params[:upgrade])redirect_toadmin_upgrades_path,:notice=>"Successfullyupgradeduser."end我如何在该操作中实际验证它们是否已保存或未重定向到适当的页面和消息? 最佳答案 在Rails3中,update_all不返回任何有意义的信息,除了已更新的记录数(这可能取决于您的DBMS是否返回该信息)。http://ar.ru
我的代码目前看起来像这样numbers=[1,2,3,4,5]defpop_threepop=[]3.times{pop有没有办法在一行中完成pop_three方法中的内容?我基本上想做类似numbers.slice(0,3)的事情,但要删除切片中的数组项。嗯...嗯,我想我刚刚意识到我可以试试slice! 最佳答案 是numbers.pop(3)或者numbers.shift(3)如果你想要另一边。 关于ruby-多次弹出/移动ruby数组,我们在StackOverflow上找到一
我注意到像bundler这样的项目在每个specfile中执行requirespec_helper我还注意到rspec使用选项--require,它允许您在引导rspec时要求一个文件。您还可以将其添加到.rspec文件中,因此只要您运行不带参数的rspec就会添加它。使用上述方法有什么缺点可以解释为什么像bundler这样的项目选择在每个规范文件中都需要spec_helper吗? 最佳答案 我不在Bundler上工作,所以我不能直接谈论他们的做法。并非所有项目都checkin.rspec文件。原因是这个文件,通常按照当前的惯例,只
我实际上是在尝试使用RVM在我的OSX10.7.5上更新ruby,并在输入以下命令后:rvminstallruby我得到了以下回复:Searchingforbinaryrubies,thismighttakesometime.Checkingrequirementsforosx.Installingrequirementsforosx.Updatingsystem.......Errorrunning'requirements_osx_brew_update_systemruby-2.0.0-p247',pleaseread/Users/username/.rvm/log/138121
我将应用程序升级到Rails4,一切正常。我可以登录并转到我的编辑页面。也更新了观点。使用标准View时,用户会更新。但是当我添加例如字段:name时,它不会在表单中更新。使用devise3.1.1和gem'protected_attributes'我需要在设备或数据库上运行某种更新命令吗?我也搜索过这个地方,找到了许多不同的解决方案,但没有一个会更新我的用户字段。我没有添加任何自定义字段。 最佳答案 如果您想允许额外的参数,您可以在ApplicationController中使用beforefilter,因为Rails4将参数
我真的很习惯使用Ruby编写以下代码:my_hash={}my_hash['test']=1Java中对应的数据结构是什么? 最佳答案 HashMapmap=newHashMap();map.put("test",1);我假设? 关于java-等价于Java中的RubyHash,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/22737685/
我正在尝试使用boilerpipe来自JRuby。我看过guide从JRuby调用Java,并成功地将它与另一个Java包一起使用,但无法弄清楚为什么同样的东西不能用于boilerpipe。我正在尝试基本上从JRuby中执行与此Java等效的操作:URLurl=newURL("http://www.example.com/some-location/index.html");Stringtext=ArticleExtractor.INSTANCE.getText(url);在JRuby中试过这个:require'java'url=java.net.URL.new("http://www
我只想对我一直在思考的这个问题有其他意见,例如我有classuser_controller和classuserclassUserattr_accessor:name,:usernameendclassUserController//dosomethingaboutanythingaboutusersend问题是我的User类中是否应该有逻辑user=User.newuser.do_something(user1)oritshouldbeuser_controller=UserController.newuser_controller.do_something(user1,user2)我
这个问题在这里已经有了答案:关闭10年前。PossibleDuplicate:Rubysyntaxquestion:Rational(a,b)andRational.new!(a,b)我正在阅读ruby镐书,我对创建有理数的语法感到困惑。Rational(3,4)*Rational(1,2)产生=>3/8为什么Rational不需要new方法(我还注意到例如我可以在没有new方法的情况下创建字符串)?