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

Application run cannot find javafx.web module on Java 17 #117

Open
DJViking opened this issue Dec 10, 2021 · 13 comments
Open

Application run cannot find javafx.web module on Java 17 #117

DJViking opened this issue Dec 10, 2021 · 13 comments
Labels
bug Something isn't working

Comments

@DJViking
Copy link

DJViking commented Dec 10, 2021

The Gradle Application Plugin run task doesn't work when running with Java 17.
Works fine on Java 11, but when updated to run Java 17 and JavaFX 17, I get
java.lang.module.FindException: Module javafx.web not found

Workaround:
Remove the javafxplugin
Add JavaFX dependencies

I wonder if there is still any use for this plugin. It saves a few more lines, but seems to do just the same as my workaround.

@abhinayagarwal
Copy link
Collaborator

Do you have an example build.gradle without using the plugin?

@abhinayagarwal abhinayagarwal added the bug Something isn't working label Jan 14, 2022
@nlisker
Copy link

nlisker commented Feb 22, 2022

I am encountering this (or a similar) problem.

For comparison, I'm using both Eclipse and Gradle to run and build.

test.zip

version 0.0.11

Building

Eclipse: builds fine

Gradle build tasks fails:

Working Directory: C:\Users\Nir\workspaceSmallStuff\test
Gradle user home: C:\Users\Nir\.gradle
Gradle Distribution: Gradle wrapper from target build
Gradle Version: 7.4
Java Home: C:\Program Files\Java\jdk-15
JVM Arguments: None
Program Arguments: None
Build Scans Enabled: false
Offline Mode Enabled: false
Gradle Tasks: :build


> Configure project :
Project : => 'testproj' Java module

> Task :generateEffectiveLombokConfig
> Task :compileJava UP-TO-DATE
> Task :processResources NO-SOURCE
> Task :classes UP-TO-DATE
> Task :jar UP-TO-DATE
> Task :startScripts UP-TO-DATE
> Task :distTar UP-TO-DATE
> Task :distZip UP-TO-DATE
> Task :assemble UP-TO-DATE
> Task :mergeClasses SKIPPED
> Task :generateTestEffectiveLombokConfig
> Task :compileTestJava UP-TO-DATE
> Task :processTestResources NO-SOURCE
> Task :testClasses UP-TO-DATE
Could not write standard input to Gradle Test Executor 25.
java.io.IOException: The pipe is being closed
	at java.base/java.io.FileOutputStream.writeBytes(Native Method)
	at java.base/java.io.FileOutputStream.write(FileOutputStream.java:347)
	at java.base/java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:81)
	at java.base/java.io.BufferedOutputStream.flush(BufferedOutputStream.java:142)
	at org.gradle.process.internal.streams.ExecOutputHandleRunner.forwardContent(ExecOutputHandleRunner.java:68)
	at org.gradle.process.internal.streams.ExecOutputHandleRunner.run(ExecOutputHandleRunner.java:53)
	at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
	at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
	at java.base/java.lang.Thread.run(Thread.java:832)

> Task :test FAILED
Error occurred during initialization of boot layer
java.lang.module.FindException: Module javafx.web not found, required by com.gluonhq.charm.glisten.connect.view

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':test'.
> Process 'Gradle Test Executor 25' finished with non-zero exit value 1

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 1s
9 actionable tasks: 3 executed, 6 up-to-date

So, the same java.lang.module.FindException: Module javafx.web not found that was reported.

Running

Eclipse: run fails:

Error occurred during initialization of boot layer
java.lang.module.FindException: Module com.gluonhq.charm.glisten not found, required by testproj

Gradle run task runs fine

Testing

Eclipse: Running the test as JUnit fails with the same run message

Gradle test fails with the same build error

version 0.0.12

Change in the build file to this version and do "refresh gradle project".

Building

Eclipse: errors: no module in the module-info file can be resolved.

Gradle build tasks fails as with 0.0.11

Running

Eclipse: fails with

Error occurred during initialization of boot layer
java.lang.module.FindException: Module testproj not found

Gradle run task runs fine

Testing

Eclipse: Running the test as JUnit fails with

WARNING: Unknown module: testproj specified to --patch-module
WARNING: Unknown module: testproj specified to --add-reads
WARNING: Unknown module: testproj specified to --add-opens
Class not found mytest.MyTest
java.lang.ClassNotFoundException: mytest.MyTest
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClass(RemoteTestRunner.java:766)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClasses(RemoteTestRunner.java:490)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:513)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:756)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:452)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:210)

Gradle test fails with the same build error


So it seems like version 0.0.12 broke something, but in version 11 there were also issues. Could be something else in the build, but don't know what.

@nlisker
Copy link

nlisker commented Mar 21, 2022

@abhinayagarwal Can you have a look at the reproduction cases? I tested both 0.0.11 and 0.0.12 with a sample project.

@HEdingfield
Copy link

HEdingfield commented Aug 7, 2022

Similar problem for me running JDK 17 and trying to upgrade from 0.0.11 to 0.0.12 or 0.0.13 and then using gradle run inside IntelliJ:

WARNING: Unknown module: my.project specified to --patch-module
Error: Could not find or load main class my.project.Main
Caused by: java.lang.ClassNotFoundException: my.project.Main
Execution failed for task ':run'.
> Process 'command 'C:\Java\jdk-17.0.2\bin\java.exe'' finished with non-zero exit value 1

@abhinayagarwal
Copy link
Collaborator

@nlisker Can you confirm if you are still facing this issue in 0.0.13 and JFX 19 ?

@bademux
Copy link

bademux commented Oct 14, 2022

@abhinayagarwal I have the same issue "Could not find or load main" in 0.0.13 and JFX 19 (JDK17)

@Artenes
Copy link

Artenes commented Oct 17, 2022

Same thing here, I am using:

  • Java 18
  • Gradle 7.5.1
  • application gradle plugin
  • JFX gradle plugin 0.0.13
  • JFX 19

But the problem goes away when downgrading to JFX gradle plugin 0.0.11.

Note that this problem only happens when we add a module-info.java under src/main/java. If the file is removed from there it works with latest version.

@nlisker
Copy link

nlisker commented Oct 17, 2022

@abhinayagarwal Let's look at this sample so we have a common ground: https://github.com/openjfx/samples/tree/master/IDE/Eclipse/Modular/Gradle/hellofx (or for other IDEs, I personally use this one because I use Eclipse).

I only updated the JavaFX version to 19, grade wrapper to 7.5.1 and 'org.beryx.jlink' to version '2.25.0'. Gradle runs on Java 18 (better to add toolchain support in these examples so Gradle and the application can use different Java versions). The results are:
'org.openjfx.javafxplugin' version '0.0.11': builds and runs using gradle.
'org.openjfx.javafxplugin' version '0.0.12': builds but fails on run with

Error: Could not find or load main class hellofx.org.openjfx.MainApp
Caused by: java.lang.ClassNotFoundException: hellofx.org.openjfx.MainApp

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':run'.
> Process 'command 'C:\Program Files\Java\jdk-18\bin\java.exe'' finished with non-zero exit value 1

'org.openjfx.javafxplugin' version '0.0.13': same as '0.0.12'

With this sample you can test directly what works and what doesn't.

@pellico
Copy link

pellico commented Dec 8, 2022

I hit the same issue :-(

@miasma
Copy link

miasma commented Feb 23, 2023

Same issue here. I tried different combinations of versions with the @nlisker's hellofx example:

  • Java 11-19: no new issues with recent versions
  • JavaFX 11-19.0.2: all work
  • Gradle: 7.5 & 7.6 works (requires application { mainModule = "hellofx" } for jlink to work, though), Gradle 8.x won't work for other reasons (incompatible modularity plugin?), couldn't find a compatible version of org.beryx.jlink for 7.4 and older
  • org.beryx.jlink: all recent versions work at least up to 2.26.0
  • org.openjfx.javafxplugin:
    • versions 0.0.10 - 0.0.11 work
    • older versions fail with org.joor.ReflectException: java.lang.NoSuchFieldException: javaExecHandleBuilder
    • 0.0.12 & 0.0.13 builds fine, but the run task fails with
      Error: Could not find or load main class hellofx/org.openjfx.MainApp in module hellofx

@miasma
Copy link

miasma commented Feb 23, 2023

I did some further testing. This commit seems to break the plugin: 02d36b8

Moduleplugin versions 1.8.2 - 1.8.9 all work, but 1.8.10 triggers the bug, also 1.8.11 and 1.8.12 fail.

@miasma
Copy link

miasma commented Feb 23, 2023

@nlisker. Ok added this to build.gradle:

application {
    mainModule = moduleName
    mainClass = "org.openjfx.MainApp"
    applicationDefaultJvmArgs = ['--module', 'hellofx']
}
//mainClassName = "$moduleName/org.openjfx.MainApp"

Now it works with Java 19, Gradle 8.0.1 and JavaFX 19.0.2. Apparently this change (java9-modularity/gradle-modules-plugin@fda9c7e#diff-ae589711150c3780c06898bd2c6583a49c3bfe8f6918f6f4549ade459fd500aa) in moduleplugin 1.8.10 affects Gradle versions 6.4+. A wrong module name gets passed to --module? Manually overriding it seems to fix it for me.

edit: now that I tried it again, I noticed that I had forgotten to comment out the mainClassName while testing at first. So the applicationDefaultJvmArgs override might not be necessary - users of Gradle 6.4+ should just use the mainModule/mainClass combo instead of mainClassName. Gradle 6.4+ changed the way main class/module names are passed. I think the moduleplugin has some code to warn about the use of the old modulename/classname scheme, but I didn't see this when using the JavaFX plugin. I think this should trigger some sort of warning because the old build configs at first seems to work, but then fails when executing the 'run' phase.

@nlisker
Copy link

nlisker commented Feb 23, 2023

Thanks, I'll try it out.

Maybe @abhinayagarwal can use this info to create a fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

8 participants