0
votes

While running my junit getting this exception. When I run JUnit using verbose I see the class is getting loaded from th right jar. Looks like its not getting initialized. Is there a reason why?

org.springframework.web.util.NestedServletException: Handler processing failed; nested exception is java.lang.NoClassDefFoundError: Could not initialize class org.apache.http.conn.ssl.SSLSocketFactory
    at org.springframework.web.servlet.DispatcherServlet.triggerAfterCompletionWithError(DispatcherServlet.java:1302)
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:977)
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893)
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:968)
    at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:859)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:575)
    at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:844)
    at org.springframework.test.web.servlet.TestDispatcherServlet.service(TestDispatcherServlet.java:65)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:668)
    at org.springframework.mock.web.MockFilterChain$ServletFilterProxy.doFilter(MockFilterChain.java:167)
    at org.springframework.mock.web.MockFilterChain.doFilter(MockFilterChain.java:134)
    at org.springframework.test.web.servlet.MockMvc.perform(MockMvc.java:155)
1
Is this really the first error? Usually this happens if before there was some error in the static initializer of the class. - Vampire

1 Answers

0
votes

java.lang.NoClassDefFoundError: Could not initialize class org.apache.http.conn.ssl.SSLSocketFactory

This means what it says. At some point, the JVM has attempted to initialize that class, and that has failed. Somewhere there should be an exception stacktrace that says what the actual cause of the failure was. It is most likely due to an unchecked exception thrown by / within in some classes static initializers. Without the stacktrace. we can only guess what the real cause is.