Debugging JTV plugin in Eclipse

Help
2006-10-01
2013-05-15
  • Martin Szugat

    Martin Szugat - 2006-10-01

    Hi!

    Can anybody explain me how to set up Eclipse to debug a JTV plugin (e.g. DataTable) project? I'd like to implement a plugin that performs an overrepresentation analysis.

    Best regards

    Martin

     
    • Alok Saldanha

      Alok Saldanha - 2006-10-02

      Hello Martin,

      I am not sure what you mean by debugging. I have
      been using Eclipse as an IDE to develop plugins,
      but not as a debugger.

      I imagine you would need to check out the LinkedView project as well, compile the plugin to a jar, and then run LinkedView in the debugger.

      You may need to overwrite lib/nanoxml with the one from the distribution, since for some reason CVS messed up the nanoxml jar. Also, you will probably have to monkey with LinkedViewApp.getCodeBase() to get treeview to run in the debugger, since it currently assumes that treeview is packaged up in a jar file.

      There might be a more elegant way... I hope this helps.

       
    • Martin Szugat

      Martin Szugat - 2006-10-02

      Hi Alok,

      By debugging I mean: I like to inspect variables during execution, setting break points, etc.

      The problem is: I created two Eclipse projects: one is derived from DataTable and contains my plugin code. The other is the LinkedView project. If I start the LinkedView project (the class LinkedViewApp) within Eclipse I get the following error:

      java.net.MalformedURLException
          at java.net.URL.<init>(Unknown Source)
          at java.net.URL.<init>(Unknown Source)
          at java.net.URL.<init>(Unknown Source)
          at edu.stanford.genetics.treeview.app.LinkedViewApp.getCodeBase(LinkedViewApp.java:293)
          at edu.stanford.genetics.treeview.app.LinkedViewApp.scanForPlugins(LinkedViewApp.java:66)
          at edu.stanford.genetics.treeview.app.LinkedViewApp.<init>(LinkedViewApp.java:54)
          at edu.stanford.genetics.treeview.app.LinkedViewApp.main(LinkedViewApp.java:245)
      Exception in thread "main" java.lang.NullPointerException
          at edu.stanford.genetics.treeview.app.LinkedViewApp.scanForPlugins(LinkedViewApp.java:67)
          at edu.stanford.genetics.treeview.app.LinkedViewApp.<init>(LinkedViewApp.java:54)
          at edu.stanford.genetics.treeview.app.LinkedViewApp.main(LinkedViewApp.java:245)

      If I use the the installation directory of JTV as the working directory, it works as expected, but my plugin is not loaded because it is not packed as a JAR file. As I understand you there is really no possibility to load a plugin without having a JAR file?

      Thanks for your answers!

      Martin

       
      • Alok Saldanha

        Alok Saldanha - 2006-10-02

        You can force loading of a particular plugin by adding the following line to the end of TreeViewApp.main() (or anywhere else)

        Class c = thisClass.getClassLoader().loadClass( "path.to.YourPluginFactory");
        PluginFactory pp = (PluginFactory) c.newInstance();

        This should load the plugin as long as the plugin class is within the classpath by exactly the same mechanism as scanForPlugins().

        However, the MalformedURLException is happening (I think) because LinkedViewApp expects to be run from a JAR file. I didn't add a check for when it is not, although it would not be hard. For the time being, you may be able to replace LinkedViewApp.getCodeBase() with something like

        public URL getCodeBase() {
           return (new File(".")).toURL();
        }

         
        • Alok Saldanha

          Alok Saldanha - 2006-10-02

          incidentally, the plugin loading is triggered by class loading through a static initializer. The only purpose of calling loadClass() and newInstance() is to force loading of the class, which is why you don't need to actually do anything with the returned class/instance.

           
      • Alok Saldanha

        Alok Saldanha - 2006-10-03

        Dear Martin,

        I just added a check to the TreeViewApp so that it should run fine within the eclipse debugger.

        In setting this up, I ran the ant "plugin" task to generate the plugin jars in a /plugin subdirectory of the eclipse project. If you don't want to package your plugin into a jar when you debug it, you'll need to add the bin directory of the plugin project to the classpath of the LinkedView project (or just import all the classes into the LinkedView project) and then force loading of the plugin with the trick I described in my other message.

        Good luck!

         
        • Alok Saldanha

          Alok Saldanha - 2006-10-03

          P.S. you'll need to check the source code out from CVS in order to get the patch that lets it run from eclipse... I'll probably put out a bugfix release early next week with this and some other patches.

           
    • Martin Szugat

      Martin Szugat - 2006-10-04

      Hi Alok,

      Thank you very much! It works fine!

      Martin

       

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks