我有一个 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
提交
取消