我有一個 jersey 2.x Web 應用程序,其中有一個業務對象試圖通過調用外部服務來處理請求。每當我嘗試實例化 CloseableHttpClient 時,它都會拋出 NullPointerException。我嘗試使用較舊的 commons-httpclient 庫,它做了完全相同的事情。我覺得這真的很奇怪,因為在 Jersey 1.x 網絡應用程序中使用了相同的代碼,它工作得很好。有誰知道這是為什么?是因為 oc 球衣容器,我需要使用球衣客戶端 api 嗎?下面的兩個示例都會生成錯誤。我使用哪個庫并不重要(當然單獨測試)。// Using the httpclient-4.3.6ClonableHttpClient httpClient = HttpClients.createDefault();// Using commons-httpclient-3.1HttpClient httpClient = new HttpClient();這是堆棧競賽:Exception:java.lang.NullPointerException at com.valspar.security.bso.WservicesSecurityManager.authenticateInMobilesecure(WservicesSecurityManager.java:549) at com.valspar.security.SecurityServiceImpl.doChiptapLogin(SecurityServiceImpl.java:165) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory$1.invoke(ResourceMethodInvocationHandlerFactory.java:81) at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:144) at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:161) at
添加回答
舉報
0/150
提交
取消