Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/387.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/ant/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java JAXB Ant任务错误:xjc2[Error]空未知位置_Java_Ant_Jaxb_Xjc - Fatal编程技术网

Java JAXB Ant任务错误:xjc2[Error]空未知位置

Java JAXB Ant任务错误:xjc2[Error]空未知位置,java,ant,jaxb,xjc,Java,Ant,Jaxb,Xjc,使用Ant的xjc2任务绑定一些有效的XML文档时,我收到以下失败消息: [xjc2] [ERROR] null [xjc2] unknown location 这些文档与成功绑定的其他文件非常相似,所有导入的模式都存在。在详细模式下运行xjc会产生: Parent is not Defined Class...I cannot get the fields from this class 有人知道这意味着什么吗?模式正确性检查 在使用XJC的过程中,我们看到了一个类似的问题(请参见下面的链

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

[xjc2] [ERROR] null
[xjc2] unknown location
这些文档与成功绑定的其他文件非常相似,所有导入的模式都存在。在详细模式下运行xjc会产生:

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

有人知道这意味着什么吗?

模式正确性检查

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

请尝试以下系统属性以禁用架构正确性检查

-Dcom.sun.tools.xjc.api.impl.s2j.SchemaCompilerImpl.noCorrectnessCheck=true
对于Ant,请尝试:

<xjc target="src">
  <schema dir="src" includes="**/*.xsd" excludes="**/debug.xsd"/>
  <arg value="-nv" />
</xjc>

我尝试将此参数提供给xjc2任务。我将其作为子节点添加到节点(在其他参数旁边)。我收到以下错误:“无法识别的参数-Dcom.sun.tools.xjc.api.impl.s2j.SchemaCompilerImpl.noCorrectnessCheck=true”我已更新了答案。ant任务中的-nv参数似乎与模式正确性检查有关,-nv参数起作用,但错误仍然存在。我还使用了一个外部工具来验证模式,没有问题,所以我认为这不是问题所在。另外,我正在运行任务,而不是(尽管参数仍然有效)。有没有可能出现代理问题?我曾试图通过在我的环境中禁用HTTP代理来重现您的问题,但我得到了一个错误,但它与您的不同,但可能值得一试。我添加了一些关于如何以编程方式访问XJC的详细信息。如果您传入自己的EntityResolver,您可能会更好地处理导致失败的模式。它谈到URI中的散列“#”字符导致“未知位置”错误。
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();