initComponent not invoked

I am building a plugin on IntelliJ. I am using JDK 6 as the SDK since all the intelliJ products that we have in our team run on Java 1.6. I have an application component, which reads some templates from a couple of files. Now, when the plugin is loaded, it is supposed to call the initComponent() method in my component, which reads data from the files. However, it doesn't invoke the initComponent method.
Everything works fine when I debug the plugin. However, when I build the jar for deployment, things break like I mentioned. Also with JDK 7, things are working as they are supposed to.

Here is the link to the ApplicationComponent. Can someone help me please!

2 comments
Comment actions Permalink

First of all, this code should be in a service and not a component. The way you've implemented it, the code is executed during every IntelliJ IDEA startup, while the splash screen is displayed, slowing down the startup for all users regardless of whether they're going to use your plugin in this particular session or not. If you convert it to a service, it will be executed exactly at the right time: the first time a feature of your plugin that requires the templates gets executed.

Second, to troubleshoot any issues like this one, you need to check whether there are any exceptions in idea.log.

0
Comment actions Permalink

Thanks for pointing it out.

I was able to debug the issue. The problem was with the resource paths in the jar file. During the debug mode, the plugin was running as a directory, so this line
<code>
            String basePath = new File(PathUtil.getJarPathForClass(getClass())).getAbsolutePath();
</code>

was picking up the correct path to the file. However, the plugin was deployed into a jar once built for distribution. So the above line was picking up the base path with .jar at the end. Silly mistake.

0

Please sign in to leave a comment.