JPro-one / JPro

The right place to report about bugs or suggest improvements for JPro.
https://www.jpro.one
9 stars 4 forks source link

Q: Best practice to embed JPro into existing project? #167

Closed jvdnbus closed 10 months ago

jvdnbus commented 11 months ago

So after a bit of tinkering, I've somewhat managed to get JPro running an FXGL application, both in IntelliJ (need to figure out debugging) and as a release package.

However, I'd like to either

It's important the JavaFX application is able to communicate with my own server without too much hassle apart from thread safety.

I was unable to achieve option A. I'd have to look at how com.jpro.boot.JProBoot works for that. Option B worked somewhat, except it seems that when running my main class "Z" at "onJVMStartup", the classpath is not loaded in properly(?) as I am unable to load classes from JARs (e.g. JDBC driver) that are well indeed included in the libs directory and the $CLASSPATH variable inside start.ps1. Are perhaps only the jprolibs + the JAR containing my main class "Z" loaded? Maybe I should assemble one fat JAR, but, how would I do this with the building of JPro in Maven?

Could you perhaps shed some light on how this hook works or point me into a better approach. Any help would be greatly appreciated!

A bit more info: JPro Version: 2023.3.3 Java Version: 21.0.1 (Eclipse Temurin) Browser+Version: N/A Your Operating System: Win 11 Build & launch method: Maven jpro:run and jpro:release

FlorianKirmaier commented 11 months ago

I think these are multiple topics in one.

Loading JDBC This sounds like a bug, but I'm unsure whether you are doing something wrong. Can you create a minimal project that shows that the JDBC is not loaded properly? Normally, your whole classpath should be loaded without any issues.

Combining with game server It might be possible to somehow combine these 2 servers, but why the hassle? Do you have native Desktop users? There is nothing wrong with having 1 process for the game-server and 1 server for the jpro-client. This also has the advantage that they are properly separated and the JPro and Native version behaves more similar (If you have native clients)

In general, it's hard to make a recommendation without knowing more about your project. It's worth mentioning, that with the JPro Loadbalancer (https://www.jpro.one/docs/current/2.15/JPro_Loadbalancer) It's possible to create a separate JVM per User.

FlorianKirmaier commented 10 months ago

Closing for now.

jvdnbus commented 10 months ago

This turned out to be several issues. I first had to make my own project modular and fix the module path, as well as make changes to existing code (and update dependencies) to work with Java 21 (17 previously).

The reason why the JPro application must be able to interact with my game server internally, is because the web app will act as a monitoring tool. Entirely separate native game clients connect to the game server.

Either way, after a lot of tinkering I got it working. Thanks for your insight, it made me rethink about what could be going wrong!