Accessing Dependent ProjectComponent

I am attempting to create a plug-in that depends on an existing plug-in, but am having a problem accessing the ProjectComponent of the other plug-in (DBHelper in this case).

I added a ]]> tag to my plugin.xml, but if I simply call "project.getComponent(ProjectMain.class)" I get a null value back.

If I do something like this:
Class[] components = project.getComponentInterfaces();
for (Class c : components) {
if (c.getName().equals("dbhelp.plugin.idea.ProjectMain")) {
this.projectMain = (ProjectMain) project.getComponent(c);
I get an instance of projectMain back, but get a ClassCastException when I try to cast it to a ProjectMain. I'm assuming it is because the ProjectMain I get back is an istance of the class defined in a different classloader than my plug-in's.

Is there a way for me to do this? Also, is there any guarantee that the depended-on plug-in will be initialized before my plug-in so I can access it in my initComponent() method?


Comment actions Permalink

Hello Nathan,

you probably added the dbhelper-classes to your plugin module which causes them to be packaged with your plugin. Adding the libraries to the IDEA-JDK instead should work. Make sure that they are removed from the sandbox as well.


Comment actions Permalink

That did it, thanks!


Please sign in to leave a comment.