When you add a dependency reference to a Java project, it may compile without any errors, but runtime you may get an error message similar to this:
HTTP Status 500 – Internal Server Error
Type Exception Report
Message An exception occurred processing JSP page [/index.jsp] at line [1]
Description The server encountered an unexpected condition that prevented it from fulfilling the request.
Exception
org.apache.jasper.JasperException: An exception occurred processing JSP page [/index.jsp] at line [1]
1: <jsp:forward page=”….html” />
Root Cause
javax.servlet.ServletException: Servlet.init() for servlet [spring] threw exception…
Root Cause
java.lang.NoClassDefFoundError: org/springframework/core/env/PropertySource…
Root Cause
java.lang.ClassNotFoundException: org.springframework.core.env.PropertySource…
If the newly added dependency also depends on another package, and that package is already in the pom.xml file, NetBeans will not show an error during build.
If the newly added dependency was recently introduced, and the version of the package already included in the pom.xml file, references an earlier version, the runtime error will occur.
For example org.springframework.web.bind.annotation.GetMapping was introduced in Spring Web 4.0
If your pom.xml file already contains the reference to spring-web or spring-webmvc version 3, your application will fail runtime.
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>3.0.5.RELEASE</version>
</dependency>
In your web browser navigate to the Maven repository at https://mvnrepository.com/artifact/org.springframework and search for the spring-web and spring-webmvc packages. Get the latest stable version numbers and update your pom.xml file.
<dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>5.0.2.RELEASE</version> </dependency>