NOTICE! This is a static HTML version of a legacy Fiji BugZilla bug.

The Fiji project now uses GitHub Issues for issue tracking.

Please file all new issues there.

Bug 964 - Exception when running from the command line
Exception when running from the command line
Status: RESOLVED FIXED
Product: Fiji
Classification: Unclassified
Component: Other
unspecified
PC All
: P5 enhancement
Assigned To: ImageJ Bugs Mailing List
: 973
Depends on:
Blocks:
 
Reported: 2014-11-26 07:47 CST by Mark Hiner
Modified: 2014-12-16 08:43 CST
3 users (show)

See Also:

Description Mark Hiner 2014-11-26 07:47:05 CST
When running Fiji from the command line, I get an exception in the CodeHacker. This is interfering with command line options, such as running scripts directly (see https://groups.google.com/forum/#!topic/fiji-devel/QgucpfxRQ-s).


---------------

log4j:WARN No appenders could be found for logger (org.bushe.swing.event.EventService).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
java.lang.IllegalArgumentException: Cannot modify method: public void run()
	at net.imagej.patcher.CodeHacker.insertAtTopOfMethod(CodeHacker.java:167)
	at net.imagej.patcher.LegacyExtensions.injectHooks(LegacyExtensions.java:229)
	at net.imagej.patcher.LegacyInjector.inject(LegacyInjector.java:308)
	at net.imagej.patcher.LegacyInjector.injectHooks(LegacyInjector.java:109)
	at net.imagej.patcher.LegacyEnvironment.initialize(LegacyEnvironment.java:101)
	at net.imagej.patcher.LegacyEnvironment.applyPatches(LegacyEnvironment.java:495)
	at net.imagej.patcher.LegacyInjector.preinit(LegacyInjector.java:397)
	at net.imagej.patcher.LegacyInjector.preinit(LegacyInjector.java:376)
	at net.imagej.legacy.DefaultLegacyService.<clinit>(DefaultLegacyService.java:124)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
	at java.lang.Class.newInstance0(Class.java:357)
	at java.lang.Class.newInstance(Class.java:310)
	at org.scijava.service.ServiceHelper.createServiceRecursively(ServiceHelper.java:302)
	at org.scijava.service.ServiceHelper.createExactService(ServiceHelper.java:269)
	at org.scijava.service.ServiceHelper.loadService(ServiceHelper.java:231)
	at org.scijava.service.ServiceHelper.loadService(ServiceHelper.java:194)
	at org.scijava.service.ServiceHelper.loadServices(ServiceHelper.java:166)
	at org.scijava.Context.<init>(Context.java:244)
	at org.scijava.Context.<init>(Context.java:203)
	at org.scijava.Context.<init>(Context.java:142)
	at org.scijava.Context.<init>(Context.java:98)
	at org.scijava.Context.<init>(Context.java:86)
	at net.imagej.ImageJ.<init>(ImageJ.java:82)
	at net.imagej.Main.launch(Main.java:61)
	at net.imagej.Main.main(Main.java:73)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at net.imagej.launcher.ClassLauncher.launch(ClassLauncher.java:258)
	at net.imagej.launcher.ClassLauncher.run(ClassLauncher.java:184)
	at net.imagej.launcher.ClassLauncher.main(ClassLauncher.java:76)
Caused by: java.lang.IllegalArgumentException: No such class: JavaScriptEvaluator
	at net.imagej.patcher.CodeHacker.getClass(CodeHacker.java:880)
	at net.imagej.patcher.CodeHacker.getMethod(CodeHacker.java:906)
	at net.imagej.patcher.CodeHacker.getBehavior(CodeHacker.java:896)
	at net.imagej.patcher.CodeHacker.insertAtTopOfMethod(CodeHacker.java:158)
	... 34 more
Caused by: javassist.NotFoundException: JavaScriptEvaluator
	at javassist.ClassPool.get(ClassPool.java:450)
	at net.imagej.patcher.CodeHacker.getClass(CodeHacker.java:875)
	... 37 more
Comment 1 Luc Deschenaux 2014-12-02 02:58:25 CST
For me it's a blocker since I use Fiji for batch processing in headless mode 24/7 ... 

I had to update because i needed to update bio-formats, will try to update only bio-formats in the meanwhile.

Thanks in advance :-)
Comment 2 Curtis Rueden 2014-12-03 16:46:49 CST
Thanks for the report!

Firstly, please note that this exception is not actually a crash, but merely a warning.

Secondly, Johannes kindly fixed this problem earlier today:
  https://github.com/imagej/ij1-patcher/pull/32

This fix will become available from the ImageJ Updater within a few days' time.
Comment 3 Mark Hiner 2014-12-11 11:51:11 CST
*** Bug 973 has been marked as a duplicate of this bug. ***
Comment 4 Curtis Rueden 2014-12-11 11:55:26 CST
This fix is now available via the Help > Update command.
Comment 5 Luc Deschenaux 2014-12-12 01:56:34 CST
Thanks for all!

.. but --run is still not running anything (silently, no more exception) :-/

Should I open another bug request, since no exception is raised ?.. 

Regards,

Luc
Comment 6 Curtis Rueden 2014-12-12 11:18:33 CST
Hi, Luc. I tried an up-to-date Fiji with the following script:

import sys
from ij import IJ
print "Hello stdout!"
IJ.log("Hello IJ log!")
sys.exit()

Using the following invocation:

Contents/MacOS/ImageJ-macosx --headless /Users/curtis/hello.py

And the output:

Hello stdout!
Hello IJ log!

And the program terminates as expected.

I am on OS X 10.10.

Does the above script behave the same on your system? If not, yes, please file a new bug using Help > Report a Bug, to send your system configuration.

Thanks!
Comment 7 Curtis Rueden 2014-12-12 11:20:12 CST
By the way, if you run the launcher with the "--help" flag you will see the list of possible arguments. The "--run" argument is meant to take a <plugin>, not a script. So that might be the source of your woes. See also http://imagej.net/Headless
Comment 8 Luc Deschenaux 2014-12-12 23:45:43 CST
Actually it's a plugin I am trying to run: https://github.com/luxigo/imagej-elphel

Command line was like:
ImageJ-linux64 --headless --run Eyesis_Correction prefs=config.xml

Maybe something changed in the way plugins are run since Fiji Life-Line version, 2014 june 2 ? (it does not work with more recent versions)

Didnt try to run it from a script neither
Comment 9 Curtis Rueden 2014-12-15 11:04:17 CST
It seems there is no "--run" argument. ImageJ 1.x does have a "-run" (one dash) argument though -- does that work better for you?
Comment 10 Luc Deschenaux 2014-12-16 00:05:36 CST
Maybe there's no more --run option but it still does in the ImageJ-linux64 --help output:
  --run <plugin> [<arg>]
        run <plugin> in ImageJ, optionally with arguments

With '-run' I was not able to pass parameters and ImageJ does not exit on headless exception (occuring when a specified path is missing and the file dialog is instantiated).

Using '-macro' ImageJ does not exit on headless exception neither ('run("Quit");' did not help) and using '-batch' ImageJ get stuck with 100% CPU usage ...

However at first glance it seems that running the plugin from a jython script with 'ImageJ-linux64 --headless <script>' is working - parameters can be specified and ImageJ exits on failure - so I can survive without '--run'.

Thanks for all :-)
Comment 11 Curtis Rueden 2014-12-16 08:43:01 CST
My apologies, Luc -- you're right. The ImageJ Launcher _also_ has a --run option. I have filed a new issue to track this problem: https://github.com/imagej/imagej-launcher/issues/24