javafxports / javafxmobile-plugin

A gradle plugin for building mobile applications in java.
BSD 3-Clause "New" or "Revised" License
42 stars 19 forks source link

Gluon Mobile Plugin does not work properly with jPro #86

Open KniKnaKnorke opened 5 years ago

KniKnaKnorke commented 5 years ago

When i run my Gluon mobile application with jPro plugin, it is not possible to access the app via multiple clients. The first client can run the app in the browser. However, the second try results in this exception

java.lang.Error: factory already defined at java.net.URL.setURLStreamHandlerFactory(URL.java:1112) at com.gluonhq.impl.charm.a.e.d.a(SourceFile:46) at com.gluonhq.charm.glisten.application.MobileApplication.start(SourceFile:212) at com.jpro.internal.config.ApplicationStarter$.startJApplication(ApplicationStarter.scala:133) at com.jpro.internal.config.ApplicationStarter$.$anonfun$startApplication$2(ApplicationStarter.scala:114) at simplefx.cores.interfaces.parts.testing.CoreTesting.inFX(CoreTesting.scala:19) at simplefx.cores.interfaces.parts.testing.CoreTesting.inFX$(CoreTesting.scala:16) at simplefx.cores.standard.Core.inFX(Core.scala:9) at com.jpro.internal.config.ApplicationStarter$.startApplication(ApplicationStarter.scala:112)

When I set the factory to null(java reflection), it is possible to get more then one client working. But it seems that the instances of the mobile application are shared of the the clients. When I click on a button the action will be performed on another browser. I read in the FAQ that the jPro Plugin should work with the mobile plugin. I dont know where to report this issues. So I did it at both github repositories(jPro/Gluon Mobile)

FlorianKirmaier commented 5 years ago

To provide some clarifications: JPro supports the Gradle Mobile Plugin, but it doesn't work with the library charm / class MobileApplication. I will update our documentation, to clarify this. So technically, this is the wrong repository, for this issue. Is there a public ticket-system for the charm-library?

The reason for it is, that MobileApplication is a singleton and can't be instantiated multiple times. When you workaround it with reflection, it will only cause some internal problems. That's the reason, why your button from instance 1 effect instance 2.

When I was looking into this topic, it seemed to me, that Charm library already is designed to not be a singleton, but for some reason, it still was a singleton.

Gluon @johanvos @jperedadnr , Do you think it's possible, to remove this restriction from the charm-library, so an application can be instantiated multiple times? Then the Charm would work fine with JPro, and I could also add some of your programs as a working online demo. And I could also recommend Charm when someone is using JPro.

I will also try to check whether it works, when a new classloader is created for each instance, but I'm suspicious whether this will work, and it also would scale a bit worse.

FlorianKirmaier commented 5 years ago

Gluon, @johanvos @jperedadnr, can you please say something about this topic? We get more people asking for this, and we don't know what to tell them, without a response on your side.

johanvos commented 5 years ago

We'll discuss this by mail.