trying to connecting jaserper server using jersy a

2019-02-15 22:25发布

问题:

When i am trying to connecting jaserper server using jersy api throw exception java.lang.NoSuchMethodError: org.glassfish.hk2.utilities.AbstractActiveDescriptor

code bellow here

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();

The exact exception I am getting is below

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)

回答1:

You can also do this operation without using any api. Just call the report with the parameters you want with REST call to your jasper server. This guide will help you.