Click here to Skip to main content
15,887,083 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
I'm currently struggling with the following issue: I need to use an interface in my plugin (PLUGIN A) that comes from another plugin (PLUGIN B). I'm also the developer on PLUGIN B so I can make code changes (if needed).

What I've done so far:

1. I've added the packaged jar from PLUGIN B to my local maven repository by using this command:


mvn install:install-file -Dfile=plugin-b.jar \
    -DgroupId=com.my.plugin.b -DartifactId=plugin-b \
    -Dversion=1.0.0 \
    -Dpackaging=jar



2. Afterwards I've added it as a dependency to the POM of my PLUGIN A:


<dependency>
            <groupId>com.my.plugin.b</groupId>
            <artifactId>plugin-b</artifactId>
            <version>1.0.0</version>
            <scope>provided</scope>
        </dependency>



This is also working so far as the plugin builds and I'm capable of doing an import of the interface:


import com.my.plugin.b.interfaces.MyInterface;



I can also use it in the IDE (IntelliJ) with all the code completion features. I was still having some troubles with the plugin not being installed on the server (could not find requirements) but this could be sorted out by adding this to the POM of PLUGIN A (inside the <import-package> tags of the "confluence-maven-plugin":


com.my.plugin.b.*;resolution:="optional",



But when I'm installing the now packaged version of PLUGIN A on my Confluence instance it gives me the following error in the logs when it comes to code execution:

java.lang.NoClassDefFoundError: com/my/plugin/b/interfaces/MyInterface



I've no idea how I can fix this. I've of course restarted the server and made a "mvn clean package" on the project.

Also I tried to use the scope "compiled" on the dependency pointing at PLUGIN B, but then the plugin doesn't do anything at all on the server and crashes with some spring related exceptions like:

getInstance Unable to create new reference LazyLoadedFilterReference{descriptor=com.my.plugin.b:rest-filter (null), filterConfig=com.atlassian.plugin.servlet.filter.PluginFilterConfig@82ha2js}


Probably because it got problems with a lot of some other services/components that are coming out of PLUGIN B and are used in PLUGIN A by using spring scanner annotations.

So anybody got an idea of what to do, what to check or how I can solve this issue?

Some more background information on the problem (explained without too much detail): In PLUGIN A the code is retrieving an object by a service that comes from a third party plugin (not in my responsibility, so no code access). In some cases the object returned by this service is an object of the type "MyInterface" because it is served by PLUGIN B. And I need to access this object and its method like defined in "MyInterface" for some calculations. I also tried creating an identical interface in PLUGIN A and cast it but all of this doesnt work.

Maybe this information helps to find another solution for my problem.

So anybody got an idea of what to do, what to check or how I can solve this issue?

Thanks in advance!

What I have tried:

Already being described in the problem text. :-)
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900