Script does not run in headless mode using the docker image

imagej

#1

Hi,

For some reason I’m unable to run a simple test script in headless mode using the ImageJ docker image. If anyone can offer any help, it would be appreciated.

Based on documentation on using the docker image and scripting in headless mode I’ve done the following:

host > docker run -it -v [path/to/scripts/on/host]:/scripts --rm fiji/fiji:fiji-oracle-jdk6 /bin/bash
docker > cd /scripts
docker > ImageJ-linux64 --ij2 --headless --console --run test.py

where test.py is:

from ij import IJ

IJ.log("Hello world")

The output I get is:

java.lang.IllegalArgumentException: Could not handle HTTPS in public boolean install(java.lang.String path) in ij.plugin.PluginInstaller
	at net.imagej.patcher.CodeHacker.handleHTTPS(CodeHacker.java:1221)
	at net.imagej.patcher.LegacyExtensions.injectHooks(LegacyExtensions.java:286)
	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:267)
	at org.scijava.Context.<init>(Context.java:224)
	at org.scijava.Context.<init>(Context.java:163)
	at org.scijava.Context.<init>(Context.java:119)
	at org.scijava.Context.<init>(Context.java:107)
	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)
Oct 26, 2018 5:24:10 PM java.util.prefs.FileSystemPreferences$2 run
INFO: Created user preferences directory.

It hangs for about a minute or two, then exits quietly.

If I run with the --debug option, I see that it gets past the IllegalArgumentException, and the last part of what it prints before hanging and eventually exiting is:

[DEBUG] INPUTS:
[DEBUG] OUTPUTS:
[DEBUG] publish(
	context = org.scijava.Context@174323d5
	consumed = false
	module = net.imagej.updater.CheckForUpdates
	processor = org.scijava.module.process.DebugPostprocessor@1a0283e,null,null), called from non-EDT Thread:null
[DEBUG] publish(
	context = org.scijava.Context@174323d5
	consumed = false
	module = net.imagej.updater.CheckForUpdates
	processor = org.scijava.display.DisplayPostprocessor@39b1ff47,null,null), called from non-EDT Thread:null
[DEBUG] publish(
	context = org.scijava.Context@174323d5
	consumed = false
	module = net.imagej.updater.CheckForUpdates,null,null), called from non-EDT Thread:null
[DEBUG] publish(
	context = org.scijava.Context@174323d5
	consumed = false
	progress = -1
	maximum = -1
	status = Command finished: Up-to-date check
	warning = false,null,null), called from non-EDT Thread:null

I’ve tested this with Docker tags fiji-openjdk-6, fiji-oracle-jdk6 and fiji-oracle-jdk7 and gotten the same results every time.

The java versions in these three containers are 1.6.0_34, 1.6.0_45, and 1.7.0_76, respectively.