CXF—六天系列—第六天—找不到MessageFactoryImpl和BouncyCastleProvider类报错

学习CXF+Spring认证时出现几个错误,缺少MessageFactoryImpl和BouncyCastleProvider类

一、Caused by: java.lang.ClassNotFoundException:org.bouncycastle.jce.provider.BouncyCastleProvider

这个是缺少认证包bcprov-jdk15-143.jar,下载即可

二、错误信息如下:

Caused by: java.lang.ClassNotFoundException: org.apache.axis.soap.MessageFactoryImpl

    at java.net.URLClassLoader$1.run(URLClassLoader.java:200)

    at java.security.AccessController.doPrivileged(Native Method)

    at java.net.URLClassLoader.findClass(URLClassLoader.java:188)

    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)

    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)

    at java.lang.ClassLoader.loadClass(ClassLoader.java:251)

    at javax.xml.soap.MessageFactory.newInstance(MessageFactory.java:50)

    ... 10 more

处理:

原因是调用了axissoap.MessageFactoryImpl,cxf应该用的是sun
     在注册安全拦截器之前执行下面代码就可以了

System.setProperty("javax.xml.soap.MessageFactory", "com.sun.xml.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl");

你可能感兴趣的:(sun)