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 8711885
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T04:59:35+00:00 2026-06-13T04:59:35+00:00

I have jaxb objects against an XML schema. That xml schema can have different

  • 0

I have jaxb objects against an XML schema. That xml schema can have different root element. Which is working perfectly fine in the main project. Based on those generated objects, I am trying to write some test cases.

I wrote following code to get JAXBContext

JAXBContext jaxbContext = JAXBContext.newInstance("com.store.web.ws.v1.model");

and i get following exception

com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions
java.lang.StackTraceElement does not have a no-arg default constructor.
    this problem is related to the following location:
        at java.lang.StackTraceElement
        at public java.lang.StackTraceElement[] java.lang.Throwable.getStackTrace()
        at java.lang.Throwable
        at java.lang.Error
        at public java.lang.Error com.store.web.ws.v1.model.ObjectFactory.createError()
        at com.store.web.ws.v1.model.ObjectFactory

    at com.sun.xml.bind.v2.runtime.IllegalAnnotationsException$Builder.check(IllegalAnnotationsException.java:106)
    at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:466)
    at com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:298)
    at com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:141)
    at com.sun.xml.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(JAXBContextImpl.java:1157)
    at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:145)
    at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:236)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:128)
    at javax.xml.bind.ContextFinder.find(ContextFinder.java:277)
    at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:372)
    at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:337)
    at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:244)
    at com.store.web.ws.v1.resource.RequestInfo.main(RequestInfo.java:171)

However, the moment i change my context line to

JAXBContext jaxbContext = JAXBContext.newInstance(BookType.class);

I get following exception SEVERE: unexpected element (uri:"", local:"book"). Expected elements are (none) which is understandable based on my earlier question

Can someone help me here ? I want to create a context based on package name.

  • 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-13T04:59:36+00:00Added an answer on June 13, 2026 at 4:59 am

    That looks like one of the classes generated from your schema is called Error, and the compiler has picked the java.lang.Error class over the com.store.web.ws.v1.model.Error class. Try putting an explicit

    import com.store.web.ws.v1.model.Error;
    

    at the top of ObjectFactory.java and recompiling it, or failing that edit the code to use fully-qualified class names.

    public com.store.web.ws.v1.Error createError() {
      return new com.store.web.ws.v1.Error();
    }
    

    (or change the class name and remap it to the right element name using @XmlRootElement(name="Error"))

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

Sidebar

Related Questions

I hope this isn't too specific. I have created an XML Schema which i
I have a library of JAXB/Entity objects I am using to unmarshall a xml
I have some jaxb objects (instantiated from code generated from xsd by jaxb) that
I have some objects being unmarshalled from an XML file by JAXB. Is it
I have created a Structure for my XML to work with JAXB Unmarshalling The
I have some problem when unmarshaling a .xml at a web service using JAXB.
The scenario: I have a servlet that receives xmls, parses them (using JAXB), persists
I have a JAXB setup where I use a @XmlJavaTypeAdapter to replace objects of
So here's the scenario...I have an XSD file describing all the objects that I
I've inherited a project which uses JAXB heavily to map XML messages onto Java

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.