简体   繁体   中英

jarsigner Failed to execute goal

I am using maven-jarsigner-plugin in maven to sign multiple jars however it failes.

Removing the jarsigner-maven-plugin from the pom.xml will cause the project to build successfully. So it is defenitly the jarsigner.

Error:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-jarsigner-plugin:1.3.2:sign (sign) on project com.company.example: 
Failed executing 'cmd.exe /X /C ""C:\Program Files\Java\jdk1.8.0_20\jre\..\bin\jarsigner.exe" -keystore ..\com.company.maven\KeyStore -storepass ***** -keypass *****
C:\Project\com.company.example\target\com.company.example-3.2.1-SNAPSHOT.jar Foo"' - exitcode 1 -> [Help 1]

pom.xml

<plugin>
         <groupId>org.apache.maven.plugins</groupId>
             <artifactId>maven-jarsigner-plugin</artifactId>
             <version>1.3.2</version>
             <configuration>
              <keystore>..\com.company.maven\KeyStore</keystore>
              <storepass>abcd123</storepass>
              <alias>Foo</alias>
              <keypass>abcd123</keypass>
             </configuration>
             <executions>
              <execution>
               <id>sign</id>
               <goals>
                <goal>sign</goal>
               </goals>
              </execution>
             </executions>
</plugin>

Performing the command manually works fine.

c:\my_project\com.company.example.maven>C:\Java\jdk1.8.0_20\jre\..\bin\jarsigner.exe -keystore ..\com.company.example.maven\KeyStore -storepass 1234ab -keypa
ss 1234ab C:\my_project\com.company.example.model\target\com.company.example.model-3.2.1-SNAPSHOT.jar Foo
jar signed.

Warning:
The signer certificate has expired.
No -tsa or -tsacert is provided and this jar is not timestamped. Without a timestamp, users may not be able to validate this jar after the signer cert
ificate's expiration date (2014-10-22) or after any future revocation date.

Any help is would be appreciated.

EDIT: The problem occurs on my machine but not others, havent found the problem yet.

More detailed report

 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-jarsigner-plugin:1.3.2:sign (sign) on project com.example.project.model: Failed executing 'cmd.
    exe /X /C "C:\Java\jdk1.8.0_20\jre\..\bin\jarsigner.exe -keystore ..\com.example.project.maven\KeyStore -storepass ***** -keypass ***** C:\Developer\Ecl
    ipseWorkspaces\IDE\com.example.project.model\target\com.example.project.model-3.2.0-SNAPSHOT.jar Foo"' - exitcode 1 -> [Help 1]
    org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-jarsigner-plugin:1.3.2:sign (sign) on pr
    oject com.example.project.model: Failed executing 'cmd.exe /X /C "C:\Java\jdk1.8.0_20\jre\..\bin\jarsigner.exe -keystore ..\com.example.project.maven\KeyStore
    -storepass ***** -keypass ***** C:\Developer\EclipseWorkspaces\IDE\com.example.project.model\target\com.example.project.model-3.2.0-SNAPSHOT.jar Foo"' - exi
    tcode 1
            at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216)
            at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
            at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
            at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
            at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
            at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
            at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:120)
            at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:347)
            at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:154)
            at org.apache.maven.cli.MavenCli.execute(MavenCli.java:582)
            at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214)
            at org.apache.maven.cli.MavenCli.main(MavenCli.java:158)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
            at java.lang.reflect.Method.invoke(Method.java:483)
            at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
            at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
            at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
            at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
    Caused by: org.apache.maven.plugin.MojoExecutionException: Failed executing 'cmd.exe /X /C "C:\Java\jdk1.8.0_20\jre\..\bin\jarsigner.exe -keystore ..\
    com.example.project.maven\KeyStore -storepass ***** -keypass ***** C:\Developer\EclipseWorkspaces\IDE\com.example.project.model\target\com.example.project.model
    -3.2.0-SNAPSHOT.jar foo"' - exitcode 1
            at org.apache.maven.plugins.jarsigner.AbstractJarsignerMojo.processArchive(AbstractJarsignerMojo.java:511)
            at org.apache.maven.plugins.jarsigner.AbstractJarsignerMojo.processArtifact(AbstractJarsignerMojo.java:427)
            at org.apache.maven.plugins.jarsigner.AbstractJarsignerMojo.execute(AbstractJarsignerMojo.java:278)
            at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:132)
            at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
            ... 19 more
    [ERROR]
    [ERROR] Re-run Maven using the -X switch to enable full debug logging.
    [ERROR]
    [ERROR] For more information about the errors and possible solutions, please read the following articles:
    [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
    [ERROR]
    [ERROR] After correcting the problems, you can resume the build with the command
    [ERROR]   mvn <goals> -rf :com.example.project.model

I solved the Failed to execute goal org.apache.maven.plugins:maven-jarsigner-plugin:1.3.2:sign (sign) in my project by fixing the manifest in the jar I was signing.

My manifest CodeBase entry looked like the following when the signing would fail.

Codebase: example.com test1.example.com test2.example.com

            example.org test1.example.org test2.example.org

All of the Codebase entries should have be on one line. The erroneous formatting was due to Eclipses source --> format tool. When I had last cleaned up the source format, Eclipse had placed undesired line returns and tabs between <Codebase> and </Codebase> . Once this undesired white space was removed the maven build completed as desired.

I had same problem. I fixed only adding extension for file ( testkeys.store )

  <alias>stathis</alias>
  <keystore>${project.basedir}\testkeys.store</keystore>
  <storepass>123456</storepass>
  <keypass>123456</keypass>

I had this exact issue. My problem was that I had typo'd the keystore name. Fixing the typo fixed the whole issue. I also had to include the extension name on the keystore.

Hope this is useful for someone, I had a similar issue.

In my pom.xml I had a plugin called maven-assembly-plugin , turns out that the plugin needs to be after the maven-jarsigner-plugin plugin for some reason. But after the change works like a charm.

Use this link for reference.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM