运行JUNIT方法时出现java.lang.ExceptionInInitializerError

时间:2015-04-30 10:01:09

标签: junit

我一直使用单一测试方法运行一个简单的Junit测试类。 我遇到了以下错误。

stackTrace如下

java.lang.ExceptionInInitializerError
    at java.lang.J9VMInternals.initialize(J9VMInternals.java:263)
    at com.ibm.ws.webservices.engine.soap.SAAJMetaFactoryImpl.newMessageFactory(SAAJMetaFactoryImpl.java:56)
    at javax.xml.soap.MessageFactory.newInstance(MessageFactory.java:159)
    at com.sun.xml.internal.ws.api.SOAPVersion.<init>(SOAPVersion.java:179)
    at com.sun.xml.internal.ws.api.SOAPVersion.<clinit>(SOAPVersion.java:84)
    at java.lang.J9VMInternals.initializeImpl(Native Method)
    at java.lang.J9VMInternals.initialize(J9VMInternals.java:241)
    at com.sun.xml.internal.ws.api.BindingID.<clinit>(BindingID.java:336)
    at java.lang.J9VMInternals.initializeImpl(Native Method)
    at java.lang.J9VMInternals.initialize(J9VMInternals.java:241)
    at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.parseBinding(RuntimeWSDLParser.java:425)
    at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.parseWSDL(RuntimeWSDLParser.java:322)
    at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.parse(RuntimeWSDLParser.java:147)
    at com.sun.xml.internal.ws.client.WSServiceDelegate.parseWSDL(WSServiceDelegate.java:267)
    at com.sun.xml.internal.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:230)
    at com.sun.xml.internal.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:178)
    at com.sun.xml.internal.ws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:93)
    at javax.xml.ws.Service.<init>(Service.java:57)

任何人都可以帮助我背后的原因

Caused by: org.apache.commons.logging.LogConfigurationException: org.apache.commons.logging.LogConfigurationException: java.lang.UnsupportedOperationException: Operation [getContextClassLoader] is not supported in jcl-over-slf4j. See also http://www.slf4j.org/codes.html#unsupported_operation_in_jcl_over_slf4j (Caused by java.lang.UnsupportedOperationException: Operation [getContextClassLoader] is not supported in jcl-over-slf4j. See also http://www.slf4j.org/codes.html#unsupported_operation_in_jcl_over_slf4j) (Caused by org.apache.commons.logging.LogConfigurationException: java.lang.UnsupportedOperationException: Operation [getContextClassLoader] is not supported in jcl-over-slf4j. See also http://www.slf4j.org/codes.html#unsupported_operation_in_jcl_over_slf4j (Caused by java.lang.UnsupportedOperationException: Operation [getContextClassLoader] is not supported in jcl-over-slf4j. See also http://www.slf4j.org/codes.html#unsupported_operation_in_jcl_over_slf4j))
    at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:532)
    at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:272)
    at com.ibm.ws.webservices.engine.components.logger.LogFactory$1.run(LogFactory.java:119)
    at com.ibm.ws.security.util.AccessController.doPrivileged(AccessController.java:118)
    at com.ibm.ws.webservices.engine.components.logger.LogFactory.getLog(LogFactory.java:111)
    at com.ibm.ws.webservices.engine.soap.MessageFactoryImpl.<clinit>(MessageFactoryImpl.java:103)
    at java.lang.J9VMInternals.initializeImpl(Native Method)
    at java.lang.J9VMInternals.initialize(J9VMInternals.java:241)
    ... 41 more
Caused by: org.apache.commons.logging.LogConfigurationException: java.lang.UnsupportedOperationException: Operation [getContextClassLoader] is not supported in jcl-over-slf4j. See also http://www.slf4j.org/codes.html#unsupported_operation_in_jcl_over_slf4j (Caused by java.lang.UnsupportedOperationException: Operation [getContextClassLoader] is not supported in jcl-over-slf4j. See also http://www.slf4j.org/codes.html#unsupported_operation_in_jcl_over_slf4j)
    at org.apache.commons.logging.impl.LogFactoryImpl.getLogConstructor(LogFactoryImpl.java:416)
    at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:525)
    ... 48 more
Caused by: java.lang.UnsupportedOperationException: Operation [getContextClassLoader] is not supported in jcl-over-slf4j. See also http://www.slf4j.org/codes.html#unsupported_operation_in_jcl_over_slf4j
    at org.apache.commons.logging.LogFactory.getContextClassLoader(LogFactory.java:366)
    at org.apache.commons.logging.impl.LogFactoryImpl.access$000(LogFactoryImpl.java:113)
    at org.apache.commons.logging.impl.LogFactoryImpl$1.run(LogFactoryImpl.java:457)
    at java.security.AccessController.doPrivileged(AccessController.java:229)
    at org.apache.commons.logging.impl.LogFactoryImpl.loadClass(LogFactoryImpl.java:454)
    at org.apache.commons.logging.impl.LogFactoryImpl.getLogConstructor(LogFactoryImpl.java:406)
    ... 49 more

1 个答案:

答案 0 :(得分:2)

我没有必要将任何jar文件添加到CLASSPATH中。我通过添加以下系统属性解决了它:

-Dorg.apache.commons.logging.LogFactory = org.apache.commons.logging.impl.SLF4JLogFactory

是否必须通过JUNit运行Web服务?