tferr / Scripts

:microscope::cocktail: Home of the ImageJ BAR: A collection of Broadly Applicable Routines for ImageJ
https://imagej.net/BAR
GNU General Public License v3.0
24 stars 18 forks source link

BAR Op namespace failing #16

Closed tferr closed 8 years ago

tferr commented 8 years ago

@hinerm First of all thank you so much for all of your work in creating the first BAR Op!!, the tutorials and the wiki page. Impressive! Second, I am really sorry for not looking into it earlier. Simply other stuff got in the way. Third, I have to apologize also for merging your changes into my master branch in rather clumsy way. Anyway, just for reference, these are the relevant changes you introduced:

  1. tferr/Scripts@bc7271fb2bcf2d9bd818ef7c1235155a41afede4 (Add dependency on imagej-ops)
  2. tferr/Scripts@523c22dc127f4cdfb5d422eb6a2c853ed86839e2 (Create BAR Op namespace)
  3. tferr/Scripts@af2eeaad5b5170bf80fc87b72402bf278d6918a4 (Add BARService)
  4. tferr/Scripts@51f48c94c5054545a0f45e170b5f170948c33fec (Add GCD script template)
  5. tferr/Scripts@633dcfc03fde6fbf9574251c30dbd9587410afa4 (Create tutorial on adding external ops)

However, I get the following error in BAR.java: Type mismatch: cannot convert from Class<Namespace> to Class<? extends SciJavaPlugin>

When I try to run CGD.py, I get a java.lang.Error: Unresolved compilation problem: in Fiji's console.

I've tried all of Ecliple Mars Quick Fix suggestions without success. Any ideas?

hinerm commented 8 years ago

@tferr

  1. First we need to update your pom-fiji version to the latest (21.4.0)
  2. Then it looks like the API for Ops changed a bit so we need to update the DefaultGCD op so that it extends AbstractOp:
-public class DefaultGCD implements BAR.GCD {
+public class DefaultGCD extends AbstractOp implements BAR.GCD {
  1. Finally, for the BAR namespace to work in Scripts, we to release the fix I just committed to correct namespace population.

With these changes everything is working in my local Fiji :smile:

tferr commented 8 years ago

@hinerm Thanks a lot! I will wait for the new imagej-ops release.

tferr commented 8 years ago

Hi @hinerm,

Just did your proposed changes:

  1. tferr/Scripts@c68483ecc7566d9c91a05c211e691b705362f639 (Update fiji-pom to 21.4.0 and imagej-ops to 0.27.0)
  2. tferr/Scripts@04915a631fa871cacf2d674ba7f5ae23a7688438 (Modified DefaultGCD to extend AbstractOp)

I then updated the Maven Project, but I still get the same error. Any ideas?

tferr commented 8 years ago

@hinerm, All is great! Sorry for the noise, it does work despite the annoying Type mismatch: cannot convert from Class<Namespace> to Class<? extends SciJavaPlugin> error in Eclipse. Any idea what is causing it/ how can it be silenced?

Anyway: I've updated the wiki page to reflect the new changes. I've also add some GitHub links so there are always permanent URLs to the latest code and a short description to the script template.

Thanks a lot for doing all this. It is great to see how everything gets so well integrated. The thew bar Op even appears on the Ops Browser! And sincere apologies for not looking into it earlier. I do hope to have enough time to look into extending this further.

tferr commented 8 years ago

@hinerm, Not so sure what is going on here. I thought this was solved, and pushed the new version to the update site. However, on a clean Fiji install subscribed to the BAR update site, running GCD.py [Templates >BAR>GCD (Python)] from the Script Editor fails:

[ERROR] Cannot create plugin: class='bar.BAR', priority=0.0, enabled=true, pluginType=Namespace
java.lang.Error: Unresolved compilation problem: 
    Type mismatch: cannot convert from Class<Namespace> to Class<? extends SciJavaPlugin>

    at bar.BAR.<init>(BAR.java:12)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
    at java.lang.Class.newInstance(Class.java:442)
    at org.scijava.plugin.PluginInfo.createInstance(PluginInfo.java:304)
    at org.scijava.plugin.DefaultPluginService.createInstance(DefaultPluginService.java:236)
    at org.scijava.plugin.AbstractPTService.create(AbstractPTService.java:68)
    at net.imagej.ops.DefaultNamespaceService.create(DefaultNamespaceService.java:53)
    at net.imagej.ops.NamespacePreprocessor.assignNamespace(NamespacePreprocessor.java:76)
    at net.imagej.ops.NamespacePreprocessor.process(NamespacePreprocessor.java:62)
    at org.scijava.module.ModuleRunner.preProcess(ModuleRunner.java:104)
    at org.scijava.module.ModuleRunner.run(ModuleRunner.java:156)
    at org.scijava.module.ModuleRunner.call(ModuleRunner.java:126)
    at org.scijava.module.ModuleRunner.call(ModuleRunner.java:65)
    at org.scijava.thread.DefaultThreadService$2.call(DefaultThreadService.java:191)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
[ERROR] Module threw exception
java.lang.NullPointerException
    at net.imagej.ops.DefaultNamespaceService.create(DefaultNamespaceService.java:54)
    at net.imagej.ops.NamespacePreprocessor.assignNamespace(NamespacePreprocessor.java:76)
    at net.imagej.ops.NamespacePreprocessor.process(NamespacePreprocessor.java:62)
    at org.scijava.module.ModuleRunner.preProcess(ModuleRunner.java:104)
    at org.scijava.module.ModuleRunner.run(ModuleRunner.java:156)
    at org.scijava.module.ModuleRunner.call(ModuleRunner.java:126)
    at org.scijava.module.ModuleRunner.call(ModuleRunner.java:65)
    at org.scijava.thread.DefaultThreadService$2.call(DefaultThreadService.java:191)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
java.util.concurrent.ExecutionException: java.lang.NullPointerException
    at java.util.concurrent.FutureTask.report(FutureTask.java:122)
    at java.util.concurrent.FutureTask.get(FutureTask.java:192)
    at net.imagej.ui.swing.script.TextEditor.evalScript(TextEditor.java:2346)
    at net.imagej.ui.swing.script.TextEditor.access$1000(TextEditor.java:151)
    at net.imagej.ui.swing.script.TextEditor$20.execute(TextEditor.java:1937)
    at net.imagej.ui.swing.script.TextEditor$Executer$1.run(TextEditor.java:1749)
Caused by: java.lang.NullPointerException
    at net.imagej.ops.DefaultNamespaceService.create(DefaultNamespaceService.java:54)
    at net.imagej.ops.NamespacePreprocessor.assignNamespace(NamespacePreprocessor.java:76)
    at net.imagej.ops.NamespacePreprocessor.process(NamespacePreprocessor.java:62)
    at org.scijava.module.ModuleRunner.preProcess(ModuleRunner.java:104)
    at org.scijava.module.ModuleRunner.run(ModuleRunner.java:156)
    at org.scijava.module.ModuleRunner.call(ModuleRunner.java:126)
    at org.scijava.module.ModuleRunner.call(ModuleRunner.java:65)
    at org.scijava.thread.DefaultThreadService$2.call(DefaultThreadService.java:191)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

Any suggestions?

hinerm commented 8 years ago

@tferr

Type mismatch: cannot convert from Class to Class<? extends SciJavaPlugin>

there is a problem with BAR's annotation.. just like you saw in eclipse.. so I think it's not being annotated and thus not found by the Namespace service. I am confused as to what's actually going on, though.

I also don't see the warning in eclipse.. you imported BAR as a Maven project? I wonder if it's my own error/warning settings...

hinerm commented 8 years ago

OK @tferr so it looks like your jar was corrupted by being confused and picking up Eclipse classes.

To avoid this kind of corruption, I set up a Jenkins job for BAR. It can now deploy SNAPSHOT and RELEASE artifacts to the ImageJ maven repo (where you can download them for upload to your update site)

If you add a webhook to this repo Jenkins will build it automatically with each push. Then you can use the double push to master method of releasing new versions (note that you currently need to change your pom.xml version back to a SNAPSHOT)

tferr commented 8 years ago

Wow, this is superb.

mvn clean; mvn eclipse:clean eclipse:eclipse

Did it. Although 10 minutes later Eclipse started to complain about missing imports (on an unrelated class) even if the imports were properly declared. Eclipse is a beast. I guess I'll just keep running the command above every half an hour!

@hinerm Seriously, thanks a lot for looking into it. Just uploaded the new version to the update site and everything works as expected.

Next time at The Old Fashioned, its on me! 🍻

tferr commented 8 years ago

Closing this as all seems to be working now