New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fails to recognize external extensions #64

Closed
tnyblom opened this Issue Sep 2, 2015 · 2 comments

Comments

Projects
None yet
2 participants
@tnyblom

tnyblom commented Sep 2, 2015

I have an issue with external plugins.
They all load but fails to get recognized as plugins extending the correct extension point.

I took the demo project and extended it with one more plugin that is loaded from a .zip file. But when I did this I always get this error:

DEBUG ro.fortsoft.pf4j.DefaultExtensionFinder - 'test.pf4j.main.Greeting' is not assignable from extension point 'test.pf4j.plugins.CheersPlugin$WelcomeGreeting'

The exact same code works if I just move it into the same jar file as the main program.

Interface:

public interface Greeting extends ExtensionPoint {
    public String getGreeting();
}

Plugin:

public class CheersPlugin extends Plugin {
    public CheersPlugin(PluginWrapper wrapper) {
        super(wrapper);
    }

    @Extension
    public static class WelcomeGreeting implements Greeting {
        @Override
        public String getGreeting() {
            return "Cheers from outside";
        }
    }
}
@tnyblom

This comment has been minimized.

tnyblom commented Sep 2, 2015

Identified the issue.

Since the .zip file for the external plugin as default includes the .jar file containing the interface this is used rather then the original one. This leads to that there are two different interface objects in two different classloaders and hence the isAssignableFrom call fails.

Solution: make sure that the plugins .zip file doesn't contain any unwanted libs.

@tnyblom tnyblom closed this Sep 2, 2015

@decebals

This comment has been minimized.

Member

decebals commented Sep 2, 2015

Great. I have met many situations like this. The log of pf4j is very detailed on debug and you can see where is the problem (you can see what classes are loaded by each plugin class loader).
One of my idea related to pf4j is to create a possibility (a command line tool or something else) to write a report/document (with plugins dependency - similar with dependency:tree from maven, what extension points declare a plugin, what extensions supply a plugin, and other useful information). It's important to see the big picture when you work with multiple plugins/extensions. Maybe someone in the future is interested by this idea.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment