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

AsyncKt cannot access class com.sun.glass.ui.Application #1348

Closed
mirkarlar opened this issue Nov 28, 2021 · 5 comments
Closed

AsyncKt cannot access class com.sun.glass.ui.Application #1348

mirkarlar opened this issue Nov 28, 2021 · 5 comments

Comments

@mirkarlar
Copy link

mirkarlar commented Nov 28, 2021

When trying to execute an async restcall I get the following exeption.

class tornadofx.AsyncKt (in module tornadofx) cannot access class com.sun.glass.ui.Application (in module javafx.graphics) because module javafx.graphics does not export com.sun.glass.ui to module tornadofx
at tornadofx@1.7.20/tornadofx.AsyncKt.success(Async.kt:115)
at tornadofx@1.7.20/tornadofx.Component.ui(Component.kt:240)

pom and module-info.java added (with extention .txt to allow them to be attached)
pom.xml.txt
module-info.java.txt

tried different jdk's: openjdk 11.0.7 , corretto (amazon) 15.0.2
different versions for javafx: 17-ea+11/ 18-ea+7

any help appreciated

additional info:
Controller with restcall (calling the function directly returns desired results):

class ForecastController : Controller() {

    val selectedCity: CityModel by inject()

    var allWeather = FXCollections.emptyObservableList<ForecastList>()

    val api: Rest by inject()

    init {
        api.baseURI = "https://api.weatherbit.io/v2.0/forecast/daily/"

    }

    fun listForcast(cityName: String = selectedCity.name.value, countryName: String = selectedCity.country.value) : List<ForecastList>
            =  api.get("?City=$cityName&country=$countryName&key=$appId").list().toModel<ForecastList>()

}

Async call:

setOnKeyPressed {
                            if (it.code == KeyCode.ENTER) {
                                tornadofx.runAsync {
                                    controller.allWeather = controller.listForcast(
                                        cityName = controller.selectedCity.name.value,
                                        countryName = controller.selectedCity.country.value
                                    ) as ObservableList<ForecastList>?
                                } ui {
                                    forecastList = controller.allWeather[0]
                                    vbox {
                                        cityLabel.text = forecastList.city.name

                                    }

                                }
                            } else {
                                null
                            }
                        }
@mirkarlar
Copy link
Author

made a bit of headway:

Instead of adding the VM option: --add-exports javafx.graphics/com.sun.glass.ui=ALL-UNNAMED
using --add-exports javafx.graphics/com.sun.glass.ui=tornadofx
seems to be working

IntelliJ RunConfiguration screenshot:
Screenshot_20211202_230158
g

@SKeeneCode
Copy link

Yes welcome to the Java module system rolls eyes.

You should probably apply these VM options via your build tool. My build gradle has this for example:

image

Most of them are there to make JFoenix work but I plan to replace it entirely with the newer MaterialFX.

@SchweinchenFuntik
Copy link
Contributor

you are using version 1.7.20, you need 2.0.0-SNAPSHOT.

1.7.20 - java8
2.0.0 - java11+

@mirkarlar
Copy link
Author

you are using version 1.7.20, you need 2.0.0-SNAPSHOT.

1.7.20 - java8 2.0.0 - java11+
Thnx for your reply.

Upgrading to 2.0.0 (SNAPSHOT) didn´t fix this problem.
Still upgrading fixed some other issues, and I'm quite happy with it.

The jvm options to loosen the module restrictions fixed the export errors.

Weird thing is
-add-exports javafx.graphics/com.sun.glass.ui=ALL-UNNAMED,
which should be more general, didnt work. Instead I had to use
--add-exports javafx.graphics/com.sun.glass.ui=tornadofx

For now I can work with that, but still makes me scratch my head....

@mirkarlar
Copy link
Author

made a bit of headway:

Instead of adding the VM option: --add-exports javafx.graphics/com.sun.glass.ui=ALL-UNNAMED
using --add-exports javafx.graphics/com.sun.glass.ui=tornadofx
seems to be working

IntelliJ RunConfiguration screenshot:
Screenshot_20211202_230158
g

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

3 participants