Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Unable to use Jsoup inside Jira plugin

Andrei RIPA April 14, 2015

Hello,

In my Jira plugin, I want to use Jsoup in order to get some html elements, but I get the following error java.lang.NoClassDefFoundError: org/jsoup/Jsoup (I don't get any error when I'm using it from a simple Java project).

I've added the jsoup-1.8.2.jar to referenced libraries and restarted Jira.

Thanks!

2 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

2 votes
Answer accepted
Andrei RIPA April 15, 2015

It seams that atlas-run doesn't do it's job properly, so after atlas-clean, I had to do atlas-compile and then atlas-package (they are included in atlas-run but aren't working as they should).

I also put the scope parameter and set it like this:

<dependency>
    <groupId>org.jsoup</groupId>
    <artifactId>jsoup</artifactId>
    <version>1.8.2</version>
    <scope>compile</scope>
</dependency>
Volodymyr Krupach
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.
April 16, 2015

<scope>compile</scope> is default. So omitting it is fine. Important is to NOT to use <scope>provided</scope> that indicates that dependency is expected be provided at run-time by container and so is NOT packaged with plugin.

Andrei RIPA April 16, 2015

Are you sure that compile is default? (I'm asking this because my project only worked after I've added that line - I didn't had the scope parameter declared at all)

Volodymyr Krupach
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.
April 16, 2015

Sure https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Dependency_Scope: compile This is the default scope, used if none is specified. Compile dependencies are available in all classpaths of a project. Furthermore, those dependencies are propagated to dependent projects.

4 votes
Volodymyr Krupach
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.
April 14, 2015

Hi Andrei,

JIRA plugins are packed as OSGI modules (https://developer.atlassian.com/docs/atlassian-platform-common-components/plugin-framework/behind-the-scenes-in-the-plugin-framework/going-from-plugin-to-osgi-bundle) and you can not load classes from the classpath.

Right way is to add dependency to pom.xml. I think it should look like:

&lt;dependency&gt;
&lt;groupId&gt;org.jsoup&lt;/groupId&gt;
&lt;artifactId&gt;jsoup&lt;/artifactId&gt;
&lt;version&gt;1.8.2&lt;/version&gt;
&lt;/dependency&gt;

After adding the dependency make sure to run

atlas-mvn eclipse:eclipse

in your project dir and refresh eclipse project.

Andrei RIPA April 14, 2015

Thank you for such a fast answer! I've added that dependency and updated my project, but I still get the same error. (I've removed the old jar and, after updating, a new one has been added). I still don't get any error from eclipse so it can see the jsoup library ...

Gabor Nagy _Midori_
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.
April 14, 2015

Seems trivial but have you tried to run an "atlas-clean" command after changing dependencies? It might help.

Volodymyr Krupach
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.
April 14, 2015

Please try to clean your dev JIRA instance by running in your project dir: atlas-clean And do not instantiate through reflection. Just plain java code.

Andrei RIPA April 14, 2015

Yes, I've run the following: atlas-clean, atlas-mvn eclipse:eclipse and then atlas-debug

Volodymyr Krupach
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.
April 14, 2015

It should work! Make sure that you have NOT copy pasted <scope>provided</scope> for your dependency.

TAGS
AUG Leaders

Atlassian Community Events