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

Error at start on Windows #41

Closed
HumanG33k opened this issue Jul 8, 2020 · 26 comments
Closed

Error at start on Windows #41

HumanG33k opened this issue Jul 8, 2020 · 26 comments

Comments

@HumanG33k
Copy link

Hello,

I probably miss something but when i try to execute my generate exe it not start.
After i start it in a powershell shell it says it can’t find my main class but the fat jar build start without trouble with a :

java -jar mydot.jar

This is my relevant pom part :

            <plugin>
                <groupId>io.github.fvarrui</groupId>
                <artifactId>javapackager</artifactId>
                <version>1.1.0</version>
                <executions>
                    <execution>
                        <id>windows</id>
                        <phase>package</phase>
                        <goals>
                            <goal>package</goal>
                        </goals>
                        <configuration>
                            
                            <mainClass>com.mytestcompany.mytestproject.Main</mainClass>
                            
                            <bundleJre>false</bundleJre>
                            <runnableJar>target/mydot.jar</runnableJar>
                            <copyDependencies>false</copyDependencies>
                            <generateInstaller>true</generateInstaller>        
                            <administratorRequired>true</administratorRequired>
                            
                            <platform>windows</platform>
                            <winConfig>
                                <generateSetup>true</generateSetup>
                                <generateMsi>true</generateMsi>
                                <headerType>console</headerType>
                            </winConfig>
                    </configuration>
                    </execution>
               </executions>
           </plugin>

For the record my main javafx class is already in a wrapper java main class.

@fvarrui
Copy link
Owner

fvarrui commented Jul 8, 2020

Hi @HumanG33k!
Can you share mvn package, mvn -v and exe output, please?

@fvarrui
Copy link
Owner

fvarrui commented Jul 8, 2020

Hi again!
Here you can find a sample project using a runnable fat jar, using same plugin options as yours.
https://github.com/fvarrui/HelloWorld

@HumanG33k
Copy link
Author

HumanG33k commented Jul 9, 2020

hi,
sry for waiting and thx to check my issue and try to help.
build is quite long + i try to do anomymisation on files.
Has you will see its not a small project. I already read example and some already closed issues. I probably miss somethings.
version.log
package.log

I m aware about the fact 13 is already dead. (F*cking stupid 6 months release )

@fvarrui
Copy link
Owner

fvarrui commented Jul 9, 2020

Ok! It seems that you are executing the plugin múltiple times, but If I’m not wrong, each execution removes the previous generated app. I know this is not the problem, but I have to warn you. Take a look at this link!

Can you confirm to me that com.organization.mavenproject3.Main is your main class? (Sorry, but I have to ask you)

Don’t worry about 13, I’m using too!! I’m too lazy to update it

@HumanG33k
Copy link
Author

yes it is. i miss it during my anonymisation. can you edit your post to remove it ? thx.
I absolutly not understand why its working in allinone jar when i run it in netbeans i have to specify the main class paht as arg :

-classpath %classpath com.organisation.mavenproject3.Main

@HumanG33k
Copy link
Author

HumanG33k commented Jul 9, 2020

do you know if something similar is possible with javapacker or if my error can be related to that ?

@fvarrui
Copy link
Owner

fvarrui commented Jul 9, 2020

You can specify VM arguments to javapackager using vmArgs option.

I’ve seen that launch4j fails with too fat jars. Can you try your jar with launch4j in standalone mode?

@HumanG33k
Copy link
Author

For launch4j :

The standalone launch4j says it need 1.6 -1.8 jre.
So i had the java 8 (install it) because i only have the openjdk 13 install.
I do it works (l4j starts)

I try to build the exe and this configuration file permit to start it :

<?xml version="1.0" encoding="UTF-8"?>
<launch4jConfig>
  <dontWrapJar>true</dontWrapJar>
  <headerType>gui</headerType>
  <jar>project-1.0-SNAPSHOT.jar</jar>
  <outfile>D:\USER\Projects\USER_tmp\Project\target\project.exe</outfile>
  <errTitle></errTitle>
  <cmdLine></cmdLine>
  <chdir>.</chdir>
  <priority>normal</priority>
  <downloadUrl>https://adoptopenjdk.net/</downloadUrl>
  <supportUrl></supportUrl>
  <stayAlive>false</stayAlive>
  <restartOnCrash>false</restartOnCrash>
  <manifest></manifest>
  <icon></icon>
  <classPath>
    <mainClass>com.organisation.mavenproject3.Main</mainClass>
    <cp>%classpath com.organisation.mavenproject3.Main</cp>
  </classPath>
  <jre>
    <path></path>
    <bundledJre64Bit>false</bundledJre64Bit>
    <bundledJreAsFallback>false</bundledJreAsFallback>
    <minVersion>11</minVersion>
    <maxVersion>14</maxVersion>
    <jdkPreference>preferJre</jdkPreference>
    <runtimeBits>64/32</runtimeBits>
  </jre>
</launch4jConfig>

i guess error come from the cp option.
Can i specify it on javapacker ?

@fvarrui
Copy link
Owner

fvarrui commented Jul 10, 2020

I see that you have configured the property dontWrapJar to true, so jar is not included inside the exe file. This is a proposed solution when using very large jar files with launch4j. Maybe is this the difference?

@fvarrui
Copy link
Owner

fvarrui commented Jul 10, 2020

And, no, you can’t specify cp option for launch4j right now, but it’s possible to include mainclass in cp by default or include a new plugin option. I don't think adding it affects other developers

@fvarrui
Copy link
Owner

fvarrui commented Jul 12, 2020

I've added mainclass to classpath by default to launch4j and published to 1.1.1-SNAPSHOT. Can you give it a try?

⚠️ You have to install the plugin manually in your local repo:

git clone https://github.com/fvarrui/JavaPackager
cd JavaPackager
gradlew clean build publishToMavenLocal

@HumanG33k
Copy link
Author

HumanG33k commented Jul 15, 2020

hello,
sry i have been busy, i try but i have an error with the main class for the gradlew.bat

I guess it s because gradle jar are not in the project directory.

so i try a

gradle wrapper

but i have an error, the --info says

* Where:
Build file 'JavaPackager\build.gradle' line: 189

* What went wrong:
A problem occurred evaluating root project 'javapackager'.
> Could not get unknown property 'ossrhUser' for NexusStagingExtension(serverUrl:https://oss.sonatype.org/service/local/, username:null, password:null, packageGroup:null, stagingProfileId:null, numberOfRetries:7, delayBetweenRetriesInMillis:1000) of type io.codearte.gradle.nexus.NexusStagingExtension.

So i "fix" it by commenting the part in build.gradle and relaunch the command.

After that i retry the following command

and a new error occur :

> Task :generatePluginDescriptor
[main] INFO org.apache.maven.cli.MavenCli - Error stacktraces are turned on.
[main] INFO org.apache.maven.cli.event.ExecutionEventLogger - Scanning for projects...
[main] INFO org.apache.maven.cli.event.ExecutionEventLogger - ------------------------------------------------------------------------
[main] INFO org.apache.maven.cli.event.ExecutionEventLogger - BUILD FAILURE
[main] INFO org.apache.maven.cli.event.ExecutionEventLogger - ------------------------------------------------------------------------
[main] INFO org.apache.maven.cli.event.ExecutionEventLogger - Total time:  0.479 s
[main] INFO org.apache.maven.cli.event.ExecutionEventLogger - Finished at: 2020-07-15T10:37:17+02:00
[main] INFO org.apache.maven.cli.event.ExecutionEventLogger - ------------------------------------------------------------------------
[main] ERROR org.apache.maven.cli.MavenCli - Plugin org.apache.maven.plugins:maven-plugin-plugin:3.4 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-plugin-plugin:jar:3.4: Could not transfer artifact org.apache.maven.plugins:maven-plugin-plugin:pom:3.4 from/to central (https://repo.maven.apache.org/maven2): No connector factories available -> [Help 1]
org.apache.maven.plugin.PluginResolutionException: Plugin org.apache.maven.plugins:maven-plugin-plugin:3.4 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-plugin-plugin:jar:3.4
        at org.apache.maven.plugin.internal.DefaultPluginDependenciesResolver.resolve(DefaultPluginDependenciesResolver.java:120)
        at org.apache.maven.plugin.internal.DefaultMavenPluginManager.getPluginDescriptor(DefaultMavenPluginManager.java:182)
        at org.apache.maven.plugin.internal.DefaultMavenPluginManager.getMojoDescriptor(DefaultMavenPluginManager.java:286)
        at org.apache.maven.plugin.DefaultBuildPluginManager.getMojoDescriptor(DefaultBuildPluginManager.java:244)
        at org.apache.maven.lifecycle.internal.MojoDescriptorCreator.getMojoDescriptor(MojoDescriptorCreator.java:239)
        at org.apache.maven.lifecycle.internal.DefaultLifecycleTaskSegmentCalculator.calculateTaskSegments(DefaultLifecycleTaskSegmentCalculator.java:104)
        at org.apache.maven.lifecycle.internal.DefaultLifecycleTaskSegmentCalculator.calculateTaskSegments(DefaultLifecycleTaskSegmentCalculator.java:83)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:89)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:305)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:192)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:105)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:957)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:289)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:193)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:182)
Caused by: org.eclipse.aether.resolution.ArtifactDescriptorException: Failed to read artifact descriptor for org.apache.maven.plugins:maven-plugin-plugin:jar:3.4
        at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.loadPom(DefaultArtifactDescriptorReader.java:255)
        at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.readArtifactDescriptor(DefaultArtifactDescriptorReader.java:171)
        at org.eclipse.aether.internal.impl.DefaultRepositorySystem.readArtifactDescriptor(DefaultRepositorySystem.java:255)
        at org.apache.maven.plugin.internal.DefaultPluginDependenciesResolver.resolve(DefaultPluginDependenciesResolver.java:106)
        ... 14 more
Caused by: org.eclipse.aether.resolution.ArtifactResolutionException: Could not transfer artifact org.apache.maven.plugins:maven-plugin-plugin:pom:3.4 from/to central (https://repo.maven.apache.org/maven2): No connector factories available
        at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:424)
        at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:229)
        at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifact(DefaultArtifactResolver.java:207)
        at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.loadPom(DefaultArtifactDescriptorReader.java:240)
        ... 17 more
Caused by: org.eclipse.aether.transfer.ArtifactTransferException: Could not transfer artifact org.apache.maven.plugins:maven-plugin-plugin:pom:3.4 from/to central (https://repo.maven.apache.org/maven2): No connector factories available
        at org.eclipse.aether.internal.impl.DefaultArtifactResolver.performDownloads(DefaultArtifactResolver.java:506)
        at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:401)
        ... 20 more
Caused by: org.eclipse.aether.transfer.NoRepositoryConnectorException: No connector factories available
        at org.eclipse.aether.internal.impl.DefaultRepositoryConnectorProvider.newRepositoryConnector(DefaultRepositoryConnectorProvider.java:168)
        at org.eclipse.aether.internal.impl.DefaultArtifactResolver.performDownloads(DefaultArtifactResolver.java:496)
        ... 21 more
[main] ERROR org.apache.maven.cli.MavenCli -
[main] ERROR org.apache.maven.cli.MavenCli - Re-run Maven using the -X switch to enable full debug logging.
[main] ERROR org.apache.maven.cli.MavenCli -
[main] ERROR org.apache.maven.cli.MavenCli - For more information about the errors and possible solutions, please read the following articles:
[main] ERROR org.apache.maven.cli.MavenCli - [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginResolutionException

> Task :generatePluginDescriptor FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':generatePluginDescriptor'.
> Process 'command 'C:\Program Files\AdoptOpenJDK\jdk-14.0.1.7-hotspot\bin\java.exe'' 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

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.

@fvarrui
Copy link
Owner

fvarrui commented Jul 15, 2020

Ok! I’ve been making changes trying to build and release the plugin with Gradle. I’ll try to build it on a brand new virtual machine to reproduce your problem

@HumanG33k
Copy link
Author

@fvarrui did you test in virtual machine ? I really curious about if this problem came from my setup.

@fvarrui
Copy link
Owner

fvarrui commented Jul 19, 2020

Hi @HumanG33k!
I've just tested in a VM and managed to reproduce your issues:

  • Gradle jar was not included in .gitignore by mistake 😅 ... it's already uploaded to the repo.
  • It took ossrhUser and ossrhPassword properties from $HOME/.gradle/gradle.properties file, needed to release the plugin to Maven Central, but not to release to your local repo .... so, now if these properties are not found because this file doesn't exist, it uses empty strings, so it doesn't fail.
  • Some dependencies needed for maven-embeder were missing, so it couldn't download dependencies from Maven Central. I didn't experience these problems because I already had such dependencies in my local Maven repository.

I hope now you can build and publish SNAPSHOT version to your local repo.

@HumanG33k
Copy link
Author

HumanG33k commented Jul 28, 2020

the build and the publish work but i have some jni error when i execute my jar/exe i will investigate.
thx for your quick fix by the way.

@fvarrui
Copy link
Owner

fvarrui commented Aug 11, 2020

Maybe it could be related to this Launch4j issue.

I could add a new property to choose if JAR has to be wrapped into EXE or stay next to it, if this is the problem.

@HumanG33k
Copy link
Author

HumanG33k commented Aug 12, 2020

it's probably the case.
i think you already did that work but you should have

  • an association table for common option (behavior is probably more appropriate)
  • a way to specify option by sub tools
  • and if time use your tool for already existing java libre software for add more test cases and promote your tool which is really cool at global project scope.

Also for my previous test program, exe are well generated but not find the main class even if my jar work with simple

java -jar myfat.jar

@fvarrui
Copy link
Owner

fvarrui commented Aug 13, 2020

it's probably the case.
i think you already did that work but you should have

  • an association table for common option (behavior is probably more appropriate)

There are a samples page, with different use cases. I have to add more.

  • a way to specify option by sub tools

I’m not sure what you mean.

  • and if time use your tool for already existing java libre software for add more test cases and promote your tool which is really cool at global project scope.

Good idea!! Thanks

Also for my previous test program, exe are well generated but not find the main class even if my jar work with simple

java -jar myfat.jar

If you create a mock project, similar to yours, maybe I could help.

@HumanG33k
Copy link
Author

HumanG33k commented Aug 13, 2020

  • a way to specify option by sub tools

I’m not sure what you mean.

the creation on windows need inno setup and WiX. And both have probably their own options. And had a way to specify throught your config part their options.

Also you if you can (money skills time) build or use a CI stack to auto build your project and the projects use your project.

Your example page is really good it permit a fast learning curve (not sure of the sentence) maybe a back link at the end to option list.

If you have the time to add the option to not bundle it can be great.

@fvarrui
Copy link
Owner

fvarrui commented Aug 15, 2020

  • a way to specify option by sub tools

I’m not sure what you mean.

the creation on windows need inno setup and WiX. And both have probably their own options. And had a way to specify throught your config part their options.

Ok, I get you ... but Inno Setup and WIX are too complex to contemplate all their variants. For this reason, I enabled the possibility of adding custom options to the plugin through the extra property and creating custom templates. However, when there is a common and useful option, I try to add it to the plugin ... as wrapJar property, for example.

Also you if you can (money skills time) build or use a CI stack to auto build your project and the projects use your project.

Yes, it's a good idea! When I have a little more time, I'd like to add test cases to the plugin.

Your example page is really good it permit a fast learning curve (not sure of the sentence) maybe a back link at the end to option list.

If you have the time to add the option to not bundle it can be great.

Yes, I'll do it.

@fvarrui
Copy link
Owner

fvarrui commented Aug 16, 2020

wrapJar property added to winConfig in 1.2.0-SNAPSHOT, which requires a manual installation.

@fvarrui
Copy link
Owner

fvarrui commented Sep 16, 2020

I've just released v1.2.0 to Maven Central with the new winConfig.wrapJar property.
Have you been able to test it?

@fvarrui
Copy link
Owner

fvarrui commented Sep 21, 2020

I'm going to close this issue ... if it's not resolved, we can reopen it and further investigate the cause.
Thx!

@fvarrui fvarrui closed this as completed Sep 21, 2020
@Trylam
Copy link

Trylam commented Sep 28, 2020

Hi,
I am taking over the project instead of HumanG33k.
When i try, i have an exception : Module java.activation not found, required by java.xml.soap

@fvarrui
Copy link
Owner

fvarrui commented Sep 28, 2020

Hi @Trylam!
I've opened a new issue.
Regards

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