Discussions

XML & Web services: xjc compilation error in JAXB

  1. xjc compilation error in JAXB (4 messages)

    Hi,

    I am getting following error when i am compiling xsd using xjs in JAXB.

    parsing a schema...
    java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
    java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
    sorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:324)
    at org.apache.commons.launcher.ChildMain.run(ChildMain.java:269)
    Caused by: java.lang.NoClassDefFoundError: com/sun/xml/util/XmlChars
    at com.sun.tools.xjc.reader.internalizer.WhitespaceStripper.processPendi
    ngText(WhitespaceStripper.java:91)
    at com.sun.tools.xjc.reader.internalizer.WhitespaceStripper.startElement
    (WhitespaceStripper.java:72)
    at org.xml.sax.helpers.XMLFilterImpl.startElement(Unknown Source)
    at com.sun.tools.xjc.reader.internalizer.VersionChecker.startElement(Ver
    sionChecker.java:54)
    at org.xml.sax.helpers.XMLFilterImpl.startElement(Unknown Source)
    at com.sun.tools.xjc.reader.internalizer.AbstractReferenceFinderImpl.sta
    rtElement(AbstractReferenceFinderImpl.java:49)
    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startEle
    ment(AbstractSAXParser.java:485)
    at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scan
    StartElement(XMLNSDocumentScannerImpl.java:326)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImp
    l$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1563)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImp
    l.scanDocument(XMLDocumentFragmentScannerImpl.java:341)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(X
    ML11Configuration.java:828)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(X
    ML11Configuration.java:758)
    at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.
    java:148)
    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Ab
    stractSAXParser.java:1178)
    at org.xml.sax.helpers.XMLFilterImpl.parse(Unknown Source)
    at org.xml.sax.helpers.XMLFilterImpl.parse(Unknown Source)
    at org.xml.sax.helpers.XMLFilterImpl.parse(Unknown Source)
    at com.sun.tools.xjc.reader.internalizer.DOMForest.parse(DOMForest.java:
    173)
    at com.sun.tools.xjc.reader.internalizer.DOMForest.parse(DOMForest.java:
    125)
    at com.sun.tools.xjc.GrammarLoader.buildDOMForest(GrammarLoader.java:291
    )
    at com.sun.tools.xjc.GrammarLoader.loadXMLSchema(GrammarLoader.java:356)

    at com.sun.tools.xjc.GrammarLoader.load(GrammarLoader.java:127)
    at com.sun.tools.xjc.GrammarLoader.load(GrammarLoader.java:76)
    at com.sun.tools.xjc.Driver.run(Driver.java:181)
    at com.sun.tools.xjc.Driver._main(Driver.java:80)
    at com.sun.tools.xjc.Driver.access$000(Driver.java:46)
    at com.sun.tools.xjc.Driver$1.run(Driver.java:60)

    can anybody tell me what is then problem. Let me tell you i have kept all the jar files in the classpath.

    Thanks in advance

    Regards
    Chintan
  2. Check the error message[ Go to top ]

    java.lang.NoClassDefFoundError: com/sun/xml/util/XmlChars

    There are some jars you need from jaxb/jaxp and common libraries. I presume u are using the java web service developer pack.

    Just including all jars from jaxb alone will not help!
  3. Hi Sowmya,

    I am using latest web service dev. pack (1.5) and i have included all jar files. com/sun/xml/util/XmlChars class resides in xsdlib.jar which I kept in the classpath but still I am facing error.

    In between I have also downloaded new xsdllib.jar file but still same problem

    Regards
    Chintan
  4. Copy jwsdp-shared\lib\xsdlib.jar and jwsdp-shared\lib\relaxngDatatype.jar to jaxp\lib\endorsed directory

    Make sure you use this in your xjc command -Djava.endorsed.dirs=%JAXP_LIB%;%JAXP_LIB%\endorsed
  5. I tried the way you suggested but i m getting
    Caused by: java.lang.IllegalArgumentException

    Can you please guide me what to do ?

    Thanks
    Chintan