Java exercise does not work

Thomas Hesse 10 Reputation points
2025-02-15T17:14:39.1166667+00:00

Exercise https://learn.microsoft.com/en-us/training/modules/host-a-web-app-with-azure-app-service/5-exercise-implement-a-web-application?pivots=java does not work. When I run the command

cd ~

mvn archetype:generate -DgroupId=example.demo -DartifactId=helloworld -DinteractiveMode=false -DarchetypeArtifactId=maven-archetype-webapp -DarchetypeVersion=1.5

I am getting the following error message:

Exception in thread "main" java.lang.NoClassDefFoundError: com/google/common/collect/ImmutableSet

    at com.google.inject.internal.Errors.<clinit>(Errors.java:105)

    at com.google.inject.internal.InternalInjectorCreator.<init>(InternalInjectorCreator.java:61)

    at com.google.inject.Guice.createInjector(Guice.java:87)

    at com.google.inject.Guice.createInjector(Guice.java:69)

    at com.google.inject.Guice.createInjector(Guice.java:59)

    at org.codehaus.plexus.DefaultPlexusContainer.addPlexusInjector(DefaultPlexusContainer.java:481)

    at org.codehaus.plexus.DefaultPlexusContainer.<init>(DefaultPlexusContainer.java:206)

    at org.apache.maven.cli.MavenCli.container(MavenCli.java:651)

    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:286)

    at org.apache.maven.cli.MavenCli.main(MavenCli.java:196)

    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)

    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

It seems Maven is not set up correctly in the cloud shell.

Even

mvn clean install

Gives the same exception.

Best regard,
Thomas

This question is related to the following Learning Module

Azure Azure Training
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.