java – 尝试使用jersy api抛出异常来连接jaserper服务器?

当我试图使用jersy api抛出异常时连接jaserper服务器java.lang.NoSuchMethodError:org.glassfish.hk2.utilities.AbstractActiveDescriptor

代码在这里

RestClientConfiguration configuration = new RestClientConfiguration("//localhost:80/jasperserver");
JasperserverRestClient client = new JasperserverRestClient(configuration);
//Session session = client.authenticate("jasperadmin", "jasperadmin");
OperationResult<InputStream> result = client
    .authenticate("jasperadmin", "jasperadmin")
    .reportingService()
    .report("/reports/samples/Cascading_multi_select_report")
    .prepareForRun(ReportOutputFormat.HTML, 1)
    //.parameter("Cascading_name_single_select", "A & U Stalker Telecommunications, Inc")
    .run();
InputStream report = result.getEntity();

我得到的确切例外如下

Exception in thread “main” java.lang.NoSuchMethodError:
org.glassfish.hk2.utilities.AbstractActiveDescriptor.(Ljava/util/Set;Ljava/lang/Class;Ljava/lang/String;Ljava/util/Set;Lorg/glassfish/hk2/api/DescriptorType;Lorg/glassfish/hk2/api/DescriptorVisibility;ILjava/lang/Boolean;Ljava/util/Map;)V
at
org.jvnet.hk2.internal.ConstantActiveDescriptor.(ConstantActiveDescriptor.java:111) at
org.jvnet.hk2.internal.ConstantActiveDescriptor.(ConstantActiveDescriptor.java:111)
at
org.jvnet.hk2.internal.Utilities.getLocatorDescriptor(Utilities.java:795)
at
org.jvnet.hk2.external.generator.ServiceLocatorGeneratorImpl.initialize(ServiceLocatorGeneratorImpl.java:69)
at
org.jvnet.hk2.external.generator.ServiceLocatorGeneratorImpl.create(ServiceLocatorGeneratorImpl.java:91)
at
org.glassfish.hk2.internal.ServiceLocatorFactoryImpl.internalCreate(ServiceLocatorFactoryImpl.java:230)
at
org.glassfish.hk2.internal.ServiceLocatorFactoryImpl.create(ServiceLocatorFactoryImpl.java:207)
at
org.glassfish.jersey.internal.inject.Injections.createLocator(Injections.java:121)
at
org.glassfish.jersey.internal.RuntimeDelegateImpl.(RuntimeDelegateImpl.java:60)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
Method) at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:408)
at java.lang.Class.newInstance(Class.java:433) at
javax.ws.rs.ext.FactoryFinder.newInstance(FactoryFinder.java:117) at
javax.ws.rs.ext.FactoryFinder.find(FactoryFinder.java:207) at
javax.ws.rs.ext.RuntimeDelegate.findDelegate(RuntimeDelegate.java:135)
at
javax.ws.rs.ext.RuntimeDelegate.getInstance(RuntimeDelegate.java:120)
at javax.ws.rs.core.UriBuilder.newInstance(UriBuilder.java:95) at
javax.ws.rs.core.UriBuilder.fromUri(UriBuilder.java:119) at
org.glassfish.jersey.client.JerseyWebTarget.(JerseyWebTarget.java:72)
at
org.glassfish.jersey.client.JerseyClient.target(JerseyClient.java:140)
at
org.glassfish.jersey.client.JerseyClient.target(JerseyClient.java:62)
at
com.jaspersoft.jasperserver.jaxrs.client.core.SessionStorage.init(SessionStorage.java:96)
at
com.jaspersoft.jasperserver.jaxrs.client.core.SessionStorage.(SessionStorage.java:56)
at
com.jaspersoft.jasperserver.jaxrs.client.core.JasperserverRestClient.authenticate(JasperserverRestClient.java:47)

解决方法:

您也可以在不使用任何api的情况下执行此操作.只需使用REST调用jasper服务器所需的参数调用报告即可.这个guide会帮到你.

上一篇:java – Guice不会注入Jersey的资源


下一篇:MyBatis 构造动态 SQL 语句