LinkageError when using jira-api and jira-core together

Hi guys.

 

I'm preparing some old plugin, developed in Jira 3.X, to upgrade to Jira 7. In particular, I'm creating a new plugin with single-issue-view to generate an customized word document. Meanwhile, the old plugin use some jira-core classes, like AbstractIssueHtmlView and JiraVelocityUtils.

When I added the jira-core, everything compile well and using atlas-mvn package, I was able to test the plugin with successfull. In the other hand, when I restart the server (Ctrl+C and atlas-run), I'm getting the following error.

********************************************************************************************************************************************************************************************************
___ FAILED PLUGIN REPORT _____________________

1 plugin failed to load during JIRA startup.

'com.mycompany.issueoperations' - 'issueoperations' failed to load.
Unexpected exception parsing XML document from URL [bundle://167.0:0/META-INF/spring/plugin-context.xml]; nested exception is java.lang.LinkageError: loader constraint violation: loader (instance of org/apache/felix/framework/BundleWiringImpl$BundleClassLoaderJava5) previously initiated loading for a different type with name "org/w3c/dom/Element"
loader constraint violation: loader (instance of org/apache/felix/framework/BundleWiringImpl$BundleClassLoaderJava5) previously initiated loading for a different type with name "org/w3c/dom/Element"

It was loaded from C:\projects\TTT\source\issueoperations\target\jira\home\plugins\installed-plugins\issueoperations-1.0.jar

********************************************************************************************************************************************************************************************************


Anyone knows how can I avoid this error?

 

Thanks.

3 answers

This widget could not be displayed.

Looks like something in the atlassian-plugin.xml file? Try creating a brand new plugin and see if that compiles and runs

This widget could not be displayed.

Hi Matt.

 

I created a new plugin (blank plugin) and added jira-core in pom.xml

...

<dependencies>
<dependency>
<groupId>com.atlassian.jira</groupId>
<artifactId>jira-api</artifactId>
<version>${jira.version}</version>
<scope>provided</scope>
</dependency>
<!-- Add dependency on jira-core if you want access to JIRA implementation classes as well as the sanctioned API. -->
<!-- This is not normally recommended, but may be required eg when migrating a plugin originally developed against JIRA 4.x -->
<dependency>
<groupId>com.atlassian.jira</groupId>
<artifactId>jira-core</artifactId>
<version>${jira.version}</version>
<scope>provided</scope>
</dependency>

...

The error happened in the same way, as you can see...

********************************************************************************************************************************************************************************************************
___ FAILED PLUGIN REPORT _____________________

2 plugins failed to load during JIRA startup.

'com.bcompany.trk.blank' - 'blank' failed to load.
Unexpected exception parsing XML document from URL [bundle://167.0:0/META-INF/spring/plugin-context.xml]; nested exception is java.lang.LinkageError: loader constraint violation: loader (instance of org/apache/felix/framework/BundleWiringImpl$BundleClassLoaderJava5) previously initiated loading for a different type with name "org/w3c/dom/Element"
loader constraint violation: loader (instance of org/apache/felix/framework/BundleWiringImpl$BundleClassLoaderJava5) previously initiated loading for a different type with name "org/w3c/dom/Element"

It was loaded from C:\projects\TRK\source\blank\target\jira\home\plugins\installed-plugins\blank-1.0.jar

'com.bcompany.trk.blank-tests' - 'blank' failed to load.
Application context initialization for 'com.bcompany.trk.blank-tests' has timed out waiting for (objectClass=com.bcompany.trk.blank.api.MyPluginComponent)

It has the following missing service dependencies :
&myComponent of type (objectClass=com.bcompany.trk.blank.api.MyPluginComponent)

It was loaded from C:\projects\TRK\source\blank\target\jira\home\plugins\installed-plugins\blank-1.0-tests.jar

********************************************************************************************************************************************************************************************************

 

Looking for errors like this, I found a way to solve the problem. I'm not sure if it is the better solution, but worked. In the jira-core dependecy, I add an exclusion to xml-apis

 

<dependency>
<groupId>com.atlassian.jira</groupId>
<artifactId>jira-core</artifactId>
<version>${jira.version}</version>
<scope>provided</scope>
<!-- exclude xml-apis - LinkageError on startup: org.w3c.dom.Element -->
<exclusions>
<exclusion>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
</exclusion>
</exclusions>
</dependency>

 

Anyone else has a different solution for this problem? It's documented anywhere?

 

This widget could not be displayed.

Hi,

I'm encountering the same problem. To avoid the org.w3c.dom.Element LinkageError I exclude the xml-apis from my dependency.

However now I get the NoClassDefFoundError and ClassNotFoundException for org.w3c.dom.Element. 

I already inserted all packages in <Import-Package> 

and even tried to add the xml-apis as a dependency in the pom.xml.

Do you found a solution to fix this?

Exclude xml-apis solved my problem. I'm running the blank plugin above, using the commands provided by atlassian sdk (atlas-run), version 6.2.14.

The version of Java is 1.8. Note that, Java 8, has the class org.w3c.dom.Element in the rt.jar

image.png

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Tuesday in Jira

What modern development practices are at the heart of how your team delivers software?

Hey Community mates! Claire here from the Software Product Marketing team. We all know software development changes rapidly, and it's often tough to keep up. But from our research, we've found the h...

165 views 1 3
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you