Skip to Content

How to solve the IllegalArgumentException

Dear all,

I am trying develop a java program by following the SAP NetWaver Library.

http://help.sap.com/saphelp_nw04s/helpdata/en/c4/e1343e8c7f6329e10000000a114084/frameset.htm

But it always catches the IllegalArgumentException.Please advise me how to solve this problem.

The developing code:

try {

DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();

docBuilderFactory.setNamespaceAware(true);

docBuilderFactory.setValidating(true);

docBuilderFactory.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaLanguage", "http://www.w3.org/2001/XMLSchema");

docBuilderFactory.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaSource",mySchemaInputStream);

DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();

Document doc = docBuilder.parse(myFileInputStream);

} catch(DOMException domException) {

domException.printStackTrace();

} catch(IllegalArgumentException illegalArgumentException){

illegalArgumentException.printStackTrace();

}

Thanks & Regards,

Red

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

2 Answers

  • Best Answer
    avatar image
    Former Member
    Nov 25, 2008 at 06:14 AM

    Hi Grace,

    Could you check your exception trace and identify where exactly is the exception generated in your code ?

    If it occurs at Document doc = docBuilder.parse(myFileInputStream); line, then the argument myFileInputStream should be one of the following class type File, InputSource, InputSteam or String. If you are using FileInputStrea, then convert it to appropriate class for use.

    Please refer to the following [documentation|http://java.sun.com/j2se/1.4.2/docs/api/javax/xml/parsers/DocumentBuilder.html] for futher help.

    Regards,

    Alka.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Nov 25, 2008 at 09:41 AM

    Hi Grace,

    The value for the http://java.sun.com/xml/jaxp/properties/schemaSource property of the SAX Parser can be of File ot InputSource Class type. From your code snippet it appears to be FileInputStream type.

    Try assigning the value as shown [here|http://www.xml.com/pub/a/2005/07/06/jaxp.html].

    Regards,

    Alka.

    Add comment
    10|10000 characters needed characters exceeded