We have recently created a new input parameter type by implementing a new InputWidget in our java written plugins. The new data type is simply an extension of net.imagej.table.AbstractTable called SDMMResultsTable in which we have added some useful utility methods. The InputWidget works great, however, we found that it only works if we provide the full class path for the type. Just providing the class name alone doesn’t work. So far we have only tested this in groovy. Is there a way to resolve this issue so we can just write the class name?
So, for example, if we write a groovy script that retrieves the name of the table (which we have added in our custom implementation):
import de.mpg.biochem.sdmm.table.SDMMResultsTable
#@ SDMMResultsTable table
#@OUTPUT String name
name = table.getName()
We get the following error message:
[WARNING] Invalid class: SDMMResultsTable
javax.script.ScriptException: Unknown type: SDMMResultsTable
at org.scijava.script.DefaultScriptService.lookupClass(DefaultScriptService.java:216)
at org.scijava.script.process.ParameterScriptProcessor.parseParam(ParameterScriptProcessor.java:213)
at org.scijava.script.process.ParameterScriptProcessor.parseParam(ParameterScriptProcessor.java:178)
at org.scijava.script.process.ParameterScriptProcessor.process(ParameterScriptProcessor.java:169)
at org.scijava.script.process.ParameterScriptProcessor.process(ParameterScriptProcessor.java:138)
at org.scijava.script.process.ScriptProcessorService.process(ScriptProcessorService.java:79)
at org.scijava.script.ScriptInfo.parseParameters(ScriptInfo.java:293)
at org.scijava.module.AbstractModuleInfo.initParameters(AbstractModuleInfo.java:192)
at org.scijava.module.AbstractModuleInfo.inputList(AbstractModuleInfo.java:154)
at org.scijava.module.AbstractModuleInfo.inputs(AbstractModuleInfo.java:96)
at org.scijava.module.process.GatewayPreprocessor.process(GatewayPreprocessor.java:66)
at org.scijava.module.ModuleRunner.preProcess(ModuleRunner.java:105)
at org.scijava.module.ModuleRunner.run(ModuleRunner.java:157)
at org.scijava.module.ModuleRunner.call(ModuleRunner.java:127)
at org.scijava.module.ModuleRunner.call(ModuleRunner.java:66)
at org.scijava.thread.DefaultThreadService$3.call(DefaultThreadService.java:238)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.IllegalArgumentException: Cannot load class: SDMMResultsTable
at org.scijava.util.Types.iae(Types.java:959)
at org.scijava.util.Types.load(Types.java:218)
at org.scijava.util.Types.load(Types.java:139)
at org.scijava.script.DefaultScriptService.lookupClass(DefaultScriptService.java:211)
... 19 more
Caused by: java.lang.ClassNotFoundException: SDMMResultsTable
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at org.scijava.util.Types.load(Types.java:210)
... 21 more
[WARNING] Ignoring invalid parameter: SDMMResultsTable table
However, the following runs with no errors and our custom InputWidget is called up when generating the input dialog:
#@ de.mpg.biochem.sdmm.table.SDMMResultsTable table
#@OUTPUT String name
name = table.getName()
The result of this script is a text window with the table name.
I looked around a little but I couldn’t find a similar post and it wasn’t immediately clear to me how to fix this problem. Interestingly, our custom ResultsTableService which is in the same package as SDMMResultsTable can be used as an input parameter without the full path. I assume this is because of how Services are loaded at runtime. I wonder then if there is a custom plugin type we should use for our table to make it visible to the class lookup process.