NoClassDefFoundError - SSLSocketFactory

时间:2016-04-16 00:30:53

标签: java spring junit powermock sslsocketfactory

运行我的junit时遇到此异常。 当我使用verbose运行JUnit时,我看到该类正在从右侧jar加载。 看起来它没有初始化。有原因吗?

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 个答案:

答案 0 :(得分:0)

  

java.lang.NoClassDefFoundError:无法初始化类org.apache.http.conn.ssl.SSLSocketFactory

这意味着它所说的。在某些时候,JVM已尝试初始化该类,但失败了。某处应该有一个异常堆栈跟踪,说明失败的实际原因是什么。这很可能是由于某些类静态初始值设定项中/内部抛出的未经检查的异常所致。没有堆栈跟踪。我们只能猜出真正的原因是什么。