<html>
    <head>
      <base href="http://fiji.sc/bugzilla/" />
    </head>
    <body>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_NEEDSINFO "
   title="NEEDSINFO - Cannot run commands from the ijpb/MorphoLibJ plugin in --headless mode using --jython script option"
   href="http://fiji.sc/bugzilla/show_bug.cgi?id=1107#c3">Comment # 3</a>
              on <a class="bz_bug_link 
          bz_status_NEEDSINFO "
   title="NEEDSINFO - Cannot run commands from the ijpb/MorphoLibJ plugin in --headless mode using --jython script option"
   href="http://fiji.sc/bugzilla/show_bug.cgi?id=1107">bug 1107</a>
              from <span class="vcard"><a class="email" href="mailto:ghv2@psu.edu" title="Greg Von Kuster <ghv2@psu.edu>"> <span class="fn">Greg Von Kuster</span></a>
</span></b>
        <pre>  (In reply to Curtis Rueden from <a href="show_bug.cgi?id=1107#c2">comment #2</a>)

Hello Curtis,

Thanks very much for you response to my questions.  Please see my inline
comments.

<span class="quote">> Thanks for the report, Greg.

> Firstly, please note that there is a serious bug preventing Jython scripts
> from working headlessly on Windows:

> <a href="https://github.com/imagej/imagej/issues/114">https://github.com/imagej/imagej/issues/114</a></span >

This is no problem for me.  I am developing on and for only Mac OS X and Linux
x86_64.

<span class="quote">> 
> If you are using Windows, as a workaround, you can use any other scripting
> language besides Jython. Obviously we hope to fix this in the future, but
> cannot promise a timeline right now.

> Anyway, I'm guessing you are on a different OS, since you say the script
> finishes successfully...

> Secondly, note that ImageJ2's headless mode is an extension of ImageJ1 to
> work headless in only certain cases. Some plugins will simply not work
> headless, due to hardcoded usage of headless-unfriendly GUI elements. The
> typical symptom there is java.awt.HeadlessException being thrown, which from
> your description I assume you are not seeing either?</span >

I'm thinking that this is the likely culprit.  Some plugins just do not seem to
work in headless mode, while others work perfectly.

<span class="quote">> 
> Off the top of my head, I do not have an easy answer for you for grabbing
> handles to existing images while headless. (The WindowManager won't work
> because it is unfortunately a UI element which needs to be overridden.)

> Regarding the NullPointerException, that sounds like a likely culprit and it
> would be helpful if you could paste the full stack trace of that message.</span >

I will paste the full stack trace of 3 plugins that behave in this way in
separate comments.

<span class="quote">> 
> Looking at the Edge Detection plugin source code, I see several serious
> potential issues with using them headless:

> * The Conn_Tres is a PlugInFrame, which is a UI element.
> * There are multiple calls to WindowManager.getCurrentImage(), which (IIRC)
> may not work correctly headless.

> In short, the headless mode is fraught with difficulty, especially when
> third party plugins are involved. Your best bet is probably to install xvfb
> on your headless machine and run your scripts that way, so that your scripts
> behave better.</span >

I will try this approach next to see if I an make the problematic plugins work
from the command line.  Thanks for this pointer - I did see some comments on
this in my searches, but have not yet implemented my tools to use it.

<span class="quote">> 
> Or, if you are running these scripts on your local machine (i.e., not a
> headless server or cluster somewhere), then why use --headless at all? Just
> don't pass that flag.</span >

I am wrapping ImageJ2 tools in Galaxy (<a href="https://galaxyproject.org">https://galaxyproject.org</a>), and in order
to do this, I need to run the tools from the command line.  I've wrapped
several tools so far using various Fiji plugins and am planning to wrap as many
more as possible.  These tools are available at
<a href="https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2">https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2</a>


<span class="quote">> 
> I am marking this as NEEDSINFO in case you want to provide more detail on
> the NullPointerException, or if you can isolate more specifics about how
> things go wrong, what you expect to happen instead, etc. If xvfb and/or not
> using --headless works for you instead though, then I would favor closing
> this issue as "WONTFIX" since we don't have the resources this year to
> improve ImageJ's legacy headless mode.</span ></pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>