Web Services with Custom Extension
bmatt
New Altair Community Member
We have been working on a custom Druid extension for our processes and everything works in Studio and when run on a Job Agent in RapidMiner Server. However, if we expose a process as a Web Service, it fails to find some classes. The jar for the extension includes the classes in question, so it seems pretty odd. We can see logs where the code for the extension is executing so it is getting that far at least. We also tried dropping a jar in the libs that resolves this class, but it still doesn't find it.
Sep 20 10:06:50 ****** standalone.sh[31845]: Caused by: java.lang.ClassNotFoundException: org.glassfish.jersey.client.JerseyClientBuilder from [Module "deployment.rapidminer-server-9.3.0.ear:main" from Service Module Loader]
# strings /opt/rapidminer/rapidminer-server/rapidminer-server-home/resources/extensions/rmx_druid-1.0.0-all.jar | grep org.glassfish.jersey.client.JerseyClientBuilder
org/glassfish/jersey/client/JerseyClientBuilder$1.class
org/glassfish/jersey/client/JerseyClientBuilder.class
org/glassfish/jersey/client/JerseyClientBuilder$1.classPK
org/glassfish/jersey/client/JerseyClientBuilder.classPK
Tagged:
0
Best Answer
-
@bmatt, thanks for posting the summary! I only have one thing to add: the relocation of the JAX-RS packages alone wasn't enough, since it does not change the logic of the service lookup performed by ClientBuilder.newBuilder() and ClientBuilder.newClient(). Thus, the need for instantiating the Jersey implementation directly.
1
Answers
-
JBoss is shipping RESTEasy, you would need to adapt the jax rs default implementation accordingly.3
-
Worked with @ryanjohansen and some others today and got this fixed. There were two issues we ran into:
- Using the ClientBuilder from JAX-RS caused the initial failure to find code, as it wasnt resolving the class properly.
Changed:
this.client = ClientBuilder.newClient(this.jerseyConfig);
To:
this.client = new JerseyClientBuilder().withConfig(this.jerseyConfig).build(); - As @mmichel pointed out the JAX-RS implementation was also an issue, the project I was building off of was using JAX-RS 2.1. Using the shadow plugin, which appears to already be build in to the RM dependencies, we were able to work around that by relocating the JAX-RS implementation for this extension.
Added to build.gradle:
shadowJar {
relocate 'javax.ws.rs', 'shadow.javax.ws.rs'
}
4 - Using the ClientBuilder from JAX-RS caused the initial failure to find code, as it wasnt resolving the class properly.
-
@bmatt, thanks for posting the summary! I only have one thing to add: the relocation of the JAX-RS packages alone wasn't enough, since it does not change the logic of the service lookup performed by ClientBuilder.newBuilder() and ClientBuilder.newClient(). Thus, the need for instantiating the Jersey implementation directly.
1