Hello 修文 葉,
I seem like you're running into a NoClassDefFoundError
for ImmutableSet
while trying to use mvn
in Azure Cloud Shell. Since you mentioned that Maven was working fine before January, and now it's not, it looks like something changed on Azure's side—maybe an update to the default JDK or Maven installation.
Here are a few things you can check:
Check Java and Maven versions
Run these commands to confirm what versions are currently in use:
java -version
mvn -version
If Java is set to 17 but your project is Java 8, that might be the root issue.
Manually Set Java 8 in Cloud Shell
If your project requires Java 8, try switching Java versions:
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
mvn clean install
If you get a "Permission denied" error, Azure Cloud Shell might not allow changing the JDK. In that case, deployment from a local machine is a better option.
Force Java 8 in Maven (pom.xml
)
If you can't change the system JDK, update your pom.xml
to ensure Maven compiles using Java 8:
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
Check for Dependency Issues
Since the error is related to ImmutableSet
, it’s likely a missing or incompatible Guava dependency. Try adding this to pom.xml
:
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>31.1-jre</version>
</dependency>
Then, clean and rebuild:
mvn clean install
If you suspect an outdated version of Guava is being pulled in by another dependency, check with:
mvn dependency:tree
If multiple Guava versions show up, exclude the old one in pom.xml
:
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-webapp-maven-plugin</artifactId>
<version>2.5.0</version>
<exclusions>
<exclusion>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</exclusion>
</exclusions>
</dependency>
Try Deploying from a Local Machine
If Cloud Shell is giving too much trouble, a simpler approach is to package the project locally and deploy it:
mvn clean package
Then, use Azure CLI to deploy:
az webapp up --name <your-app-name> --resource-group <your-resource-group>
Alternatively, you can set up GitHub Actions or Azure DevOps to automate deployment.
Hope it helps!
Please do not forget to click "Accept the answer” and Yes
wherever the information provided helps you, this can be beneficial to other community members.
If you have any other questions or still running into more issues, let me know in the "comments" and I would be happy to help you.