Jaxb in a plugin is no longer working in migration from Jira 7.x to Jira 8.x

The behavior of the ClassLoader used by JAXBContext inside a plugin seems to have changed from Jira 7.x to 8.x.

Running a simple test like this in a plugin:
JAXBContext context = JAXBContext.newInstance(“com.acme.foo”);
log.debug(“classloader for context: {}”, context.getClass().getClassLoader());

Gives this result in Jira 7.x:
classloader for context: com.my.plugin.test-plugin [235]

and this result in Jira 8.x:
classloader for context: ParallelWebappClassLoader
context: jira
delegate: false
----------> Parent Classloader:
java.net.URLClassLoader@6f496d9

Maybe it’s some sort of change between the versions of tomcat included with Jira. Whatever it is, it essentially renders jaxb unusable in a plugin because marshalling / setProperty can’t succeed in doing instanceof tests on classes loaded from different classloaders.

Trying to fix it by passing a ClassLoader using JAXBContext.newInstance(“com.acme.foo”, myClassLoader) doesn’t seem to change the behavior.

Has anyone else encountered this on the latest releases of Jira and found a workaround?

3 Likes

Hi @travis - just an FYI that we’ve reached out to some folks internally and they’re looking into it.

4 Likes

Any progress on that? Its kind of a showstopper for us as well at the moment.

1 Like

One notable change from Jira 7 -> 8 is Jira 8 including JAXB itself as a dependency, this may be related to the issue.

I think that’s a good theory. Maybe in the move to support JDK 11 which doesn’t come with JAXB included they inadvertently broke things by adding it as a dependency.

@travis,

Java 11 removed JAX-B from the JDK, where javax.xml.bind and friends used to be just standard packages. As a result, in order to support Java 11, Bitbucket Server (which I work on) and Jira had to switch to bundling JAX-B libraries directly; we can’t rely on the JDK itself providing it anymore. (The other products will follow suit as they release Java 11-compatible versions.) That’s resulted in a change of behavior. Previously the javax.xml.bind bits were handled like, say, java.lang.String, but now they’re not. The JAX-B changes are causing problems for more than just Atlassian products. (See here, for example).

We’re still researching this internally… Stay tuned, and apologies for the delay.

Best regards,
Bryan Turner
Atlassian Bitbucket

2 Likes

Understood. I am Ok waiting for Jira 8.2 and switching to Java 11 if that makes the issue go away. If not, a fix or workaround would be appreciated.

Thank you for the effort.

Jira 8.2.0 got released: https://confluence.atlassian.com/jirasoftware/jira-software-8-2-x-release-notes-968676271.html

Updated the Jira version in pom.xml, added a new dependency to resolve compilation issues that now occurred:

        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>4.0.1</version>
            <scope>provided</scope>
        </dependency>

However, this issue still persists, at least on Java 8.