0
REST APIを使用してサーバーに接続し、Javaでデータを取得しようとしました。 私はいくつかのコードを開発しています。REST-API経由でデータを取得中にjava.lang.IllegalArgumentExceptionに関する問題
Client client = Client.create();
WebResource webResource = client.resource("https://XXXX/0/devices/2c5a7b88-1eca-48b3-ae68-cdcb011a84d9/s/car-exists\\?latest=2");
WebResource.Builder builder = webResource.getRequestBuilder();
for (NewCookie c : cookies)
builder = builder.cookie(c);
ClientResponse response = builder.accept("application/json").get(ClientResponse.class);
上記の最後の文の後に例外があります。
javax.faces.FacesException: #{XXX}: java.lang.IllegalArgumentException: Illegal character in path at index 117: https://XXX/0/devices/2c5a7b88-1eca-48b3-ae68-cdcb011a84d9/s/car-exists\?latest=2
at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:118)
at org.primefaces.application.DialogActionListener.processAction(DialogActionListener.java:45)
at javax.faces.component.UICommand.broadcast(UICommand.java:315)
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:790)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1282)
at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:646)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at filter.NoCacheFilter.doFilter(NoCacheFilter.java:46)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1023)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: javax.faces.el.EvaluationException: java.lang.IllegalArgumentException: Illegal character in path at index 117: https://XXX/0/devices/2c5a7b88-1eca-48b3-ae68-cdcb011a84d9/s/car-exists\?latest=2
at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:101)
at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
... 27 more
コマンドラインでREST-APIに便利な「curl」アプリケーションを使用し、同じURLで簡単にデータを取得しました。しかし、私はJavaでそれを行うことはできません。 URLに問題はありますか?私はそのコードに間違いがないので、私を修正してください。
クエリパラメータの前のurlに 'backslash'を追加する必要はありません。つまり、' https:// XXX/0/devices/2c5a7b88-1eca-48b3-ae68-cdcb011a84d9/s/car-exist?latest = 2' – Satendra