biocompibens / SME

Smooth 2D manifold extraction from 3D image stack
GNU General Public License v3.0
21 stars 3 forks source link

Problem with the class org.apache.commons.math3.random.JDKRandomGenerator #5

Open Eviatar opened 7 years ago

Eviatar commented 7 years ago

Error message when running plugin:

Padding Done ! There was a problem with the class org.apache.commons.math3.random.JDKRandomGenerator which can be found here: /Applications/Fiji.app/jars/commons-math3-3.4.1.jar /Applications/Fiji.app/plugins/SME_stacking.jar

WARNING: multiple locations found! java.lang.NoSuchMethodError: org.apache.commons.math3.random.JDKRandomGenerator.(I)V at SME_PROJECTION_SRC.SME_ENS_KmeanControl.Kmeans(SME_ENS_Kmean_Control.java:351) at SME_PROJECTION_SRC.SME_ENS_Kmean_Control.applyKmeans(SME_ENS_Kmean_Control.java:47) at SME_PROJECTION_SRC.SME_Plugin_Get_Manifold.runKmeans(SME_Plugin_Get_Manifold.java:180) at SME_PROJECTION_SRC.SME_Plugin_Simple_CONF.runKmeansStep(SME_Plugin_Simple_CONF.java:92) at SME_PROJECTION_SRC.SME_Plugin_Simple_CONF.getManifold(SME_Plugin_Simple_CONF.java:78) at SME_PROJECTION_SRC.SME_Plugin_Simple_CONF.runConfColour(SME_Plugin_Simple_CONF.java:329) at SME_PROJECTION_SRC.SME_Plugin_Simple.run(SME_Plugin_Simple.java:249) at ij.IJ.runUserPlugIn(IJ.java:217) at ij.IJ.runPlugIn(IJ.java:181) at ij.Executer.runCommand(Executer.java:137) at ij.Executer.run(Executer.java:66) at java.lang.Thread.run(Thread.java:748)

java.lang.NoSuchMethodException: Could not find method org.apache.commons.math3.random.JDKRandomGenerator.(I)V There was a problem with the class org.apache.commons.math3.random.JDKRandomGenerator which can be found here: /Applications/Fiji.app/jars/commons-math3-3.4.1.jar /Applications/Fiji.app/plugins/SME_stacking.jar

WARNING: multiple locations found! java.lang.NoSuchMethodError: org.apache.commons.math3.random.JDKRandomGenerator.(I)V at SME_PROJECTION_SRC.SME_ENS_KmeanControl.Kmeans(SME_ENS_Kmean_Control.java:351) at SME_PROJECTION_SRC.SME_ENS_Kmean_Control.applyKmeans(SME_ENS_Kmean_Control.java:47) at SME_PROJECTION_SRC.SME_Plugin_Get_Manifold.runKmeans(SME_Plugin_Get_Manifold.java:180) at SME_PROJECTION_SRC.SME_Plugin_Simple_CONF.runKmeansStep(SME_Plugin_Simple_CONF.java:92) at SME_PROJECTION_SRC.SME_Plugin_Simple_CONF.getManifold(SME_Plugin_Simple_CONF.java:78) at SME_PROJECTION_SRC.SME_Plugin_Simple_CONF.runConfColour(SME_Plugin_Simple_CONF.java:329) at SME_PROJECTION_SRC.SME_Plugin_Simple.run(SME_Plugin_Simple.java:249) at ij.IJ.runUserPlugIn(IJ.java:217) at ij.IJ.runPlugIn(IJ.java:181) at ij.Executer.runCommand(Executer.java:137) at ij.Executer.run(Executer.java:66) at java.lang.Thread.run(Thread.java:748)

at SME_PROJECTION_SRC.SME_ENS_Kmean_Control.Kmeans_(SME_ENS_Kmean_Control.java:351)
at SME_PROJECTION_SRC.SME_ENS_Kmean_Control.applyKmeans(SME_ENS_Kmean_Control.java:47)
at SME_PROJECTION_SRC.SME_Plugin_Get_Manifold.runKmeans(SME_Plugin_Get_Manifold.java:180)
at SME_PROJECTION_SRC.SME_Plugin_Simple_CONF.runKmeansStep(SME_Plugin_Simple_CONF.java:92)
at SME_PROJECTION_SRC.SME_Plugin_Simple_CONF.getManifold(SME_Plugin_Simple_CONF.java:78)
at SME_PROJECTION_SRC.SME_Plugin_Simple_CONF.runConfColour(SME_Plugin_Simple_CONF.java:329)
at SME_PROJECTION_SRC.SME_Plugin_Simple.run(SME_Plugin_Simple.java:249)
at ij.IJ.runUserPlugIn(IJ.java:217)
at ij.IJ.runPlugIn(IJ.java:181)
at ij.Executer.runCommand(Executer.java:137)
at ij.Executer.run(Executer.java:66)
at java.lang.Thread.run(Thread.java:748)
imagejan commented 7 years ago

The problem is that SME_Stacking.jar defines class names that are already provided by the Apache commons-math3 included in Fiji. This leads to version skew and, as you experienced, can break existing plugins. The solution (on the developer side) is to not override those classes, but either:

From the user perspective, you can try to delete commons-math3-3.4.1.jar, but it will certainly break other plugins in your Fiji installation.

erexhepa commented 7 years ago

Hi

Apologies for the late reply. Just back from vacations.

We did a lot of tests with Fiji on different architectures to ensure there were no problems with the Apache library and they did work. The only problem that can arrise is that we have the Apache library included in our jar and you might have the apache library alread with Fiji. We do not overwrite classes of the Apache library.

The class names definition during execution (i.e. the ones that comes with our jar and the one present in Fiji) should generate a Warning but no Exception should be generated. The class defined in the library provided by us is used since it is that one that is specifically included in our code. I will have a look on again on the error trace.

erexhepa commented 7 years ago

@Eviatar

Would it be possible for you to attach the image that generates the error above ?

imagejan commented 7 years ago

@erexhepa wrote:

We do not overwrite classes of the Apache library.

The issue is not with overwriting, but with shipping the library in an Uber-JAR, as it can lead to version skew, see: https://imagej.net/Uber-JAR

erexhepa commented 7 years ago

yes sorry misunderstood what you meant above.

tlambert03 commented 6 years ago

i'm also getting an exception in addition to a warning. Full trace below. Happy to provide whatever additional system info you think is relevant

There was a problem with the class org.apache.commons.math3.random.JDKRandomGenerator which can be found here:
/Applications/Fiji.app/jars/commons-math3-3.4.1.jar
/Applications/Fiji.app/plugins/ij-plugins/commons-math3-3.6.1.jar
/Applications/Fiji.app/plugins/SME_stacking.jar
/Applications/Fiji.app/plugins/Thunder_STORM.jar

WARNING: multiple locations found!
java.lang.NoSuchMethodError: org.apache.commons.math3.random.JDKRandomGenerator.<init>(I)V
    at SME_PROJECTION_SRC.SME_ENS_Kmean_Control.Kmeans_(SME_ENS_Kmean_Control.java:351)
    at SME_PROJECTION_SRC.SME_ENS_Kmean_Control.applyKmeans(SME_ENS_Kmean_Control.java:47)
    at SME_PROJECTION_SRC.SME_Plugin_Get_Manifold.runKmeans(SME_Plugin_Get_Manifold.java:180)
    at SME_PROJECTION_SRC.SME_Plugin_Simple_CONF.runKmeansStep(SME_Plugin_Simple_CONF.java:92)
    at SME_PROJECTION_SRC.SME_Plugin_Simple_CONF.getManifold(SME_Plugin_Simple_CONF.java:78)
    at SME_PROJECTION_SRC.SME_Plugin_Simple_CONF.runConfColour(SME_Plugin_Simple_CONF.java:329)
    at SME_PROJECTION_SRC.SME_Plugin_Simple.run(SME_Plugin_Simple.java:249)
    at ij.IJ.runUserPlugIn(IJ.java:221)
    at ij.IJ.runPlugIn(IJ.java:185)
    at ij.Executer.runCommand(Executer.java:137)
    at ij.Executer.run(Executer.java:66)
    at java.lang.Thread.run(Thread.java:745)

[ERROR] Exception
java.lang.NoSuchMethodException: Could not find method org.apache.commons.math3.random.JDKRandomGenerator.<init>(I)V
There was a problem with the class org.apache.commons.math3.random.JDKRandomGenerator which can be found here:
/Applications/Fiji.app/jars/commons-math3-3.4.1.jar
/Applications/Fiji.app/plugins/ij-plugins/commons-math3-3.6.1.jar
/Applications/Fiji.app/plugins/SME_stacking.jar
/Applications/Fiji.app/plugins/Thunder_STORM.jar

WARNING: multiple locations found!
java.lang.NoSuchMethodError: org.apache.commons.math3.random.JDKRandomGenerator.<init>(I)V
    at SME_PROJECTION_SRC.SME_ENS_Kmean_Control.Kmeans_(SME_ENS_Kmean_Control.java:351)
    at SME_PROJECTION_SRC.SME_ENS_Kmean_Control.applyKmeans(SME_ENS_Kmean_Control.java:47)
    at SME_PROJECTION_SRC.SME_Plugin_Get_Manifold.runKmeans(SME_Plugin_Get_Manifold.java:180)
    at SME_PROJECTION_SRC.SME_Plugin_Simple_CONF.runKmeansStep(SME_Plugin_Simple_CONF.java:92)
    at SME_PROJECTION_SRC.SME_Plugin_Simple_CONF.getManifold(SME_Plugin_Simple_CONF.java:78)
    at SME_PROJECTION_SRC.SME_Plugin_Simple_CONF.runConfColour(SME_Plugin_Simple_CONF.java:329)
    at SME_PROJECTION_SRC.SME_Plugin_Simple.run(SME_Plugin_Simple.java:249)
    at ij.IJ.runUserPlugIn(IJ.java:221)
    at ij.IJ.runPlugIn(IJ.java:185)
    at ij.Executer.runCommand(Executer.java:137)
    at ij.Executer.run(Executer.java:66)
    at java.lang.Thread.run(Thread.java:745)

    at SME_PROJECTION_SRC.SME_ENS_Kmean_Control.Kmeans_(SME_ENS_Kmean_Control.java:351) ~[SME_stacking.jar:na]
    at SME_PROJECTION_SRC.SME_ENS_Kmean_Control.applyKmeans(SME_ENS_Kmean_Control.java:47) ~[SME_stacking.jar:na]
    at SME_PROJECTION_SRC.SME_Plugin_Get_Manifold.runKmeans(SME_Plugin_Get_Manifold.java:180) ~[SME_stacking.jar:na]
    at SME_PROJECTION_SRC.SME_Plugin_Simple_CONF.runKmeansStep(SME_Plugin_Simple_CONF.java:92) ~[SME_stacking.jar:na]
    at SME_PROJECTION_SRC.SME_Plugin_Simple_CONF.getManifold(SME_Plugin_Simple_CONF.java:78) ~[SME_stacking.jar:na]
    at SME_PROJECTION_SRC.SME_Plugin_Simple_CONF.runConfColour(SME_Plugin_Simple_CONF.java:329) ~[SME_stacking.jar:na]
    at SME_PROJECTION_SRC.SME_Plugin_Simple.run(SME_Plugin_Simple.java:249) ~[SME_stacking.jar:na]
    at ij.IJ.runUserPlugIn(IJ.java:221) [na:1.51r]
    at ij.IJ.runPlugIn(IJ.java:185) [na:1.51r]
    at ij.Executer.runCommand(Executer.java:137) [na:1.51r]
    at ij.Executer.run(Executer.java:66) [na:1.51r]
    at java.lang.Thread.run(Thread.java:745) [na:1.8.0_66]
erexhepa commented 6 years ago

Hi,

happy to help you figure out what the problem is. Can you attach the image you used to get this error ? What version of Fiji you're using and what operating system you're running ?

Elton

imagejan commented 6 years ago

@tlambert03 wrote:

/Applications/Fiji.app/jars/commons-math3-3.4.1.jar
/Applications/Fiji.app/plugins/ij-plugins/commons-math3-3.6.1.jar
/Applications/Fiji.app/plugins/SME_stacking.jar
/Applications/Fiji.app/plugins/Thunder_STORM.jar

It seems you have multiple conflicting plugins installed that all ship different (and possibly incompatible) versions of commons-math3.

In an up-to-date Fiji installation (running on Java 8, not Java 6), you should have version 3.6.1:

/Applications/Fiji.app/jars/commons-math3-3.6.1.jar

I would expect that updating Fiji would already help in your case, as currently the old version 3.4.1 is picked up in your installation. If it doesn't help, try removing ij_plugins and Thunder_STORM (preferably by deactivating their update site, if you installed them this way).

As a longer term solution, the developers of both SME_stacking and Thunder_STORM should stop shipping uber-JARs with these libraries included, and instead use maven for dependency management and use pom-scijava as a parent to ensure they are compatible with a current Fiji installation.

tlambert03 commented 6 years ago

thank you both! (particularly for helping with something that is only tangentially related to SME). indeed simply downloading fiji and starting fresh solves the problem... though I'm still curious as to what's wrong with my other installation. To answer both of your questions (and perhaps to help anyone else if they have the same problem)

I'm on OS X 10.12.6, using images from the sample dataset (dendrites.tif for example). I'm running Fiji with ImageJ 1.51r. One particular difference I noticed between the working version and the broken install: when I select "About ImageJ" from the Fiji menu, the "working" version shows me a Fiji window that says v1.0, whereas the "broken" install gives me the traditional ImageJ info (version 2.0.0-rc-43/1.51r build 49b667f9aa)... if that tells you anything.

I generally do try to run Fiji update on a regular basis, and in this case running Fiji update and/or ImageJ update didn't solve anything. Yes, it does work to simply remove all of the conflicting commons-math3 version... but it's not sufficient to remove the plugin ones, I also need to remove the one in Fiji.app/jars (and also obviously not a desirable solution). I see now that I've got an older version of commons-math3 there, but I don't quite know enough about the Fiji internals and update mechanism to understand why just updating Fiji from within the app isn't fixing it. (but, if I had downloaded that at a time when it was shipping with Java 6, would I need to update that manually by reinstalling Fiji?)

Anyway, it's simple enough for me to just use the freshly-downloaded version of Fiji. If it's obvious to you what was wrong with my older version, I'd be curious to know. But thank you both for your time, and thanks a lot for the cool method and plugin.

erexhepa commented 6 years ago

thank you both! (particularly for helping with something that is only tangentially related to SME). indeed simply downloading fiji and starting fresh solves the problem... though I'm still curious as to what's wrong with my other installation. To answer both of your questions (and perhaps to help anyone else if they have the same problem). I'm on OS X 10.12.6, using images from the sample dataset (dendrites.tif for example). I'm running Fiji with ImageJ 1.51r. One particular difference I noticed between the working version and the broken install: when I select "About ImageJ" from the Fiji menu, the "working" version shows me a Fiji window that says v1.0, whereas the "broken" install gives me the traditional ImageJ info (version 2.0.0-rc-43/1.51r build 49b667f9aa)... if that tells you anything.

no worries. We are happy to help you run the plugin. Both the working and non-working version of Fiji you have seem to be the same release (1.51r but this refers to ImageJ not FIJI), maybe different builds but they should very very similar with regard to ImageJ so I don't know how the old apache library

/Applications/Fiji.app/jars/commons-math3-3.4.1.jar

ended up in the Fiji folder for the non-working version but my guess is that you installed Fiji a long time ago.

The FIJI update should update all libraries and plugin that are registered for update and this probematic library is not updated because it was not registered for updates. You maybe have a very old Fiji installation and should install (as imagejan suggested) an uptodate version of Fiji (which you have done and seems to solve the problem for running the plugin).

Anyway imagejan is right for longterm management/compatibility we should use maven for managing all compatibility issues.