You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@xmlbeans.apache.org by Murali Pottlapelli <Mu...@Sun.COM> on 2009/10/20 09:44:04 UTC

SchemaTypeLoader.getSourceAsStream(source); runs into java.lang.NullPointerException

Hi,
I am running into java.lang.NullPointerException in the following 
snippet at getSourceAsStream(source);

        //get SchemaType for element 
        SchemaGlobalElement element = 
typeLoader.findElement(QName.valueOf("{http://xml.netbeans.org/schema/Synchronous}typeA"));
        //confirm element
        System.out.println( 
"{http://xml.netbeans.org/schema/Synchronous}typeA is:" + 
element.getName() );
        System.out.println("\t \t" + "  -- details  ns: " + 
element.getName().getNamespaceURI()
                + "  prefix: " + element.getName().getPrefix() + "  
local name: " + element.getName().getLocalPart());
        SchemaType st = element.getType();

        // get the name of the schema source file
        // Not sure, is it working right?
        //schema source doc queried: 
URI_SHA_1_E8BB73591F25D088F33651C66E86AE1809406E4B/Synchronous.xsd
        //vs original: 
file:/C:/tmp/mvnprojects/schemaParser/target/classes/resources/Synchronous.xsd
        String source = st.getSourceName();
        System.out.println("schema source doc queried: " + source + " vs 
original: " + url);

        SchemaTypeLoader stl = st.getTypeSystem();
        java.io.InputStream is =  stl.getSourceAsStream(source);

I am attaching the Java program and maven project to reproduce the 
issue. Is this an user error? or an issue?

To build and run the test case

   1. unzip attached zip file
   2. move to the root folder
   3. mvn clean assembly:assembly
   4. java -cp
      target\schemaParser-1.0-SNAPSHOT-jar-with-dependencies.jar myTest.App

Regards
Murali