I'm running the following command to try to generate a lambda maven project. mvn "archetype:generate" "-DarchetypeGroupId=software.amazon.awssdk" "-DarchetypeArtifactId=archetype-lambda" "-DarchetypeVersion=2.11.4" "-DgroupId=com.amazon.test" "-DartifactId=test-project" "-Dservice=s3" "-Dregion=us-west-2" "-DinteractiveMode=false" -e
I think it should create the maven project successfully. Was following this page
I got this error output:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:3.2.0:generate (default-cli) on project standalone-pom: Error merging velocity templates: Unable to find resource 'archetype-resources/global.vm' -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:3.2.0:generate (default-cli) on project standalone-pom: Error merging velocity templates: Unable to find resource 'archetype-resources/global.vm'
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
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 jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:567)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: org.apache.maven.plugin.MojoFailureException: Error merging velocity templates: Unable to find resource 'archetype-resources/global.vm'
at org.apache.maven.archetype.mojos.CreateProjectFromArchetypeMojo.execute (CreateProjectFromArchetypeMojo.java:208)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
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 jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:567)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
[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/MojoFailureException
Run mvn "archetype:generate" "-DarchetypeGroupId=software.amazon.awssdk" "-DarchetypeArtifactId=archetype-lambda" "-DarchetypeVersion=2.11.4" "-DgroupId=com.michael.test" "-DartifactId=test-project" "-Dservice=s3" "-Dregion=us-west-2" "-DinteractiveMode=false" -e in an empty directory
I'd like to use this archetype to generate lambda templates.
mvn --version
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: C:\Program Files\apache-maven-3.6.3\bin\..
Java version: 12, vendor: Oracle Corporation, runtime: C:\Program Files\jdk-12
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"
Hi @michaelgman13 , I was not able to reproduce the issue. I found this answer on stackoverflow and thought it could be related https://stackoverflow.com/a/26758522
Could you check if you have write permission of the directory?
@michaelgman13 were you able to try @zoewangg 's suggestion?
@debora-ito , @zoewangg - I am facing the same issue. The exact same error logs mentioned above with -e flag. I have permission to read and write in the folder, I am running command prompt in admin mode so permissions should not be a problem here.
Hi @nchauhan5, did you also run the command on windows?
@zoewangg Yes
Facing this problem as well. I can confirm this is not a filesystem read/write access issue by generating with a different archetype.
mkdir -p /tmp/foo && cd /tmp/foo
# Fine
touch ok
# Fine
mvn archetype:generate -B \
-DarchetypeGroupId=org.apache.maven.archetypes \
-DarchetypeArtifactId=maven-archetype-quickstart \
-DarchetypeVersion=1.1 \
-DgroupId=com.company \
-DartifactId=project \
-Dversion=1.0-SNAPSHOT \
mkdir -p /tmp/bar && cd /tmp/bar
# Fine
touch sure
# Failure
mvn archetype:generate \
-DarchetypeGroupId=software.amazon.awssdk \
-DarchetypeArtifactId=archetype-lambda \
-DarchetypeVersion=2.14.3 \
-DgroupId=com.test \
-DartifactId=sample-project \
-Dversion=1.0-SNAPSHOT \
-Dservice=s3 \
-Dregion=us-west-1 \
-DinteractiveMode=true \
--errors
Two lines that look relevant from the output
[ERROR] ResourceManager : unable to find resource 'archetype-resources/global.vm' in any resource loader.
[ERROR] #parse(): cannot find template 'archetype-resources/global.vm', called at archetype-resources/pom.xml[line 1, column 1]
What is archetype-resources/global.vm and is it being removed prematurely?
Full output from failed command shown below
mvn archetype:generate \
-DarchetypeGroupId=software.amazon.awssdk \
-DarchetypeArtifactId=archetype-lambda \
-DarchetypeVersion=2.14.3 \
-DgroupId=com.test \
-DartifactId=sample-project \
-Dversion=1.0-SNAPSHOT \
-Dservice=s3 \
-Dregion=us-west-1 \
-DinteractiveMode=true \
--errors
[INFO] Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------< org.apache.maven:standalone-pom >-------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] --------------------------------[ pom ]---------------------------------
[INFO]
[INFO] >>> maven-archetype-plugin:3.2.0:generate (default-cli) > generate-sources @ standalone-pom >>>
[INFO]
[INFO] <<< maven-archetype-plugin:3.2.0:generate (default-cli) < generate-sources @ standalone-pom <<<
[INFO]
[INFO]
[INFO] --- maven-archetype-plugin:3.2.0:generate (default-cli) @ standalone-pom ---
[INFO] Generating project in Interactive mode
[INFO] Archetype repository not defined. Using the one from [software.amazon.awssdk:archetype-lambda:2.13.76] found in catalog remote
[INFO] Using property: groupId = com.test
[INFO] Using property: artifactId = sample-project
[INFO] Using property: version = 1.0-SNAPSHOT
[INFO] Using property: package = com.test
[INFO] Using property: handlerClassName = App
[INFO] Using property: httpClient = url-connection-client
[INFO] Using property: javaSdkVersion = 2.14.3
[INFO] Using property: nettyOpenSslVersion = 2.0.29.Final
[INFO] Using property: region = us-west-1
[INFO] Using property: service = s3
Confirm properties configuration:
groupId: com.test
artifactId: sample-project
version: 1.0-SNAPSHOT
package: com.test
handlerClassName: App
httpClient: url-connection-client
javaSdkVersion: 2.14.3
nettyOpenSslVersion: 2.0.29.Final
region: us-west-1
service: s3
Y: :
[INFO] ----------------------------------------------------------------------------
[INFO] Using following parameters for creating project from Archetype: archetype-lambda:2.14.3
[INFO] ----------------------------------------------------------------------------
[INFO] Parameter: groupId, Value: com.test
[INFO] Parameter: artifactId, Value: sample-project
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] Parameter: package, Value: com.test
[INFO] Parameter: packageInPathFormat, Value: com/test
[INFO] Parameter: httpClient, Value: url-connection-client
[INFO] Parameter: package, Value: com.test
[INFO] Parameter: handlerClassName, Value: App
[INFO] Parameter: service, Value: s3
[INFO] Parameter: groupId, Value: com.test
[INFO] Parameter: artifactId, Value: sample-project
[INFO] Parameter: javaSdkVersion, Value: 2.14.3
[INFO] Parameter: nettyOpenSslVersion, Value: 2.0.29.Final
[INFO] Parameter: region, Value: us-west-1
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[ERROR] ResourceManager : unable to find resource 'archetype-resources/global.vm' in any resource loader.
[ERROR] #parse(): cannot find template 'archetype-resources/global.vm', called at archetype-resources/pom.xml[line 1, column 1]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.831 s
[INFO] Finished at: 2020-08-22T12:17:49-07:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:3.2.0:generate (default-cli) on project standalone-pom: Error merging velocity templates: Unable to find resource 'archetype-resources/global.vm' -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:3.2.0:generate (default-cli) on project standalone-pom: Error merging velocity templates: Unable to find resource 'archetype-resources/global.vm'
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
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 jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:564)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: org.apache.maven.plugin.MojoFailureException: Error merging velocity templates: Unable to find resource 'archetype-resources/global.vm'
at org.apache.maven.archetype.mojos.CreateProjectFromArchetypeMojo.execute (CreateProjectFromArchetypeMojo.java:208)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
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 jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:564)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
[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/MojoFailureException
Reproducing using amazoncorretto:8u265-al2 docker image:
docker run -it amazoncorretto:8u265-al2 /bin/bash
yum install -y maven
cd /tmp
mvn archetype:generate \
-DarchetypeGroupId=software.amazon.awssdk \
-DarchetypeArtifactId=archetype-lambda \
-DarchetypeVersion=2.14.3 \
-DgroupId=com.test \
-DartifactId=sample-project \
-Dservice=s3 \
-Dregion=US_WEST_2 \
-DinteractiveMode=false
[INFO] ----------------------------------------------------------------------------
[INFO] Using following parameters for creating project from Archetype: archetype-lambda:2.14.3
[INFO] ----------------------------------------------------------------------------
[INFO] Parameter: groupId, Value: com.test
[INFO] Parameter: artifactId, Value: sample-project
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] Parameter: package, Value: com.test
[INFO] Parameter: packageInPathFormat, Value: com/test
[INFO] Parameter: httpClient, Value: url-connection-client
[INFO] Parameter: handlerClassName, Value: App
[INFO] Parameter: groupId, Value: com.test
[INFO] Parameter: service, Value: s3
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] Parameter: nettyOpenSslVersion, Value: 2.0.29.Final
[INFO] Parameter: javaSdkVersion, Value: 2.14.3
[INFO] Parameter: region, Value: US_WEST_2
[INFO] Parameter: package, Value: com.test
[INFO] Parameter: artifactId, Value: sample-project
[ERROR] ResourceManager : unable to find resource 'archetype-resources/global.vm' in any resource loader.
[ERROR] #parse(): cannot find template 'archetype-resources/global.vm', called at archetype-resources/pom.xml[line 1, column 1]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 9.323s
[INFO] Finished at: Sat Aug 22 19:47:25 UTC 2020
[INFO] Final Memory: 15M/165M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:3.2.0:generate (default-cli) on project standalone-pom: Error merging velocity templates: Unable to find resource 'archetype-resources/global.vm' -> [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/MojoFailureException
@jason-riddle Thank you for providing detailed steps to reproduce the issue. I'm able to reproduce it using the docker image. We will look into the issue
I think I found out the root cause. It seems the new release of maven-archetype-plugin 3.2.0 broke it. I was running older version of maven-archetype-plugin on my local machine and that's why I couldn't reproduce it there.
In 3.2.0, the default ResourceLoader is ClasspathResourceLoader
[DEBUG] Default Properties File: org/apache/velocity/runtime/defaults/velocity.properties
[DEBUG] Default ResourceManager initializing. (class org.apache.velocity.runtime.resource.ResourceManagerImpl)
[DEBUG] ResourceLoader instantiated: org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
In 3.0.1, it is ContextClassLoaderResourceLoader
[DEBUG] Default ResourceManager initializing. (class org.apache.velocity.runtime.resource.ResourceManagerImpl)
[DEBUG] ResourceLoader instantiated: org.codehaus.plexus.velocity.ContextClassLoaderResourceLoader
[DEBUG] ResourceLoader instantiated: org.codehaus.plexus.velocity.SiteResourceLoader
We will need to investigate how to fix it.
As a workaround, you can use the following command to enforce the use of older version of the archetype plugin
mvn org.apache.maven.plugins:maven-archetype-plugin:3.1.0:generate \
-DarchetypeGroupId=software.amazon.awssdk \
-DarchetypeArtifactId=archetype-lambda \
-DarchetypeVersion=2.14.3 \
-DgroupId=com.test \
-DartifactId=sample-project \
-Dservice=s3 \
-Dregion=US_WEST_2 \
-DinteractiveMode=false
@zoewangg, what will be the command be, if instead of "archetype-lambda" archetypeArtifactId, I want to create a project with AWS Rekognition service as parts of the pom.xml
@nchauhan5 You mean an archetype for a general application rather than Lambda function? We don't have one yet. Could you create a feature request? We will prioritize it if more people +1 on it.
If you mean Lambda function, you can use the same command and change the service part to -Dservice=rekognition. You can find all available services here: https://github.com/aws/aws-sdk-java-v2/tree/master/services
happening here as well, using windows 10. note that this example is https://docs.aws.amazon.com/sdk-for-java/v2/developer-guide/setup-project-maven.html#create-maven-project
Hi @fjleon1980, we are aware of this issue. Could you try with the workaround?
mvn org.apache.maven.plugins:maven-archetype-plugin:3.1.0:generate \
-DarchetypeGroupId=software.amazon.awssdk \
-DarchetypeArtifactId=archetype-lambda \
-DarchetypeVersion=2.14.3 \
-DgroupId=com.test \
-DartifactId=sample-project \
-Dservice=s3 \
-Dregion=US_WEST_2 \
-DinteractiveMode=false
Hi @zoewangg, I was with the same problem and the workaround worked!
Fixed via #2085 and released as part of 2.15.8
With the latest version, now you don't need to specify the maven-archetype-plugin version any more.
mvn archetype:generate \
-DarchetypeGroupId=software.amazon.awssdk \
-DarchetypeArtifactId=archetype-lambda \
-DarchetypeVersion=2.15.8 \
-DgroupId=com.amazon.test \
-DartifactId=test-project \
-Dservice=s3 \
-Dregion=us-west-2 \
-DinteractiveMode=false
This blog post should be updated to stop other folks trying to find the solution for this bug
Most helpful comment
Hi @fjleon1980, we are aware of this issue. Could you try with the workaround?