Software Development

Best way to configure Maven pom xml to prevent the manifest attribute error in Java JAR packages?

MA Asked by Matthew Taylor · 02-07-2025
0 upvotes 3,874 views 0 comments
The question

I have a project where compiling locally works, but deployment fails on the server. I want to know how to fix the "no main manifest attribute" error when trying to run a Java JAR file that was generated via a CI/CD pipeline. Should I use the assembly plugin or the standard shade plugin?

3 answers

0
KA
Answered on 04-07-2025

When you need to build a fat JAR that contains all dependencies alongside your main class, the Maven Shade Plugin is actually an exceptional choice. It packages all dependency classes directly into a single archive and gives you an explicit configuration block to define your application entry point. By adding the Transformer implementation for the manifest resource inside the plugin configuration, Maven automatically writes the correct entry point attribute. This avoids any path errors on your deployment servers.

0
AN
Answered on 05-07-2025

That makes sense for applications with external dependencies, but what if my project is just core Java code? Won't the shade plugin add unnecessary overhead and bloat the file size during our automated server builds?

DE 06-07-2025

You are completely right, Andrew. For standalone projects, the shade plugin is total overkill. Instead, use the basic maven-jar-plugin. It allows you to specify the main class inside the configuration archive block without bundling external libraries, keeping your final executable file incredibly small and lightweight.

0
SA
Answered on 07-07-2025

If you are using Spring Boot, the framework provides its own specialized build plugin that configures the executable headers automatically during compilation.

MA 08-07-2025

I completely agree, Sandra. The Spring Boot Maven plugin handles the layout properties flawlessly under the hood, making it the fastest possible way to deploy web applications without worrying about manual metadata scripting.

Share your thoughts

Your email address will not be published. Required fields are marked (*)

Professional Counselling Session

Still have questions?
Schedule a free counselling session

Our experts are ready to help you with any questions about courses, admissions, or career paths. Get personalized guidance from industry professionals.

Request a Call Back

Search Online

We Accept

We Accept

Follow Us

"PMI®", "PMBOK®", "PMP®", "CAPM®" and "PMI-ACP®" are registered marks of the Project Management Institute, Inc. | "CSM", "CST" are Registered Trade Marks of The Scrum Alliance, USA. | COBIT® is a trademark of ISACA® registered in the United States and other countries.

Book Free Session