Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8066247
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T11:55:27+00:00 2026-06-05T11:55:27+00:00

I am trying deserialize XML data into newly created Java content trees: I am

  • 0

I am trying deserialize XML data into newly created Java content trees:

I am using SAX, have the Java class under src\main\java\Summaries.java and am trying to simply print the document extracted:

String xmlPath = "C:\\workspace-sts-2.8.0.RELEASE\\RESTClient\\src\\main\\resources\\dailySummary.xml";
String xmlPath2 = "/dailySummary.xml";
String xmlPath3 = "/src/main/resources/dailySummary.xml";

InputStream inputStream = null;
InputSource inputSource = null;
Unmarshaller unmarshaller = null;
JAXBContext jc = null;
try 
{

// read from a file
// or try xmlPath1 or try xmlPath3
inputStream = RESTtestclient.class.getClassLoader().getResourceAsStream(xmlPath2);

inputSource = new InputSource(inputStream);
SAXParserFactory sax = SAXParserFactory.newInstance();
sax.setNamespaceAware(true);
XMLReader reader = sax.newSAXParser().getXMLReader();
SAXSource saxSource= new SAXSource(reader, inputSource);

// use jAXB
Class[] classes = new Class[1];
classes[0]= Summaries.class;
jc = JAXBContext.newInstance(classes);
unmarshaller = jc.createUnmarshaller();

@SuppressWarnings("unchecked")
**JAXBElement<Object> doc = (JAXBElement<Object>) unmarshaller.unmarshal(saxSource);**  // errors out here
sysout(doc);
}

I get an error like this :

javax.xml.bind.UnmarshalException
 - with linked exception:

[org.xml.sax.SAXParseException: File "null" not found.]
     at javax.xml.bind.helpers.AbstractUnmarshallerImpl.createUnmarshalException(AbstractUnmarshallerImpl.java:315)
    at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.createUnmarshalException(UnmarshallerImpl.java:505)
     at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:206)
    at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:173)
     at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:120)
    at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:103)
     at main.java.RESTtestclient.marshallJAXB(RESTtestclient.java:346)
    at main.java.RESTtestclient.main(RESTtestclient.java:82)

Caused by: org.xml.sax.SAXParseException: File "null" not found.
     at org.apache.xerces.framework.XMLParser.reportError(XMLParser.java:1156)
    at org.apache.xerces.readers.DefaultEntityHandler.startReadingFromDocument(DefaultEntityHandler.java:499)
     at org.apache.xerces.framework.XMLParser.parseSomeSetup(XMLParser.java:310)
    at org.apache.xerces.framework.XMLParser.parse(XMLParser.java:1034)
     at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:200)

Any ideas that might point me in the right direction ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T11:55:29+00:00Added an answer on June 5, 2026 at 11:55 am

    You could try the following approach using JAXB’s UnmarshallerHandler:

    package forum10890323;
    
    import java.io.InputStream;
    import javax.xml.bind.*;
    import javax.xml.parsers.*;
    import org.xml.sax.*;
    
    public class Demo {
    
        public static void main(String[] args) throws Exception {
            JAXBContext jc = JAXBContext.newInstance(Root.class);
            UnmarshallerHandler unmarshallerHandler = jc.createUnmarshaller().getUnmarshallerHandler();
    
            SAXParserFactory spf = SAXParserFactory.newInstance();
            SAXParser sp = spf.newSAXParser();
            XMLReader xr = sp.getXMLReader();
            xr.setContentHandler(unmarshallerHandler);
    
            InputStream inputStream = Root.class.getClassLoader().getResourceAsStream("forum10890323/input.xml");
            InputSource inputSource = new InputSource(inputStream);
            xr.parse(inputSource);
            inputStream.close();
    
            Root root = (Root) unmarshallerHandler.getResult();
    
            Marshaller marshaller = jc.createMarshaller();
            marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
            marshaller.marshal(root, System.out);
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm getting an error when trying to deserialize some data into a class. The
I'm trying to deserialize XML into C# objects. When I run my code, no
I'm trying to deserialize an XML sitemap and then load it into a Datagrid
I am trying to serialize/deserialize JSON in Android using GSON. I have two classes
Using DCS I am trying to deserialize objects from XML where the object serialized
suppose i have xml data stored in string variable. so when i am trying
I am trying to read data from an MS Project XML file. I have
I am trying to deserialize the following xml structure into an object... <?xml version=1.0
I'm trying to deserialize an object back from it's XML string using xmlSerializer.Deserialize() but
I am trying to learn deserialization. I have written this code to deserialize *.hbm.xml

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.