jolokia: Bug with partial shading of `org.json.simple` in `jolokia-jvm:1.7.2`
package org.jolokia.jvmagent.handler;
...
public class JolokiaHttpHandler implements HttpHandler {
...
// org.json.simple.JSONAware
private JSONAware executeGetRequest(ParsedUri parsedUri) {
// org.jolokia.shaded.org.json.simple.JSONAware
return requestHandler.handleGetRequest(...);
}
Result
Class cast exception in runtime. Version 1.6.2, worked without problems.
Links
About this issue
- Original URL
- State: open
- Created 10 months ago
- Comments: 19 (14 by maintainers)
Commits related to this issue
- [#569] jolokia-agent-jvm comes in two flavors (normal and "standalone" with embedded+shaded classes) — committed to jolokia/jolokia by grgrzybek 7 months ago
Naming is hard, but you are a winner here 😉 It’s now clear:
jolokia-agentpart means it’s Jolokia Agent (similar to WAR and OSGi agents)javaagentmeans it’s a Jolokia Agent to be used with-javaagentCan’t be better and clearer 😉
M4 rather had what pre 1.7.0 had, because the history is:
<id>agent</id>in assembly descriptor - so we have-agentclassifierjolokia-jvm-1.7.2.jarwith shaded classes inside<shadedArtifactAttached>true</shadedArtifactAttached>and<shadedClassifierName>agent</shadedClassifierName>So actually, the only concern I have is that
jolokia-agent-jvm-2.0.0-agent.jarlooks weird…cc: @rhuss @tadayosi @apupier
Let me highlight the issue:
org.jolokia.support.spring.SpringJolokiaAgentextendsorg.jolokia.jvmagent.JolokiaServer)agentclassifier (embedding shaded json library and some jolokia deps)agentclassifier (just classes from the agent)The classifier change was related to change from maven-assembly-plugin to maven-shade-plugin (see e7ab408b). But also it broke (see this issue) jolokia-support-spring → jolokia-agent-jvm dependency, because before 1.7.0, jolokia-support-spring depended on no-classifier agent without shaded classes.
createDependencyReducedPomof maven-shade-plugin is the way to express dependencies better, because what’s available in Maven repo after deployment is the processed POM without the dependencies that were actually shaded.The problem however occurs in IDE / non-IDE scenarios. In pure Maven build, the dependencies are used after shading, however in IDE it’s before shading (which isn’t even performed). Before Jolokia 1.7.0 it wasn’t a problem, because we’d have to specify explicit dependency on
<classifier>agent</classifier>version of jolokia-jvm…That’s why now jolokia-support-spring tests work in IDE, but fail in
mvnwith:The solution would be to get back to pre 1.7.0 behavior and have jolokia-agent-jvm deployed in two flavors:
agentclassifier (and shaded classes)Then no Jolokia module should depend on the
agentclassified version andjolokia-agent-jvm-2.0.0-agent.jar(…) should be used as standalone agent, in which case no other Jolokia dependency should be present on classpath.WDYT?