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

Plugin-configuration when using JPMS / JDK9+ #346

Closed
WarWolfen opened this issue Jun 20, 2018 · 36 comments
Closed

Plugin-configuration when using JPMS / JDK9+ #346

WarWolfen opened this issue Jun 20, 2018 · 36 comments

Comments

@WarWolfen
Copy link

WarWolfen commented Jun 20, 2018

Hi!

I am new to Java 9 / 10 (Jigsaw) and I am porting my project. After fiddling for some time, I now can compile the thing. I am using this:

<plugin>  
    <groupId>com.zenjava</groupId>  
    <artifactId>javafx-maven-plugin</artifactId>  
    <version>8.9.0-SNAPSHOT</version>  
    <configuration>  
        <mainClass>net.clanwolf.c3.client.MainFrame</mainClass>  
        <preLoader>c3_preloader.C3_Preloader</preLoader>  
        <identifier>${project.artifactId}</identifier>  
        <vendor>ClanWolf.net</vendor>  
        <!-- win.app | linux.app | mac.app | exe | msi | rpm | deb -->  
        <bundler>msi</bundler>  
        <nativeReleaseVersion>${project.version}</nativeReleaseVersion>  
        <needShortcut>true</needShortcut>  
        <needMenu>true</needMenu>  
        <appName>${project.artifactId}</appName>  
             <manifestAttributes>  
                    <Specification-Title>${project.name}</Specification-Title>  
                    <Specification-Version>${project.version}</Specification-Version>  
                    <Specification-Vendor>${project.organization.name}</Specification-Vendor>  
                    <Implementation-Title>${project.name}</Implementation-Title>  
                    <Implementation-Version>${project.version}</Implementation-Version>  
                    <Implementation-Vendor-Id>${project.groupId}</Implementation-Vendor-Id>  
                    <Implementation-Vendor>${project.organization.name}</Implementation-Vendor>  
        </manifestAttributes>  
    </configuration>  
    <executions>  
           <execution>  
                <!-- required before build-native -->  
                <id>create-jfxjar</id>  
                <phase>package</phase>  
                <goals>  
                    <goal>build-jar</goal>  
                </goals>  
            </execution>  
            <execution>  
                <id>create-native</id>  
                    <phase>package</phase>  
                    <goals>  
                        <goal>build-native</goal>  
                    </goals>  
            </execution>  
    </executions>  
</plugin>`

It works fine until it tries to run WiX. The error there is:
Module does not exist.
"Adding modules: [] to runtime image."
Exception: jdk.tools.jlink.plugin.PluginException: java.lang.module.FindException: Module not found

That leaves me kind of helpless. Where would I tell my thing what the module name is? I have a module.info.java and the structure is correct (at least, it compiles ok).

Thank you for your help!

Addition:
There are no automatic modules in the project, just my (one) application --> one module.
Here is all of it:
https://github.com/ClanWolf/C3-Client_Phoenix

Structure is this:
image
module-info.class might not be found at build time... (?)

(May be similar to this: https://stackoverflow.com/questions/49162252/jlink-not-finding-module-info-class)

@WarWolfen WarWolfen changed the title Module " "... Module " "not found Jun 20, 2018
@WarWolfen WarWolfen changed the title Module " "not found Module " " not found Jun 20, 2018
@WarWolfen
Copy link
Author

Found this:
#287

Is there a list of all bundlearguments?

@WarWolfen
Copy link
Author

WarWolfen commented Jun 20, 2018

I now did this:

<bundleArguments>
    <icon>http://c3.clanwolf.net/icon.ico</icon>
    <module-path>src/main/java/</module-path>
    <module>net.clanwolf.c3.client</module>
    <!--<add-modules>module1,module2,module3</add-modules>-->
    <!--<limit-modules>module1,module2,module3</limit-modules>-->
</bundleArguments>

Assuming the module is found, this is the result:

[INFO] Add C:\Users\chbartel\IdeaProjects\C3-Client_Phoenix\target\jfx\app\run.cmd file to application resources.
Exception: java.lang.NullPointerException
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS

@WarWolfen
Copy link
Author

Hi!

Got it working now. Pointing the module to the target path did the trick. I kind of assumed I had to point to the sources... which is... after all... kind of obviously not the case.
Anyway, this can be closed.

@FibreFoX
Copy link
Member

:) this kind of issues are cool ... sorry for the delayed feedback, but glad your could help yourself.

@WarWolfen
Copy link
Author

Too fast to celebrate. It build all fine without errors and I can install everything. Unfortunatly, running the installed app does not do anything. I can start the jar manually, but the exe and the shortcut do not work... :(

@WarWolfen
Copy link
Author

With this:

<bundleArguments>
    <runtime/>
    <icon>target/classes/icon.ico</icon>
    <installdirChooser>true</installdirChooser>
    <module-path>target/classes</module-path>
    <module>net.clanwolf.c3.client</module>
</bundleArguments>

It still bundles the runtime into the installer. And always when I start the installed app, nothing happens. Can I make the app give me a log somehow? I have no idea what is wrong.

@FibreFoX FibreFoX reopened this Jun 20, 2018
@WarWolfen
Copy link
Author

Ok, I can accept the runtime being bundled. That has a good aspect to it and I do not really mind the filesize. But the resulting exe not doing anything is of course... bad.
What puzzles me is that there is no log or anything anywhere telling me what actually goes wrong. It can't be that much, as the jar works perfectly when I start it manually (the "-jfx" one). Can anyone point me to a log of what might cause the error? I was kind of excited once the install process worked, but it is so frustrating to click on the exe and see... nothing.
:(

@maxd
Copy link
Contributor

maxd commented Jun 21, 2018

I have a deal with such problem too. So, I recommend to do several steps to investigate problem:

  1. Check Event Log (seems like your OS is Windows).

  2. Try to find crash logs in working directory of your application or in the temp directory of OS.

    In the event that the file cannot be created in the working directory (insufficient space, permission problem, or other issue), the file is created in the temporary directory for the operating system. ... On Windows the temporary directory is specified by the value of the TMP environment variable; if that environment variable is not defined, the value of the TEMP environment variable is used.

  3. Run *.exe from console because sometime it can print error message to STDOUT/STDERR. Check exit code. In some cases it can point you to problem.

  4. Check that you are using main function for launch JavaFX application. Several years ago the launcher have a problem with starting application through Application.start method, So, I am using such main method:

    public static void main(String[] args) throws Exception {
        Application.launch(MyApplication.class, args);
    }
    
  5. In some cases application can catch exception right after launch (i.e. in Application.start method) and exit suddenly without printing any errors to STDOUT and alert dialogs. Usually it is happen then some error is present in your or third-party code.

    To investigate such problems I am using IntelliJ IDEA remote debugger.

    • open your project in IntelliJ IDEA

    • create "Remote" configuration, specify correct host where you run application and copy recommended settings for Java agent to clipboard. In my case it is:

      -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005
      

      paste it to text editor and change suspend=n to suspend=y. It will wait attach of debugger before start execution of application.

    • open /app/.cfg and add agent settings to new line of [JVMOptions] section. Save changes.

    • Run *.exe. Run remote debugger in IntelliJ IDEA and try to find problem in code use remote debugger.

    If you don't want to use remote debugger you can use own log files or even println methods to collect more information about such problems but it can take more time.

I hope this steps should help you to investigate problem.

@WarWolfen
Copy link
Author

WarWolfen commented Jun 21, 2018

I will try.

I found that in the cfg, the classpath is empty:

[Application]
app.name=C3-Client_Phoenix
app.version=4.3.7
app.preferences.id=C3-Client_Phoenix
app.runtime=$APPDIR\runtime
app.identifier=C3-Client_Phoenix
app.classpath=
app.application.instance=multiple
app.mainmodule=net.clanwolf.c3.client
packager.java.version=10.0.1

[JVMOptions]
-Xmx2g
-Djavafx.verbose=true

[JVMUserOptions]

[ArgOptions]

Maybe that is ok, because it is a module, but I am not sure at all.

I have checked for crash dumps, log files, console output... anything I could think of. But the thing just does nothing at all. Oh, and I had the main method already in my code. I have enabled javafx.verbose (found that in some Thread), but there is no difference whatsoever.

%ERRORLEVEL% after execution of the exe is: 0

UPDATE:
Remote debugging did not work. IntelliJ comes up with "connection refused". I have changed the cfg as suggested and in case of an error it should suspend.

Remote debugging did not work. Connection refused. I have the feeling, the exe is already closed when I start the debugger...

@WarWolfen
Copy link
Author

WarWolfen commented Jun 21, 2018

I have println outputs in my code on the first line of the main method. Nothing comes up in the console. It does not even get there!

This drives me nuts! There is NOTHING anywhere telling me what is missing. I am considering to abandon it all together, provide a runme.cmd and get on with my live.
:(

I do not even see a process in process-explorer when I start the exe...
N O T H I N G

@WarWolfen
Copy link
Author

WarWolfen commented Jun 21, 2018

Running with verbose=true, I can see it bundles allright... but there are two lines stating that the module does not exist... despite the fact, it does find it and works with it:

Running [C:\C3\tools\wix311-binaries\light.exe, /?]
Detected [C:\C3\tools\wix311-binaries\light.exe] version [3,1]
Module net.clanwolf.c3.client does not exist.
"Adding modules: [net.clanwolf.c3.client] to runtime image."
outputDir = C:\Users\chbartel\AppData\Local\Temp\fxbundler8733120003115715196\images\win-msi.image\C3-Client_Phoenix\runtime
modulePath = [target\classes, C:\Program Files\Java\jdk-10.0.1\jmods]
addModules = [net.clanwolf.c3.client]
limitModules = []
excludeFileList = .*.diz
stripNativeCommands = true
userArguments = {}
Using custom package resource [icon] (loaded from file C:\Users\chbartel\IdeaProjects\C3-Client_Phoenix\target\classes\icon.ico)
Module net.clanwolf.c3.client does not exist.

This is so extremly frustrating...

@WarWolfen
Copy link
Author

WarWolfen commented Jun 21, 2018

https://stackoverflow.com/questions/41556619/javafx-jfxnative-output-exe-does-not-run-java-main-class

Running the exe with > out.txt produces an empty file (0 kB). No output there as well.

@FibreFoX
Copy link
Member

Running the exe with > out.txt produces an empty file (0 kB). No output there as well.

;) sometimes it's funny how my very own SO-answers are still valid and quoted.

@WarWolfen the linked repo, is that something I can use for reproducing? https://github.com/ClanWolf/C3-Client_Phoenix

@WarWolfen
Copy link
Author

WarWolfen commented Jun 21, 2018

Sure, that is the project. All my fiddling and mindblowing failings of today are not in there as I cannot push from where I am now, but the status has not changed. It did not work this morning, it does not work now, after hundreds of iterations and trial-and-error attempts to achieve anything... just something.

I am completly frustrated with this and probably abandon the whole project. It is just not worth the time...

Off topic:
Now I suddenly can not even start the minimal example app, because Java 10 complains about Maven exporting something into something (and now what??? it is Maven 3.5.3, jigsaw ready... maybe). It worked all day, but I tried to make the example use log4j in order to troubleshoot the installer issue, failed and removed it again. Now it is completly identical (source-wise) to before the change, but still it will not run.
Computers have been invented to solve problems no-one would know about without computers.

@WarWolfen
Copy link
Author

The version that is checked in now does not start anymore. It does build, however... and the installed version does not do anything (as mentioned above). But on top of all that this version does not start at all... because of:

Error occurred during initialization of boot layer
java.lang.module.ResolutionException: Modules maven.model and maven.model.builder export package org.apache.maven.model.merge to module plexus.compiler.manager

What the hell does that say? I did not change anything about maven. NOTHING!

@WarWolfen
Copy link
Author

@WarWolfen
Copy link
Author

Was the problem reproducable?

@WarWolfen
Copy link
Author

I replaced log4j (which refused to work with jigsaw) with java logging, added some logging to the sources... no output whatsoever.

@FibreFoX
Copy link
Member

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 12.932 s
[INFO] Finished at: 2018-06-23T09:58:00+02:00
[INFO] Final Memory: 12M/54M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project C3-Client_Phoenix: Could not resolve dependencies for project net.clanwolf.c3:C3-Client_Phoenix:jar:4.6.2: Could not find artifact net.clanwolf:C3-Preloader:jar:1.0.0 in mvnrepository (http://www.mvnrepository.com) -> [Help 1]

Anything not alreay being released?

@WarWolfen
Copy link
Author

WarWolfen commented Jun 23, 2018

Hi!
Sorry for the late reply.
This is my private JavaFX perloader. It does exist in my private maven repository. I have checked it in into the libs folder of the project (it is handled by maven, so it needs to be installed locally). There is a txt file with the proper install command included.
Alternatively, you could also remove the preloader line from the pom.xml.

EDIT:
At least now it is... somehow it was ignored on initial commit.

@WarWolfen
Copy link
Author

Automatic modules not possible for jlink? I need to use commons-collections in my app. Does that mean I cannot package it with javafx-maven-plugin (as in: https://stackoverflow.com/questions/46882108/how-to-find-automatic-modules-with-javapackager)
?

@WarWolfen
Copy link
Author

Ok,after all searching and fiddling, I have decided to switch to NSIS. I have created a batch starter to check for installed Java versions (checked in). Thanks for the help, but this can be closed, I guess.

@FibreFoX
Copy link
Member

hm ... I didn't even got the chance to have this analyzed, due to missing mvce ... just add some comment to this issue-thread to have this re-opened. It sounds more like an issue of the .cfg-file but I cant reproduce with the provided project, because it's not compiling.

@WarWolfen
Copy link
Author

Oh, it does compile for me. What do you miss? I can sure switch back, but I understood that jlink will not work with automatic modules.

@FibreFoX
Copy link
Member

The original issue was, that something with the JPMS did not work, but it seemed your found your way, but it was followed by a problem running the native EXE launcher, at least that's I understood. Having a problem with the native launcher/EXE-file in combination with JPMS sounds like a tricky bug, but as I'm not being able to re-create this issue, the project you linked could not be compiled on my machine, eans this bug might still be existent.

@WarWolfen
Copy link
Author

The issue is still there in the project as it is checked in now. It is in a compiling state now and as I understand it should compile for you as well. What does not compile on your end?

@FibreFoX
Copy link
Member

[INFO] Scanning for projects...
[WARNING] The project net.clanwolf.c3:C3-Client_Phoenix:jar:4.7.3 uses prerequisites which is only intended for maven-plugin projects but not for non maven-plugin projects. For such purposes you should use the maven-enforcer-plugin. See https://maven.apache.org/enforcer/enforcer-rules/requireMavenVersion.html
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building C3-Client Phoenix 4.7.3
[INFO] ------------------------------------------------------------------------
[WARNING] The POM for net.clanwolf:C3-Preloader:jar:1.0.0 is missing, no dependency information available
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.624 s
[INFO] Finished at: 2018-06-24T16:43:36+02:00
[INFO] Final Memory: 8M/44M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project C3-Client_Phoenix: Could not resolve dependencies for project net.clanwolf.c3:C3-Client_Phoenix:jar:4.7.3: Failure to find net.clanwolf:C3-Preloader:jar:1.0.0 in http://www.mvnrepository.com was cached in the local repository, resolution will not be reattempted until the update interval of mvnrepository has elapsed or updates are forced -> [Help 1]
[ERROR]

The C3-Preloader-Lib is not publically available, tried with latest online repository.

@WarWolfen
Copy link
Author

Have you

  1. installed this from the project (the jar is in with the maven install commandline as pointed out earlier) or
  2. removed to preloader line from the pom altogether?

The problem is not related to the preloader, I have tested that before.

@FibreFoX
Copy link
Member

Debugging inside a minefield, where everything could be the problem, is not that easy. Can you provide a non-living project where I can produces this issue?! "Minimal, Complete, and Verifiable example"

@FibreFoX FibreFoX reopened this Jun 24, 2018
@WarWolfen
Copy link
Author

This is a minimal example. It is actually only one empty javaFX window with the title "Hello world". There is no way of making it smaller (only thing is to delete the preloader line from the pom):
238: c3_preloader.C3_Preloader

@FibreFoX
Copy link
Member

Nor is it minimal (as it includes a lot of dependencies and code), nor is it reproducable (preloader not being public).

Putting that aside, I checked the problem and came to a conclusion: the module-part is not configured as expected. The module requires to have some main class being specified as part of the module, or having it being specified inside the module-parameter as part of the bundling-process.
https://docs.oracle.com/javase/10/tools/javapackager.htm#GUID-E51F9601-E121-4A50-BCA7-C7F8730078B2__GUID-E411F5F8-261A-4649-93E3-3BE251C88547

-m modulename [/mainclass] or --module modulename [/mainclass]

    Specifies the initial module to resolve, and the name of the main class to execute if not specified by the module.

Tooling around I got a stripped down code-part working using this bundleArguments:

<bundleArguments>
    <installdirChooser>true</installdirChooser>
    <module-path>target/classes</module-path>
    <module>net.clanwolf.c3.client/net.clanwolf.c3.client.MainFrame</module>
</bundleArguments>

Can you check that on your side that this resolves your missing window?

@FibreFoX FibreFoX changed the title Module " " not found Plugin-configuration when using JPMS Jun 24, 2018
@FibreFoX FibreFoX changed the title Plugin-configuration when using JPMS Plugin-configuration when using JPMS / JDK9+ Jun 24, 2018
@WarWolfen
Copy link
Author

Thank you very much! I will check this.

@WarWolfen
Copy link
Author

I have tested and you are right, the class was missing. It started allright. I still probably end up not being able to use it, because jlink will not find automatic modules. I am not sure about that, but the build fails if commons-collections is in the project. The problem is, that documentation about everything is spread all over the web and finding the relevant pieces is not at all easy.

Do you have clear information about that? Can this work with automatic modules after all?

@WarWolfen
Copy link
Author

Found this that might be usefull to modularize the automatic modules:
http://mail.openjdk.java.net/pipermail/jigsaw-dev/2016-July/008559.html
Will try this later today or tomorrow...

@FibreFoX
Copy link
Member

JLink requires all modules to be explicit, automatic modules are not supported (and yes, this makes JLink pretty useless ...). The whole java community is discussing the consequences, especially legacy-support/mixed-support is totally confusing.

Some parts I found by searching the internet about this:
commonmark/commonmark-java#125
google/guava#2970

https://stackoverflow.com/questions/48408454/java-9-generating-a-runtime-image-with-jlink-using-3rd-party-jars
https://stackoverflow.com/questions/47222226/how-to-inject-module-declaration-into-jar?noredirect=1&lq=1#comment82872402_47222302

A "solution" might be to have a project, where you "inject" the required module-info file, maybe using maven shade plugin, and then your project is dependant to that shaded custom jar.

As the original issue was the module-configuration, I hope you are okay that I'm closing this issue. Feel free to put any feedback or solutions you found back into this place :) maybe others will find it helpful too.

@WarWolfen
Copy link
Author

Thank you very much for your help. I have set up a NSIS for deployment. Eventually, the other libs will become compatible and things will be sorted out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants