JAXB Ant任务错误:xjc2 null未知位置

使用Ant的xjc2任务绑定一些有效的XML文档时,我收到以下失败消息:

[xjc2] [ERROR] null [xjc2] unknown location 

这些文档与已成功绑定的其他文件非常相似,所有导入的模式都存在。 生成以详细模式运行xjc:

 Parent is not Defined Class...I cannot get the fields from this class 

任何人都知道这意味着什么?

架构正确性检查

在我们使用XJC时,我们看到了一个类似的问题(参见下面的链接),它通过禁用模式正确性检查来解决:

请尝试以下System属性以禁用架构正确性检查。

 -Dcom.sun.tools.xjc.api.impl.s2j.SchemaCompilerImpl.noCorrectnessCheck=true 

对于Ant,请尝试:

     

在以下页面中,-nv参数与架构正确性检查有关:

进入守则

您可以尝试以编程方式与XJC交互(请参阅下文)并插入您自己的EntityResolver以查看导入/包含失败的位置:

 import com.sun.codemodel.*; import com.sun.tools.xjc.*; import com.sun.tools.xjc.api.*; SchemaCompiler sc = XJC.createSchemaCompiler(); sc.setEntityResolver(new YourEntityResolver()); sc.setErrorListener(new YourErrorListener()); sc.parseSchema(SYSTEM_ID, element); S2JJAXBModel model = sc.bind();