如何修复“No XMLValidationSchemaFactory实现类指定或可访问”错误?

时间:2013-09-20 10:09:34

标签: java stax

在我的代码中,我有以下代码片段:

import org.codehaus.stax2.validation.XMLValidationSchema;
import org.codehaus.stax2.validation.XMLValidationSchemaFactory;


public class MyClass
{
    [...]

    public void myMethod()
    {
        XMLValidationSchemaFactory sf = XMLValidationSchemaFactory.
          newInstance(XMLValidationSchema.SCHEMA_ID_W3C_SCHEMA);
    }

    [...]
}

当我运行它时,会出现以下错误:

javax.xml.stream.FactoryConfigurationError: No XMLValidationSchemaFactory 
implementation class specified or accessible (via system property 
'org.codehaus.stax2.validation.XMLValidationSchemaFactory.w3c', or 
service definition under 
'META-INF/services/org.codehaus.stax2.validation.XMLValidationSchemaFactory.w3c')
    at org.codehaus.stax2.validation.XMLValidationSchemaFactory.
newInstance(XMLValidationSchemaFactory.java:226)
    at org.codehaus.stax2.validation.XMLValidationSchemaFactory.
newInstance(XMLValidationSchemaFactory.java:116)

我该如何解决?

1 个答案:

答案 0 :(得分:0)

我通过升级到Woodstox 4.2.0解决了这个问题。