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

Getting a NoClassDefFoundException in wired integration test when trying to use class from my main package

Sander Kleykens July 11, 2013

I'm getting a NoClassDefFoundException exception in one of my wired integration tests when I try to use some of the classes in my main packages.

For instance, I try to do this:

MyResultClass result = componentBeingTested.myMethod();
assertEquals(MyResultType.TYPE_ONE, result.getType());

And I would get a NoClassDefFoundException about the class containing the MyResultType enum on the assert line.

10 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
Alexej Geldt
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.
August 17, 2014

same here with JIRA 5.2.11

it's not just entities that are affected. I am stuck with my own POJO's and my own Exception class.

This seems to be related to the packaging. There are classes missing in the test bundle. Maybe we have to declare them somewhere? However i couldn't find any documentation.

1 vote
beauchef August 6, 2014

I have the same issue with the simple Unit tests as well. I have a simple auto-generated unit test for my plug-in. It runs fine with atlas-unit-test. But I get a java.lang.NoClassDefFoundError when I run the same test through the JIRA plug-in test console.

1 vote
beauchef August 6, 2014

I have the EXACT same issue. I can't believe there is no answer to this question!? I followed the simple instructions to create a Wired test using the AtlassianPluginsTestRunner class. I inject ActiveObjects. But when I try to retrieve one of my entities, I get a java.lang.NoClassDefFoundError ! What am I missing?

1 vote
thomas_strecker_cc May 20, 2014

Are there any news on this topic? I'm stuck there, too.

I know I have the option to make my plugin export its packages by adding to the POM:

<instructions>
    <Export-Package>...</Export-Package>
</instructions>

However, these exports should not exist in the final product, so I would like to see them only in the test phase. Does anyone have an idea how to achieve this?

1 vote
Colin Goudie
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.
February 24, 2014

Any update on issues like this? I'm getting a similar issue

0 votes
Boris Georgiev _Appfire_
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 14, 2013

This problem seems like something related to the packaging of the plugin and the tests. If you can send me the code or the project with just the test and the classes it references (including the pom.xml and atlassian-plugin.xml), so I can test locally I'll try to help.

0 votes
Sander Kleykens July 14, 2013

Extracting the AggregationReturnType doesn't seem to fix it, unfortunately.

The following piece of test code gives the same NoClassDefFoundException on the cast to WebServiceAggregationResultNumber:

WebServiceAggregationResultNumber result = (WebServiceAggregationResultNumber) aggregationManager.aggregateByFilter("10005", "customfield_10002", "min", "number", userManager.getUser("admin"));
assertEquals((Double) 0.5, (Double) result.getValue());

I am getting similar issues running my unit tests through the plugin test console (ClassNotFoundExceptions). They work fine when run with atlas-unit-test.

I have other wired tests that run fine, but they don't use any classes from my main package except for the components I'm testing (but those get injected).

0 votes
Boris Georgiev _Appfire_
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 14, 2013

Can you try to extract the AggregationReturnType in its own class so it's not an inner class ? I can't give exact reason for the failure but I suspect that there might be some problem with AggregationReturnType being inner class.

0 votes
Sander Kleykens July 13, 2013

Yes, it happens even after a clean.

This is the part of the server log when I run the test class (it only shows 1 actual test, the other tests result in the same stuff being written to the server log). The AggregationReturnType is the MyResultType enum from my question.

The "java.lang.UnsupportedOperationException: Attempted to serialize java.lang.Class: mypackage.common.representation.ErrorCollectionRepresentation. Forgot to register a type adapter?" is also unusual since I have tests (in other test classes) that test if my REST resources provide error information on bad input and the ErrorCollectionRepresentation seems to get serialized fine there.

This is my plugin's pom.xml.

0 votes
Boris Georgiev _Appfire_
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 12, 2013

Is this happening after cleaning and rebuilding your plugin and running tests again ?

If yes - please provide more information like logs and your plugins pom.xml file.

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events