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

  • Home
  • SEARCH
  • 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 9108363
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T02:47:28+00:00 2026-06-17T02:47:28+00:00

My JAXB parser suddenly stopped working today. It was working for several weeks. I

  • 0

My JAXB parser suddenly stopped working today. It was working for several weeks. I get the following message. I haven’t changed this code for several weeks. Wondering if this set up is good.


EDIT 2: Please could somebody help me! I can’t figure this out.



EDIT 1:
My acceptance tests running the same code below are working fine. I believe this is a
classloading issue. I am using the JAXB and StAX in the JDK. However, when I deploy to jboss 5.1, I get the error below. Using 1.6.0_26 (locally) and 1.6.0_30 (dev server). Still puzzling over a solution.


unexpected element (uri:””, local:”lineEquipmentRecord”). Expected
elements are
<{}switchType>,<{}leSwitchId>,<{}nodeAddress>,<{}leId>,<{}telephoneSuffix>,<{}leFormatCode>,<{}groupIdentifier>,<{}telephoneNpa>,<{}telephoneLine>,<{}telephoneNxx>

Here is my unmarshalling class:

import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.NoSuchElementException;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;
import javax.xml.bind.ValidationEvent;
import javax.xml.bind.ValidationEventHandler;
import javax.xml.stream.FactoryConfigurationError;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamConstants;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;


public class PartialUnmarshaller<T> {
    XMLStreamReader reader;
    Class<T> clazz;
    Unmarshaller unmarshaller;

    public PartialUnmarshaller(InputStream stream, Class<T> clazz) throws XMLStreamException, FactoryConfigurationError, JAXBException {
        this.clazz = clazz;
        this.unmarshaller = JAXBContext.newInstance(clazz).createUnmarshaller();
        unmarshaller.setEventHandler(new ValidationEventHandler() {

            @Override
            public boolean handleEvent(ValidationEvent event) {
                System.out.println(event.getMessage());
                return true;
            }
        });
        this.reader = XMLInputFactory.newInstance().createXMLStreamReader(stream);

        /* ignore headers */
        skipElements(XMLStreamConstants.START_DOCUMENT);
        /* ignore root element */
        reader.nextTag();
        /* if there's no tag, ignore root element's end */
        skipElements(XMLStreamConstants.END_ELEMENT);
    }

    public T next() throws XMLStreamException, JAXBException {
        if (!hasNext())
            throw new NoSuchElementException();

        T value = unmarshaller.unmarshal(reader, clazz).getValue();

        skipElements(XMLStreamConstants.CHARACTERS, XMLStreamConstants.END_ELEMENT);
        return value;
    }

    public boolean hasNext() throws XMLStreamException {
        return reader.hasNext();
    }

    public void close() throws XMLStreamException {
        reader.close();
    }

    private void skipElements(Integer... elements) throws XMLStreamException {
        int eventType = reader.getEventType();

        List<Integer> types = new ArrayList<Integer>(Arrays.asList(elements));
        while (types.contains(eventType))
            eventType = reader.next();
    }
}

This class is used as follows:

List<MyClass> lenList = new ArrayList<MyClass>();
PartialUnmarshaller<MyClass> pu = new PartialUnmarshaller<MyClass>(
        is, MyClass.class);
while (pu.hasNext()) {
    lenList.add(pu.next());
}

The XML being unmarshalled:

<?xml version="1.0" encoding="UTF-8"?>
<lineEquipment>
    <lineEquipmentRecord>
        <telephoneNpa>333</telephoneNpa>
        <telephoneNxx>333</telephoneNxx>
        <telephoneLine>4444</telephoneLine>
        <telephoneSuffix>1</telephoneSuffix>
        <nodeAddress>xxxx</nodeAddress>
        <groupIdentifier>LEN</groupIdentifier>
    </lineEquipmentRecord>
    <lineEquipmentRecord>
        <telephoneNpa>111</telephoneNpa>
        <telephoneNxx>111</telephoneNxx>
        <telephoneLine>2222</telephoneLine>
        <telephoneSuffix>0</telephoneSuffix>
        <nodeAddress>xxxx</nodeAddress>
        <groupIdentifier>LEN</groupIdentifier>
    </lineEquipmentRecord>
</lineEquipment>

Finally, here is MyClass:

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

/**
 * This class is used as an envelope to hold Martens
 * line equipment information.
 * @author spgezf
 *
 */
@XmlRootElement(name="lineEquipmentRecord")
public class MyClass {

    private String telephoneNpa;
    private String telephoneNxx;
    private String telephoneLine;

    private String telephoneSuffix;
    private String nodeAddress;
    private String groupIdentifier;

    public MyClass(){       
    }


    // Getters and Setters.

    @XmlElement(name="telephoneNpa")
    public String getTelephoneNpa() {
        return telephoneNpa;
    }

    public void setTelephoneNpa(String telephoneNpa) {
        this.telephoneNpa = telephoneNpa;
    }
    @XmlElement(name="telephoneNxx")
    public String getTelephoneNxx() {
        return telephoneNxx;
    }

    public void setTelephoneNxx(String telephoneNxx) {
        this.telephoneNxx = telephoneNxx;
    }
    @XmlElement(name="telephoneLine")
    public String getTelephoneLine() {
        return telephoneLine;
    }

    public void setTelephoneLine(String telephoneLine) {
        this.telephoneLine = telephoneLine;
    }


    @XmlElement(name="telephoneSuffix")
    public String getTelephoneSuffix() {
        return telephoneSuffix;
    }

    public void setTelephoneSuffix(String telephoneSuffix) {
        this.telephoneSuffix = telephoneSuffix;
    }

    @XmlElement(name="nodeAddress")
    public String getNodeAddress() {
        return nodeAddress;
    }

    public void setNodeAddress(String nodeAddress) {
        this.nodeAddress = nodeAddress;
    }

    @XmlElement(name="groupIdentifier")
    public String getGroupIdentifier() {
        return groupIdentifier;
    }

    public void setGroupIdentifier(String groupIdentifier) {
        this.groupIdentifier = groupIdentifier;
    }


}
  • 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-17T02:47:30+00:00Added an answer on June 17, 2026 at 2:47 am

    Thanks, this is classloading issue I couldn’t overcome so I abandoned JAXB.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

It seems JAXB can't read what it writes. Consider the following code: interface IFoo
This block of code essentially takes a JAXB Object and turns it into a
Possible Duplicate: Best XML Parser for PHP Using JAXB with Google Android I need
Here is my JAXB class, @XmlRootElement public class Status { private int code; private
How can I get jaxb to bind to my Vector? I cannot seem to
I cannot get JAXB to unmarshal a timestamp in a Resteasy JAX-RS server application.
I am trying to use JAXB to parse the following XML . I removed
This is the first time I've ever tried to use JAXB for anything at
I have always been using jaxb for parsing XML files into java object. This
JAXB can't parse the bindings for this example: <xs:element name=classA type=classA substitutionGroup=classSubA/> <xs:complexType name=complexClassA

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.