Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Eviatar opened this issue Jul 31, 2017 · 10 comments
Open

Comments

@Eviatar
Copy link

Eviatar commented Jul 31, 2017

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_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)

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_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)

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
Copy link

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:

  • properly depend on that third-party library using Maven (see Use maven for dependency management #2) as a dependency manager (and inheriting from pom-scijava as parent POM), and the ImageJ updater will take care that this dependency is uploaded to your update site (Make an update site for ImageJ #1) only if required; or
  • shadowing the required classes from commons-math by putting them in a package with different name, so you can use customized code without interfering with other plugins depending on commons-math.

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
Copy link
Collaborator

erexhepa commented Aug 16, 2017

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
Copy link
Collaborator

@Eviatar

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

@imagejan
Copy link

@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
Copy link
Collaborator

yes sorry misunderstood what you meant above.

@tlambert03
Copy link

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
Copy link
Collaborator

erexhepa commented Nov 4, 2017

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
Copy link

imagejan commented Nov 4, 2017

@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
Copy link

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
Copy link
Collaborator

erexhepa commented Nov 5, 2017

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants