java.lang.NoClassDefFoundError: javax/servlet/jsp/jstl/core/Config

I created a Maven (maven-archetype-webapp) application and applied mvn eclipse:eclipse on it to make it compatible with Eclipse. When I ran the project I hit this exception:

java.lang.NoClassDefFoundError: javax/servlet/jsp/jstl/core/Config

This was strange because I had mentioned jstl-1.2 in my pom.xml. A quick search on Google returned a lot of answers to this problem, but none of them worked for me. Then I found the root cause of the problem myself and eventually fixed it.

Problem

A look into Web Deployment Assembly of my project revealed that Maven dependencies weren’t being added into my project’s classpath. To view Web Deployment Assembly of a project:

  • Right-click project name from Project Explorer on left hand side and click Properties.
  • Click Deployment Assembly from left hand side.

Here’s how my Deployment Assembly looked like:

Web Deployment Assembly

For some reason it was only including a subset of dependencies that I defined in pom.xml and that subset didn’t include the jstl-1.2.jar.

Solution

I added a new directive Maven Dependencies to the list and provided /WEB-INF/lib as it’s Deploy Path. To add Maven Dependencies directive:

  • In Web Deployment Assembly panel, click Add.
  • Select Java Build Path Entries and click Next.
  • Select Maven Dependencies and click Finish.
  • In Web Deployment Assembly panel, click Apply and then Ok.

This solved the problem for me. And of course I removed the jars which were being explicitly specified in the Deployment Assembly since they became redundant. My Web Deployment Assembly looked like this at the end:

Web Deployment Assembly

Published by

Umar Ashfaq

Umar Ashfaq is a full-stack web developer. His core strength is building neat UIs with JavaScript on web but he also enjoys server side Java, NodeJS and Objective C. Follow him on twitter @umarashfaq87

Leave a Reply

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