-
Notifications
You must be signed in to change notification settings - Fork 143
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
JMetro: NoSuchMethodError with no code written #214
Comments
I can confirm that I am getting the same error and behavior trying to add JMetro to my simple project. Java17, OpenJFX 18, JMetro 11.6.15 on Windows 10 using Maven. |
I am getting the same error, but I am only getting it when I initialize/setup JMetro in my scene with the following code: ...
JMetro jMetro = new JMetro(Style.LIGHT);
jMetro.setScene(scene); // <-- Removing/Commenting out this line fixes the error
EDIT |
Hi, Sorry for the late reply but I've been very busy with my day to day work. Is there any call to a Jmetro method or anything related to JMetro in the stacktrace of the exception? (I don't see any reference to JMetro in the stacktrace the reporter of this issue mentioned) |
I ran into this same error previously. My stack trace did not include any mention of Jmetro. In fact, I was able to trigger the same error even after removing all Jmetro usage from my project; however, because I still had the Jmetro dependency listed in my project, it triggered the same error ("Exception in thread "JavaFX Application Thread" java.lang.NoSuchMethodError: 'void com.sun.javafx.scene.NodeHelper.recalculateRelativeSizeProperties(javafx.scene.Node, javafx.scene.text.Font"). It seems there is some conflict between the jmetro and the javafx library that causes the javafx code to fail when the jmetro module is also loaded. |
@vkphd Can you check if it also happens on different versions of Java and different versions of JavaFX? |
BTW, this is a very strange bug. Unless I'm missing something I don't see how a dependency that's never used could trigger an exception.. Thanks |
Anyways, please attach a small test app that illustrates the problem happening. This is the standard practice for any bug. Also, this is even more important given the small amount of resources and time available.. |
Here is my solution <dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-graphics</artifactId>
<version>11.0.2</version>
<classifier>win</classifier>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>11.0.2</version>
<classifier>win</classifier>
<scope>runtime</scope>
</dependency> So, to make it work you need to explicitly include those libraries in your project with the proper versions. Otherwise javafx-controls of newer version tries to use javafx-graphics of older version |
I'll need a small test app (as small as possible) so I can run and see the problem happening. Then I can also debug it. |
https://github.com/bykka/JMetro_214 |
Thanks a lot for attaching a test app @bykka |
@dukke I don't know if the issue I had a long time ago is related but this is what I did in my build.gradle. https://github.com/Satergo/Satergo/blob/52a3357ee7f25a332102a84cf65cbc523f956f6a/build.gradle#L56-L59. (Also, the exclusion of controlsfx is not needed anymore -- I wasn't using controlsfx so I didn't want it cluttering my final package -- because a new release with my PR that marks controlsfx as compileOnly was made) There is also a StackOverflow question about this, I think that's where I found the solution. It could be because JMetro is using the OpenJFX Gradle Plugin, which seems to be for applications more than libraries. Maybe you can compare with other JavaFX libraries. Edit: The issue I was having is likely unrelated, but I do believe the one I had also still exists. |
Thanks for your input guys! However it would be nice if we could prevent this exception from happening... Ok, so after some investigation this seems a bit weird. Both javafx.graphics version 11 and javafx.graphics version 18 have the method
Since we're using, for example, the Scene class there must be some javafx.graphics module being pulled in (Scene belongs to javafx.graphics) but even if the wrong version of javafx.graphics is pulled in (e.g. version 11 of javafx.graphics) it should still work or at least it shouldn't give the exception that it gives since the method in question exists in version 11. |
...BTW, I'm trying to avoid changing the jmetro configuration and having it compile using javafx 17 for 2 reasons:
|
Hello, after trying the workaround suggested by @bykka, a new issue appeared after initializing
To reslove you need an additionnal dependency
Environment:
|
This issue is still happening. Is there any fix for this being actively worked on? |
JMetro v11.6.15 (using Maven) throws
NoSuchMethodError
with no JMetro imports or code written at all (i.e. mere dependency inclusion seems to be the cause). Shortened stack trace (if it's worth anything):The stack trace suggests this happens when rendering the window, but a bit of debugging leads me to believe this happens at
static
initialization time. At first I thought it had something to do with my local configuration, but no resetting or clearing seems to solve the issue.Java version: 17
JavaFX version: 17.0.2
The text was updated successfully, but these errors were encountered: