Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
317 views
in Technique[技术] by (71.8m points)

java - JAXB Ant Task Error: xjc2 [ERROR] null unknown location

When binding on some valid XML documents using Ant's xjc2 task, I get the following failure message:

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

The documents are very similar to other files which have bound successfully, all imported schemas exist. Running xjc in verbose mode produced:

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

Anyone have any idea what this means?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Schema Correctness Check

In our use of XJC we have seen a similar problem (see the link below) that was solved by disabling the schema correctness check:

Try the following System property to disable the schema correctness check.

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

For Ant, try:

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

From the following page the -nv parameter relates to the schema correctness check:

Getting into the Code

You could try interacting with XJC programmatically (see below) and plug-in your own EntityResolver to see where the import/include fails:

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();

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...