Jersey 클라이언트를 사용하여 원격 웹 서비스에 액세스하려고합니다.Jersey 클라이언트를 사용하려고 할 때 Null 포인터 예외가 발생했습니다.
Client client = Client.create();
WebResource resource = client.resource(request.getUrl());
Builder builder = resource.accept("application/json");
String response = builder.post(String.class, request.getPayload());
저는 이것을 OSGi 번들에 번들로 묶어 Adobe CQ CMS에 설치했습니다.
나는 다음과 같은 스택 트레이스 얻을 CMS의 요청 코드 실행하려고 :에 의한
Caused by: java.lang.ExceptionInInitializerError
at com.sun.jersey.core.spi.factory.MessageBodyFactory.getMessageBodyWriterMediaTypes(MessageBodyFactory.java:444)
at com.sun.jersey.api.client.RequestWriter.getMediaType(RequestWriter.java:324)
at com.sun.jersey.api.client.RequestWriter.writeRequestEntity(RequestWriter.java:282)
at com.sun.jersey.client.urlconnection.URLConnectionClientHandler._invoke(URLConnectionClientHandler.java:204)
at com.sun.jersey.client.urlconnection.URLConnectionClientHandler.handle(URLConnectionClientHandler.java:147)
at com.sun.jersey.api.client.Client.handle(Client.java:648)
at com.sun.jersey.api.client.WebResource.handle(WebResource.java:680)
at com.sun.jersey.api.client.WebResource.access$200(WebResource.java:74)
at com.sun.jersey.api.client.WebResource$Builder.post(WebResource.java:568)
at com.myapp.auth.request.impl.HttpRequestSender.sendRequest(HttpRequestSender.java:44)
at com.myapp.auth.ws.clients.impl.AuthenticateClientImpl.authenticate(AuthenticateClientImpl.java:47)
at com.myapp.auth.Authenticator.authenticate(Authenticator.java:31)
at org.apache.jsp.apps.angry_002dnerds.components.page.base.content_jsp._jspService(content_jsp.java:155)
at org.apache.sling.scripting.jsp.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at org.apache.sling.scripting.jsp.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:420)
... 126 more
: javax.ws.rs.core.MediaType.valueOf에서 java.lang.NullPointerException이 을 (MediaType에 된 .java :. 119) com.sun.jersey.core.header.MediaTypes에서 (MediaTypes.java:64) ... 142 개
나는 주위를 둘러 보았다 및 다른 사람의 MediaType과 유사한 오류가 있었 것을 보았다 다른 플랫폼에서 NullPointerExceptions을 던지는 것.
전에이 문제를 본 사람이 있습니까?
'web.xml'을 보여주세요. –
나는 web.xml을 가지고 있지 않다. OSGi 번들로 이것을 구축해라. – cowls
필자는 같은 문제가있는 누군가를 여기에서 발견했다 : http://jersey.576304.n2.nabble.com/MediaType-Delegate-is-null-td5548719. html 그들은 jersey1.3에서 수정되었다고 제안하지만 버전 1.12를 사용하고 있으며 여전히 동일한 문제를보고 있습니다. 다소 다소 – cowls