Skip to main content

xjc throws NPE compililing DTD

3 replies [Last post]
pegster
Offline
Joined: 2011-09-26
Points: 0

Hi

I have downloaded the InvoiceDetail.dtd from the cXML website. When I try and compile using xjc it throws a NullPointerException. I have edited the DTD to make 2 values unique which the compiler complains about initially. This is something I have done before and the DTD usually compiles.

C:\>xjc -dtd c:\temp\InvoiceDetail.dtd
parsing a schema...
compiling a schema...
Exception in thread "main" java.lang.NullPointerException
at com.sun.tools.internal.xjc.generator.bean.field.AbstractField$1TypeList.add(AbstractField
.java:431)
at com.sun.tools.internal.xjc.generator.bean.field.AbstractField$1TypeList.add(AbstractField
.java:443)
at com.sun.tools.internal.xjc.generator.bean.field.AbstractField.getType(AbstractField.java:
447)
at com.sun.tools.internal.xjc.generator.bean.field.AbstractField.(AbstractField.java:1
09)
at com.sun.tools.internal.xjc.generator.bean.field.AbstractListField.(AbstractListFiel
d.java:94)
at com.sun.tools.internal.xjc.generator.bean.field.UntypedListField.(UntypedListField.
java:94)
at com.sun.tools.internal.xjc.generator.bean.field.UntypedListFieldRenderer.generate(Untyped
ListFieldRenderer.java:61)
at com.sun.tools.internal.xjc.generator.bean.field.DefaultFieldRenderer.generate(DefaultFiel
dRenderer.java:68)
at com.sun.tools.internal.xjc.generator.bean.BeanGenerator.generateFieldDecl(BeanGenerator.j
ava:736)
at com.sun.tools.internal.xjc.generator.bean.BeanGenerator.generateClassBody(BeanGenerator.j
ava:524)
at com.sun.tools.internal.xjc.generator.bean.BeanGenerator.(BeanGenerator.java:224)
at com.sun.tools.internal.xjc.generator.bean.BeanGenerator.generate(BeanGenerator.java:164)
at com.sun.tools.internal.xjc.model.Model.generateCode(Model.java:275)
at com.sun.tools.internal.xjc.Driver.run(Driver.java:332)
at com.sun.tools.internal.xjc.Driver.run(Driver.java:180)
at com.sun.tools.internal.xjc.Driver._main(Driver.java:105)
at com.sun.tools.internal.xjc.Driver.access$000(Driver.java:63)
at com.sun.tools.internal.xjc.Driver$1.run(Driver.java:85)

Any help would be appreciated.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
tatacalu
Offline
Joined: 2012-11-23
Points: 0

Hi there,

I am experiencing the same issue. If I try to run the xjc command under Windows [in Cygwin] I get the following error:

$ xjc -dtd my.dtd
parsing a schema...
compiling a schema...
[ERROR] A class/interface with the same name "generated.IpAddr" is already in use. Use a class customization to resolve this conflict.
line 4039 of file:/C:/Work/Payment%20API%20v2/my.dtd

[ERROR] (Relevant to above error) another "Ipaddr" is generated from here.
line 4038 of file:/C:/Work/Payment%20API%20v2/my.dtd

[ERROR] This error is caused because on Windows you cannot have both "Ipaddr.java" and "IpAddr.java" in the same directory.
unknown location

Exception in thread "main" java.lang.NullPointerException
at com.sun.tools.internal.xjc.generator.bean.field.AbstractField$1TypeList.add(AbstractField.java:431)
at com.sun.tools.internal.xjc.generator.bean.field.AbstractField$1TypeList.add(AbstractField.java:443)
at com.sun.tools.internal.xjc.generator.bean.field.AbstractField.getType(AbstractField.java:447)
at com.sun.tools.internal.xjc.generator.bean.field.AbstractField.(AbstractField.java:109)
at com.sun.tools.internal.xjc.generator.bean.field.AbstractListField.(AbstractListField.java:94)
at com.sun.tools.internal.xjc.generator.bean.field.UntypedListField.(UntypedListField.java:94)
at com.sun.tools.internal.xjc.generator.bean.field.UntypedListFieldRenderer.generate(UntypedListFieldRenderer.java:61)
at com.sun.tools.internal.xjc.generator.bean.field.DefaultFieldRenderer.generate(DefaultFieldRenderer.java:68)
at com.sun.tools.internal.xjc.generator.bean.BeanGenerator.generateFieldDecl(BeanGenerator.java:736)
at com.sun.tools.internal.xjc.generator.bean.BeanGenerator.generateClassBody(BeanGenerator.java:524)
at com.sun.tools.internal.xjc.generator.bean.BeanGenerator.(BeanGenerator.java:224)
at com.sun.tools.internal.xjc.generator.bean.BeanGenerator.generate(BeanGenerator.java:164)
at com.sun.tools.internal.xjc.model.Model.generateCode(Model.java:275)
at com.sun.tools.internal.xjc.Driver.run(Driver.java:332)
at com.sun.tools.internal.xjc.Driver.run(Driver.java:180)
at com.sun.tools.internal.xjc.Driver._main(Driver.java:105)
at com.sun.tools.internal.xjc.Driver.access$000(Driver.java:63)
at com.sun.tools.internal.xjc.Driver$1.run(Driver.java:85)

I tried to run the same command on Linux I get the same error but without any details:

$ xjc -dtd my.dtd
parsing a schema...
compiling a schema...
Exception in thread "main" java.lang.NullPointerException
at com.sun.tools.internal.xjc.generator.bean.field.AbstractField$1TypeList.add(AbstractField.java:431)
at com.sun.tools.internal.xjc.generator.bean.field.AbstractField$1TypeList.add(AbstractField.java:443)
at com.sun.tools.internal.xjc.generator.bean.field.AbstractField.getType(AbstractField.java:447)
at com.sun.tools.internal.xjc.generator.bean.field.AbstractField.(AbstractField.java:109)
at com.sun.tools.internal.xjc.generator.bean.field.AbstractListField.(AbstractListField.java:94)
at com.sun.tools.internal.xjc.generator.bean.field.UntypedListField.(UntypedListField.java:94)
at com.sun.tools.internal.xjc.generator.bean.field.UntypedListFieldRenderer.generate(UntypedListFieldRenderer.java:61)
at com.sun.tools.internal.xjc.generator.bean.field.DefaultFieldRenderer.generate(DefaultFieldRenderer.java:68)
at com.sun.tools.internal.xjc.generator.bean.BeanGenerator.generateFieldDecl(BeanGenerator.java:736)
at com.sun.tools.internal.xjc.generator.bean.BeanGenerator.generateClassBody(BeanGenerator.java:524)
at com.sun.tools.internal.xjc.generator.bean.BeanGenerator.(BeanGenerator.java:224)
at com.sun.tools.internal.xjc.generator.bean.BeanGenerator.generate(BeanGenerator.java:164)
at com.sun.tools.internal.xjc.model.Model.generateCode(Model.java:275)
at com.sun.tools.internal.xjc.Driver.run(Driver.java:332)
at com.sun.tools.internal.xjc.Driver.run(Driver.java:180)
at com.sun.tools.internal.xjc.Driver._main(Driver.java:105)
at com.sun.tools.internal.xjc.Driver.access$000(Driver.java:63)
at com.sun.tools.internal.xjc.Driver$1.run(Driver.java:85)

I am using Oracle JDK 6 U 33 on Windows / Oracle JDK 6 U 35 on Linux

Any ideas regarding this issue?

Thanks!

yaroska
Offline
Joined: 2006-05-05
Points: 0

Hi, tatacalu,

Can you please attach you dtd? So I would be able to localize the problem.

Thanks.

--
Iaroslav

tatacalu
Offline
Joined: 2012-11-23
Points: 0

Hi there,

Because of confidentiality issues i cannot attach the DTD but I think the problem is related to similar element definitions like:

ipaddress
ipAddress

My question in this case would be: is it possible provide xjc with a binding file like below ?
http://stackoverflow.com/questions/4793637/jaxb-how-to-change-xjc-genera...

More specifically:

<jxb:bindings node="//xs:complexType[@name='itemType']">
    <jxb:class name="Item"/>
</jxb:bindings>

Is there any way I could instruct xjc to change the name of the generated java class for a DTD element using a syntax similar the the one above ?

Thank you!