Missing dependencies and getContextClassLoader()

Hi Ann,

you identified a test gap: I verified the plugin with different projects but all were built using Java 8… I’ll fix the issue with a 1.7.2 release and update the PR accordingly.

But for fixing this I have one question: The problem occurs because the JAXB runtime cannot be resolved. Interestingly exactly for this reason jQA itself as well as the jQA SQ plugin bundle a JAXB runtime, it is packaged into the lib folder of the plugin. But at execution time this cannot be resolved by the Sonar plugin classloader.
I’ve been looking into other plugins to see how they handle this and I found that obviously the sonar-xml-plugin has a similar issue and for that reason creates a shaded artifact. Is this the official way to go?

Cheers

Dirk

Hi Ann,

found the solution by searching this forum here: https://github.com/frdeboffles/sonar-crowd/commit/020274b7d9242ea0db7715407d9bf88c96b2110c. I forced current thread context classloader to use the plugin classloader and it works. Maybe that’s a thing that should be done by Sonar itself while executing plugins. Nevertheless 'll provide a new release now.

Cheers

Dirk

It works, I’ll provide a new release.

Dirk, maybe some SonarSource developer will correct me, but it seems that the next SonarQube release will block plugins from using the getContextClassLoader() method: https://github.com/SonarSource/sonarqube/commit/c13aab927fa11aa451a188bf3f6b183589394bf7#diff-ee353d3da65884bde1d57d22d1a6aa38R42-R44

Felipe, the TCCL solution seems to work at least for SQ 7.9. The commit you’re references an issue that has been marked to be resolved for SQ 8.1, so maybe I’ll be running in troubles there. Will cross check against SQ 8.0 to be sure that my current solution works.

Cheers

Dirk

The current approach of overrding TCCL works for 8.0. But I think it would make sense to create an issue: There’ll probably be libraries being used by plugins that rely on TCCL (e.g. JAXB). SQ should ensure that this is set correctly while executing the sensors. What do you think?

Dirk