LinkageError when using jira-api and jira-core together

barbosa_s_alexandre July 25, 2017

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

0 votes
Hartmut Klein September 6, 2017

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?

barbosa_s_alexandre September 6, 2017

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

0 votes
barbosa_s_alexandre July 26, 2017

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?

 

0 votes
MattS
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 25, 2017

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

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events