javax.ws.rs.ProcessingException 当使用 jrs-rest-java-client API
javax.ws.rs.ProcessingException when using jrs-rest-java-client API
我正在尝试使用 rest API 连接到 Jasper Report Server,下面是我的 Java 代码
RestClientConfiguration configuration = new RestClientConfiguration("http://localhost:8181/jasperserver");
JasperserverRestClient client = new JasperserverRestClient(configuration);
Session session = client.authenticate("jasperadmin", "jasperadmin");
session.logout();
OperationResult<InputStream> result = client
.authenticate("jasperadmin", "jasperadmin")
.reportingService()
.report("/reports/samples/EmpTry")
.prepareForRun(ReportOutputFormat.HTML, 1)
.run();
InputStream report = result.getEntity();
但我收到以下异常
Exception in thread "main" javax.ws.rs.ProcessingException: javax.ws.rs.core.Response$Status$Family.familyOf(I)Ljavax/ws/rs/core/Response$Status$Family;
at org.glassfish.jersey.client.ClientRuntime.invoke(ClientRuntime.java:236)
at org.glassfish.jersey.client.JerseyInvocation.call(JerseyInvocation.java:655)
at org.glassfish.jersey.client.JerseyInvocation.call(JerseyInvocation.java:652)
at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
at org.glassfish.jersey.internal.Errors.process(Errors.java:228)
at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:422)
at org.glassfish.jersey.client.JerseyInvocation.invoke(JerseyInvocation.java:652)
at org.glassfish.jersey.client.JerseyInvocation$Builder.method(JerseyInvocation.java:412)
at org.glassfish.jersey.client.JerseyInvocation$Builder.post(JerseyInvocation.java:321)
at com.jaspersoft.jasperserver.jaxrs.client.core.SessionStorage.login(SessionStorage.java:102)
at com.jaspersoft.jasperserver.jaxrs.client.core.SessionStorage.init(SessionStorage.java:93)
at com.jaspersoft.jasperserver.jaxrs.client.core.SessionStorage.<init>(SessionStorage.java:50)
at com.jaspersoft.jasperserver.jaxrs.client.core.JasperserverRestClient.authenticate(JasperserverRestClient.java:35)
at Zz.main(Zz.java:17)
Caused by: java.lang.NoSuchMethodError: javax.ws.rs.core.Response$Status$Family.familyOf(I)Ljavax/ws/rs/core/Response$Status$Family;
at org.glassfish.jersey.message.internal.Statuses$StatusImpl.<init>(Statuses.java:63)
at org.glassfish.jersey.message.internal.Statuses$StatusImpl.<init>(Statuses.java:54)
at org.glassfish.jersey.message.internal.Statuses.from(Statuses.java:93)
at org.glassfish.jersey.client.HttpUrlConnector._apply(HttpUrlConnector.java:278)
at org.glassfish.jersey.client.HttpUrlConnector.apply(HttpUrlConnector.java:182)
at org.glassfish.jersey.client.ClientRuntime.invoke(ClientRuntime.java:227)
... 14 more
我正在为我的应用程序使用 weblogic 服务器。所以需要在weblogic.xml文件中指定一些jar文件。下面给出的是我的 weblogic.xml 的样子。
<wls:container-descriptor>
<wls:prefer-application-packages>
<wls:package-name>com.sun.jersey.*</wls:package-name>
<wls:package-name>com.sun.jersey.*</wls:package-name>
<wls:package-name>org.jvnet.hk2.*</wls:package-name>
<wls:package-name>com.sun.research.ws.wadl.*</wls:package-name>
<wls:package-name>com.sun.ws.rs.ext.*</wls:package-name>
<wls:package-name>javax.ws.rs.*</wls:package-name>
</wls:prefer-application-packages>
</wls:container-descriptor>
还要确保您使用的是相同版本的球衣。有两个不同的版本可用,如果同时使用它们会显示错误。
我正在尝试使用 rest API 连接到 Jasper Report Server,下面是我的 Java 代码
RestClientConfiguration configuration = new RestClientConfiguration("http://localhost:8181/jasperserver");
JasperserverRestClient client = new JasperserverRestClient(configuration);
Session session = client.authenticate("jasperadmin", "jasperadmin");
session.logout();
OperationResult<InputStream> result = client
.authenticate("jasperadmin", "jasperadmin")
.reportingService()
.report("/reports/samples/EmpTry")
.prepareForRun(ReportOutputFormat.HTML, 1)
.run();
InputStream report = result.getEntity();
但我收到以下异常
Exception in thread "main" javax.ws.rs.ProcessingException: javax.ws.rs.core.Response$Status$Family.familyOf(I)Ljavax/ws/rs/core/Response$Status$Family;
at org.glassfish.jersey.client.ClientRuntime.invoke(ClientRuntime.java:236)
at org.glassfish.jersey.client.JerseyInvocation.call(JerseyInvocation.java:655)
at org.glassfish.jersey.client.JerseyInvocation.call(JerseyInvocation.java:652)
at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
at org.glassfish.jersey.internal.Errors.process(Errors.java:228)
at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:422)
at org.glassfish.jersey.client.JerseyInvocation.invoke(JerseyInvocation.java:652)
at org.glassfish.jersey.client.JerseyInvocation$Builder.method(JerseyInvocation.java:412)
at org.glassfish.jersey.client.JerseyInvocation$Builder.post(JerseyInvocation.java:321)
at com.jaspersoft.jasperserver.jaxrs.client.core.SessionStorage.login(SessionStorage.java:102)
at com.jaspersoft.jasperserver.jaxrs.client.core.SessionStorage.init(SessionStorage.java:93)
at com.jaspersoft.jasperserver.jaxrs.client.core.SessionStorage.<init>(SessionStorage.java:50)
at com.jaspersoft.jasperserver.jaxrs.client.core.JasperserverRestClient.authenticate(JasperserverRestClient.java:35)
at Zz.main(Zz.java:17)
Caused by: java.lang.NoSuchMethodError: javax.ws.rs.core.Response$Status$Family.familyOf(I)Ljavax/ws/rs/core/Response$Status$Family;
at org.glassfish.jersey.message.internal.Statuses$StatusImpl.<init>(Statuses.java:63)
at org.glassfish.jersey.message.internal.Statuses$StatusImpl.<init>(Statuses.java:54)
at org.glassfish.jersey.message.internal.Statuses.from(Statuses.java:93)
at org.glassfish.jersey.client.HttpUrlConnector._apply(HttpUrlConnector.java:278)
at org.glassfish.jersey.client.HttpUrlConnector.apply(HttpUrlConnector.java:182)
at org.glassfish.jersey.client.ClientRuntime.invoke(ClientRuntime.java:227)
... 14 more
我正在为我的应用程序使用 weblogic 服务器。所以需要在weblogic.xml文件中指定一些jar文件。下面给出的是我的 weblogic.xml 的样子。
<wls:container-descriptor>
<wls:prefer-application-packages>
<wls:package-name>com.sun.jersey.*</wls:package-name>
<wls:package-name>com.sun.jersey.*</wls:package-name>
<wls:package-name>org.jvnet.hk2.*</wls:package-name>
<wls:package-name>com.sun.research.ws.wadl.*</wls:package-name>
<wls:package-name>com.sun.ws.rs.ext.*</wls:package-name>
<wls:package-name>javax.ws.rs.*</wls:package-name>
</wls:prefer-application-packages>
</wls:container-descriptor>
还要确保您使用的是相同版本的球衣。有两个不同的版本可用,如果同时使用它们会显示错误。