Proguard configuration on a Enterprise Java Application - maven

I'm trying to use proguard in a Maven project this is a obfuscate plugin, when I run it I have an error:
Failed to execute goal com.pyx4me:proguard-maven-plugin:2.0.4:proguard (default) on project MavenEnterpriseApp-ear: Obfuscation failed (result=1) -> [Help 1]
when I run maven with -e or -X I have:
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.pyx4me:proguard-maven-plugin:2.0.4:proguard (default) on project MavenEnterpriseApp-ear: Obfuscation failed (result=1)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:217)
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:84)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:319)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
My plugin configuration is:
<plugin>
<groupId>com.pyx4me</groupId>
<artifactId>proguard-maven-plugin</artifactId>
<version>2.0.4</version>
<executions>
<execution>
<phase>prepare-package</phase>
<goals>
<goal>proguard</goal>
</goals>
</execution>
</executions>
<configuration>
<obfuscate>true</obfuscate>
<includeDependency>false</includeDependency>
<injar>${project.artifactId}-v${project.version}.ear</injar>
<outjar>${project.artifactId}-v${project.version}-obf.ear</outjar>
<outputDirectory>${project.build.directory}</outputDirectory>
<maxMemory>256m</maxMemory>
</configuration>
</plugin>
As you can see I'm trying to ofuscate the ear. In the official page:
injar: Specifies the input jar name (or wars, ears, zips) of the
application to be processed. You may specify a classes directory e.g.
'classes'. This way plugin will processed the classes instead of jar.
You would need to bind the execution to phase 'compile' or
'process-classes' in this case.
The project is an a Maven Enterise Application project, basically I have 2 sub project one with JPA and EJB3 resources and the other is an a web project with jsf the structure is. When I run Maven I obtain an ear, in this I have 2 binaries a jar and a war. I have three
questions:
First) In what pom I suppose to insert it? now I'm using the pom into the EAR project as you can see:
Second)I can obfuscatean an ear?
Third) If the second is false: how can I obfuscate specificlly the ears? I'm trying to specify the jars but I recive the same error ever:
Failed to execute goal com.pyx4me:proguard-maven-plugin:2.0.4:proguard (default) on project MavenEnterpriseApp-ear: Obfuscation failed (result=1) -> [Help 1]

Try to change phase of proguard from "prepare-package" into "process-classes", change injar option into "classes", and let me know if it does not work.
HTH.

Related

Getting a java.lang.IllegalArgumentException when updating cucumber-groovy version in POM file

I'm getting the following exception when updating the cucumber-groovy version in my POM file from 4.2.0 to 4.7.0
java.lang.IllegalArgumentException: The glue path contained invalid identifiers target/test-classes
at io.cucumber.core.model.GluePath.parseAssumeClasspathScheme (GluePath.java:84)
at io.cucumber.core.model.GluePath.parse (GluePath.java:53)
at io.cucumber.core.options.RuntimeOptionsParser.parse (RuntimeOptionsParser.java:85)
at io.cucumber.core.options.CommandlineOptionsParser.parse (CommandlineOptionsParser.java:25)
at io.cucumber.core.options.CommandlineOptionsParser.parse (CommandlineOptionsParser.java:29)
at io.cucumber.core.cli.Main.run (Main.java:29)
at io.cucumber.core.cli.Main.main (Main.java:14)
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:498)
at org.codehaus.mojo.exec.ExecJavaMojo$1.run (ExecJavaMojo.java:282)
at java.lang.Thread.run (Thread.java:748)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.329 s
[INFO] Finished at: 2019-10-28T19:17:41+11:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.6.0:java (default) on project sample-test: An exception occured while executing the Java class. The glue path contained invalid identifiers target/test-classes -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[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
This is the section of POM file where the error is being generated from (I believe)
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>${exec-maven-plugin.version}</version>
<executions>
<execution>
<phase>test</phase>
<goals>
<goal>java</goal>
</goals>
<configuration>
<classpathScope>test</classpathScope>
<mainClass>io.cucumber.core.cli.Main</mainClass> <!-- NEEDED FOR cucumber-groovy version 4.7.1 -->
<!--<mainClass>cucumber.api.cli.Main</mainClass>--> <!-- NEEDED FOR cucumber-groovy version 4.2.0 -->
<arguments>
<argument>--plugin</argument>
<argument>json:reports/junit.json</argument>
<argument>--strict</argument>
<argument>--glue</argument>
<argument>target/test-classes</argument>
<argument>target/test-classes/.</argument>
<argument>--tags</argument>
<argument>${tagArg}</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
And here is the properties section of the POM file
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<cluecumber-report-plugin.version>2.3.1</cluecumber-report-plugin.version>
<exec-maven-plugin.version>1.6.0</exec-maven-plugin.version>
<maven-clean-plugin.version>3.1.0</maven-clean-plugin.version>
<maven-surefire-plugin.version>2.22.2</maven-surefire-plugin.version>
<ocular.version>1.0.0.Alpha</ocular.version>
<groovycsv.version>1.3</groovycsv.version>
<ashot.version>1.5.4</ashot.version>
<webdrivermanager.version>3.7.1</webdrivermanager.version>
<com4j.version>2.1</com4j.version>
<geb-core.version>3.2</geb-core.version>
<http-builder.version>0.7.1</http-builder.version>
<commons-io.version>2.6</commons-io.version>
<selenium-api.version>3.141.59</selenium-api.version>
<selenium-java.version>3.141.59</selenium-java.version>
<slf4j-simple.version>1.7.28</slf4j-simple.version>
<cucumber-jvm.version>4.8.0</cucumber-jvm.version>
<cucumber-groovy.version>4.7.0</cucumber-groovy.version>
<groovy-all.version>2.5.8</groovy-all.version>
</properties>
Same POM file works fine when using the cucumber-groovy version 4.2.0, is there a different way to specify the glue code for newer version of cucumber-groovy?
I have tried using the following but none of them worked.
target.test-classes
target
test-classes
My folder structure is
src\test\resources\features
src\test\resources\step_definitions
Any help is highly appreciated.
Thanks!
You currently pass your glue as --glue target/test-classes target/test-classes/. However your glue should be either a package name or class path uri. To access resources in the nameless package you can use --glue classpath: instead.
update POM file and replace
--glue target/test-classes target/test-classes/.
with
--glue classpath: classpath:/.

Create an EAR using Maven

I want to create an EAR using Maven, but since I'm in a pure Tycho world, I can't use the maven-ear-plugin, just the maven-assembly-plugin (which is fine).
There are multiple questions even on this very site that indicate that the maven-assembly-plugin can build EARs, even though the documentation says no.
However, when I use define the EAR format like this:
<formats>
<format>ear</format>
</formats>
I get the following exception:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-assembly-plugin:3.0:single (make-assembly) on project org.acme.application: Failed to create assembly: Error creating assembly archive default: appxml attribute is required -> [Help 1]
(I tried a couple of versions for the maven-assembly-plugin, so it's not that.)
Since a EAR is just a renamed JAR, I'm now using the JAR format and this other Maven plug-in:
<plugin>
<groupId>com.coderplus.maven.plugins</groupId>
<artifactId>copy-rename-maven-plugin</artifactId>
<version>1.0</version>
<executions>
<execution>
<id>rename-ear</id>
<phase>verify</phase>
<goals>
<goal>rename</goal>
</goals>
<configuration>
<sourceFile>${basedir}/target/${earName}.jar</sourceFile>
<destinationFile>${basedir}/target/${earName}.ear</destinationFile>
</configuration>
</execution>
</executions>
</plugin>
Which works nicely in creating an EAR, however with mvn install it brings the following exception:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-install-plugin:2.5.2:install (default-install) on project org.acme.application: Failed to install artifact group:org.acme.application:jar:1.9.126-SNAPSHOT: C:\workspace\Application\target\Application.jar (Das System kann die angegebene Datei nicht finden) -> [Help 1]
(It's German for "Cannot find file", one day I'll get him to print out readable error messages.)
Of course, now I could copy the JAR to an EAR instead of just renaming it, but I thought I get a 2nd oppinion first: Is it possible to create an EAR with the maven-assembly-plugin? If so, how?

Could not transfer artifact jlibs:jlibs-xml:pom:1.0 from/to kepler

I am running the pom.xml with in the Myeclipse window. Getting the error related to Kepler repository. Not sure why I am seeing this error. Please refer the error stack below -
[ERROR] Failed to execute goal org.raml.plugins:jaxrs-raml-maven-plugin:1.3.3:generate-raml (default) on project Service: Execution default of goal org.raml.plugins:jaxrs-raml-maven-plugin:1.3.3:generate-raml failed: Plugin org.raml.plugins:jaxrs-raml-maven-plugin:1.3.3 or one of its dependencies could not be resolved: Failed to collect dependencies for org.raml.plugins:jaxrs-raml-maven-plugin:jar:1.3.3 (): Failed to read artifact descriptor for jlibs:jlibs-xml:jar:1.0: Could not transfer artifact jlibs:jlibs-xml:pom:1.0 from/to kepler (http://download.eclipse.org/releases/kepler): No connector available to access repository kepler (http://download.eclipse.org/releases/kepler) of type p2 using the available factories AsyncRepositoryConnectorFactory, WagonRepositoryConnectorFactory -> [Help 1]
I am using the below maven code -
<plugin>
<groupId>org.raml.plugins</groupId>
<artifactId>jaxrs-raml-maven-plugin</artifactId>
<version>1.3.3</version>
<configuration>
<sourcePaths>
<param>${basedir}/src/main/java/Service.java</param>
</sourcePaths>
<sourceDirectory>${basedir}/src/main/java</sourceDirectory>
<outputFile>${project.build.directory}/generated-sources/jaxrs-raml/example.raml</outputFile>
</configuration>
<executions>
<execution>
<goals>
<goal>generate-raml</goal>
</goals>
<phase>process-classes</phase>
</execution>
</executions>
Not facing similar while running the plug in code for "raml-jaxrs-maven-plugin"
Any help would be appreciated.

Failed to deploy artifacts: Could not find artifact

I want to deploy a library to my companies remote repository.
It's the first time I want to deploy the library project to the remote repository.
I get the following error message:
org.sonatype.aether.transfer.ArtifactNotFoundException: Could not find artifact com.http:httpkit:jar:0.0.1 in internal.repo (http://jenkins.internal.com/)
Maybe I understand something complete wrong, but the error message says, that in the remote repository doesn't exist the artifact that I try to deploy for the first time. So of course there is not such artifact. Why does maven tries to fetch the artifact when I try to upload the artifact?
My pom file:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.http</groupId>
<artifactId>httpkit</artifactId>
<version>0.0.1</version>
<packaging>jar</packaging>
<name>httpkit</name>
<properties>
<platform.version> 4.1.1.4</platform.version>
</properties>
<dependencies>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>${platform.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>
<!-- Deploy to internal maven repository -->
<distributionManagement>
<repository>
<id>internal.repo</id>
<name>Internal Repository</name>
<url>http://jenkins.internal.com/</url>
</repository>
</distributionManagement>
<build>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>3.5.3</version>
<configuration>
<androidManifestFile>${project.basedir}/AndroidManifest.xml</androidManifestFile>
<assetsDirectory>${project.basedir}/assets</assetsDirectory>
<resourceDirectory>${project.basedir}/res</resourceDirectory>
<nativeLibrariesDirectory>${project.basedir}/src/main/native</nativeLibrariesDirectory>
<sdk>
<platform>16</platform>
</sdk>
<undeployBeforeDeploy>true</undeployBeforeDeploy>
</configuration>
<extensions>true</extensions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
I call
mvn deploy
from command line
Any suggestion how to fix that problem?
EDIT: The failure log (running mvn deploy -X)
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project httpkit: Failed to deploy artifacts: Could not find artifact com.http:httpkit:jar:0.0.1 in internal.repo (http://jenkins.internal.com) -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project httpkit: Failed to deploy artifacts: Could not find artifact com.http:httpkit:jar:0.0.1 in internal.repo (http://jenkins.internal.com)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:217)
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:84)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
Caused by: org.apache.maven.plugin.MojoExecutionException: Failed to deploy artifacts: Could not find artifact com.http:httpkit:jar:0.0.1 in internal.repo (http://jenkins.internal.com)
at org.apache.maven.plugin.deploy.DeployMojo.execute(DeployMojo.java:193)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
... 19 more
Caused by: org.apache.maven.artifact.deployer.ArtifactDeploymentException: Failed to deploy artifacts: Could not find artifact com.http:httpkit:jar:0.0.1 in internal.repo (http://jenkins.internal.com)
at org.apache.maven.artifact.deployer.DefaultArtifactDeployer.deploy(DefaultArtifactDeployer.java:141)
at org.apache.maven.plugin.deploy.AbstractDeployMojo.deploy(AbstractDeployMojo.java:167)
at org.apache.maven.plugin.deploy.DeployMojo.execute(DeployMojo.java:157)
... 21 more
Caused by: org.sonatype.aether.deployment.DeploymentException: Failed to deploy artifacts: Could not find artifact com.http:httpkit:jar:0.0.1 in internal.repo (http://jenkins.internal.com)
at org.sonatype.aether.impl.internal.DefaultDeployer.deploy(DefaultDeployer.java:280)
at org.sonatype.aether.impl.internal.DefaultDeployer.deploy(DefaultDeployer.java:211)
at org.sonatype.aether.impl.internal.DefaultRepositorySystem.deploy(DefaultRepositorySystem.java:443)
at org.apache.maven.artifact.deployer.DefaultArtifactDeployer.deploy(DefaultArtifactDeployer.java:137)
... 23 more
Caused by: org.sonatype.aether.transfer.ArtifactNotFoundException: Could not find artifact com.http:httpkit:jar:0.0.1 in internal.repo (http://jenkins.internal.com/)
at org.sonatype.aether.connector.wagon.WagonRepositoryConnector$4.wrap(WagonRepositoryConnector.java:947)
at org.sonatype.aether.connector.wagon.WagonRepositoryConnector$4.wrap(WagonRepositoryConnector.java:941)
at org.sonatype.aether.connector.wagon.WagonRepositoryConnector$PutTask.run(WagonRepositoryConnector.java:837)
at org.sonatype.aether.connector.wagon.WagonRepositoryConnector.put(WagonRepositoryConnector.java:467)
at org.sonatype.aether.impl.internal.DefaultDeployer.deploy(DefaultDeployer.java:274)
... 26 more
[ERROR]
[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
Have you tried to add the server in your settings.xml file? The default settings xml is located in your ~/.m2/ directory. Should contain something like that:
<servers>
<server>
<id>my-internal-nexus-repo</id>
<username>yourUserName</username>
<password>yourPassword</password>
</server>
</servers>
Here is a link to the http://maven.apache.org/settings.html maven doc for adding servers.
One other thing which might be a shot in the dark. I've noticed you are trying to connect to what the url suggests might be a Jenkins instance. Jenkins is a Continious Integration server and seemed strange to me that you are finding your repositories there. I would expect a Nexus url or something.
A possible cause is that you simply misspelt the repository name, or used the wrong repository name entirely
So using the OP's example:
Failed to deploy artifacts: Could not find artifact com.http:httpkit:jar:0.0.1 in internal.
repo (http://jenkins.intrnal.com)
could actually mean
Failed to deploy artifacts: Could not find internal.repo (http://jenkins.intrnal.com)
We have faced this issue. After couple of hours, we figured it is disk space issue in internal repository.
I ran into a similar problem and solved by
Adding my nexus server as a nonProxyHost in settings.xml
Setting the 3rd party's Repository Policy to Release rather than
Snapshot.
See more details in my stackoverflow answer.
Note that I was doing a "mvn deploy:deploy-file" (which uploads a 3rd party artifact to the shared repository) whereas you are doing a "mvn deploy" (which uploads YOUR artifact from your built project to the shared repository), but the root cause maybe the same.
In my case my server url in snapshotRepository section of pom.xml was pointing to http, while my internal repository was hosted in https.
Regarding the error:
Failed to deploy artifacts: Could not transfer artifact
Solution:
A very simple way to fix this is just by changing/updating the version in the pom.xml file. Suppose 01.16.03 is already used then try using 01.16.04 instead. It should work.
Okay...I encountered the same issue some days ago.
And after fiddling around with all sort of permutations and combination, I finally arrived at the conclusion.
Those who says that the reactor automatically sorts and resolves all dependencies on its own are incorrect. It seems that the link below describes it all. Kindly look at the last point under "Reactor Sorting" section:
https://maven.apache.org/guides/mini/guide-multiple-modules.html#Reactor_Sorting
It suggests that the order in which the modules are defined are taken into consideration when no other rules applies.
I hope that helps other. :)
It is because your Maven not able to find settings file. If deleting .m2 not work, try below solution
Go to your JOB configuration
than to the Build section
Add build step :- Invoke top level maven target and fill Maven version and Goal
than click on Advance button and mention settings file path as mention in image
Today i encountered the same issue.My solution was to upgrade pom version.Sure,you can also modify the nexus settings so that the same version number can be uploaded repeatedly,but the second method I haven't practiced myself, you can try.
In my case, Blob Store is almost running out of space. I have forgotten to set up clean-up policies. Once the disk space is cleared this issue is solved.
Maven knows the URL of the repository to deploy to from the repository (or snapshotRepository) sub elements of the distributionManagement element in the POM:
<distributionManagement>
<repository>
<id>{some ID}</id>
<name>{some helpful name}</name>
<url>http://example.com:8081/repository/maven-releases/</url>
</repository>
<snapshotRepository>
...
</snapshotRepository>
</distributionManagement>
But Maven will also need to know the user-name and password to use. That can't be in the (public, published) POM, but is instead in a server element in your Maven settings file (~/.m2/settings.xml):
<servers>
<server>
<id>{some ID}</id>
<username>{username}</username>
<password>{password}</password>
<filePermissions>664</filePermissions>
<directoryPermissions>775</directoryPermissions>
<configuration></configuration>
</server>
...
</servers>
Because the settings file can contain credentials for multiple servers, it needs a means of associating your POM repository with the appropriate settings server. It uses the content of the id sub element to identify which server credentials to use with which repository.
Obviously, if you use the wrong id (completely wrong or having a typo) then Maven will not know which credentials to use. However, Maven does not output a warning or error message in this case. It tries (using no credentials?) to do the upload, which of course fails with 401 Unauthorized.
Therefore, if deployment fails with a mysterious 401 Unauthorized, one thing to check is that your repository and server id values are the same.

Cannot create archetype from existing maven project

I'm trying to create an archetype from an existing multi module maven project. For this, I change the directory to the root directory (where the root pom.xml is in) and issue a "mvn archetype:create-from-project". The build doesn't finish and I get the following error:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:2.2:create-from-project (default-cli) on project siaci-d: charsetName -> [Help 1]
Running again with the -e and -X flags I can see the following stack trace:
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:2.2:create-from-project (default-cli) on project siaci-d: charsetName
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:213)
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:84)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
Caused by: org.apache.maven.plugin.MojoFailureException: charsetName
at org.apache.maven.archetype.mojos.CreateArchetypeFromProjectMojo.execute(CreateArchetypeFromProjectMojo.java:285)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
... 19 more
I checked the maven-archetype-plugin documentation and didn't find any reference to a charsetName attribute. So, I'm a bit lost about how to fix this. I'm using maven 3.0.4 with java 1.6.0_25 on a Ubuntu box. Any advice?
Any idea of what is going wrong here?
You posted this question some time ago, however this answer may help others.
I had the same problem in a project. This error happens when you have a file in your project that contains characters in a different encondig. A solution to this problem is replacing this characters — if it's not many, generate the archetype, revert the characters to the original and at last, change to the right enconding at the archetype metadata file.
Another option is to change the default enconding UTF-8 in the archetype generation, like this:
mvn archetype:create-from-project -Darchetype.properties=../archetype.properties
For more information, follow this guides:
http://maven.apache.org/archetype/maven-archetype-plugin/create-from-project-mojo.html#defaultEncoding
http://maven.apache.org/archetype/maven-archetype-plugin/examples/create-with-property-file.html
I was dealing with the same error then I found out what was messing up the archetype creation...
First, I chose the encoding ISO-8859-1 by inserting the properties below on pom.xml:
<properties>
<project.build.sourceEncoding>ISO-8859-1</project.build.sourceEncoding>
<project.reporting.outputEncoding>${project.build.sourceEncoding}</project.reporting.outputEncoding>
<project.resources.sourceEncoding>${project.build.sourceEncoding}</project.resources.sourceEncoding>
</properties>
Afterwards, I inserted the archetype-plugin with all configurations below at the build section of pom.xml:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-archetype-plugin</artifactId>
<version>2.2</version>
<configuration>
<defaultEncoding>${project.build.sourceEncoding}</defaultEncoding>
<encoding>${project.build.sourceEncoding}</encoding>
<archetypeArtifactId>archetype-wsjpa</archetypeArtifactId>
<archetypeGroupId>br.com.example</archetypeGroupId>
<archetypeVersion>1.0</archetypeVersion>
<archetypeFilteredExtentions>java,xml</archetypeFilteredExtentions>
</configuration>
</plugin>
By doing so, you should provide all archetype generation configuration in your own pom.xml instead of writing a property file (archetype.properties) to declare this configuration.
And finally, I ran maven with mvn clean install then mvn archetype:create-from-project -e -X
Even so, you still may notice some encoding errors like the one reported in this post, even if you have updated your pom.xml as shown above... If you're still having the same error after setting the correct encoding for your project, try to figure out which project file still contains invalid characters.
To find the troublemaker file you should observe the debug lines that Maven shows on the console like this one: "[DEBUG] InputFileName:src\main\resources\META-INF\persistence.xml" and check which project files has been written to the folder ${basedir}\target\generated-sources\archetype\src\main\resources\archetype-resources.
When encoding errors occurs during archetype creation, the aforementioned folder doesn't match the original project contents and it happens because Maven couldn't copy some resources due to invalid or incompatible characters which is not contained in the property specified charset.

Resources