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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:54:25+00:00 2026-05-26T11:54:25+00:00

I have a Spring MVC 3/J2EE Project. The jsp rendering controllers are working fine,

  • 0

I have a Spring MVC 3/J2EE Project. The jsp rendering controllers are working fine, but the one controller that renders XML for Ajax is not working. I am using JDK 1.6 in RAD 7.5 so JAXB should be on the classpath, and I’ve even tried adding the latest JAXB jars to the lib file to make sure. I still get a 406 error when I make the call. My DOJO call has handleAs: "xml", and I’ve confirmed that application/xml is on the Accept header via FireBug. I have the <mvc:annotation-driven /> line in my spring servlet xml file. I can see the method being invoked and returning without error. I’m not sure what I should try next to debug.

//Country is a class with only primative types which implements Serializable.
public @ResponseBody List<Country> getCountries(){
    return addressService.getCountries();
}

function loadData(){
    console.log("Before get ...");
    dojo.xhrGet({
        url:"http://localhost:9080/sample/shared/getCountries.htm",
        handleAs:"xml",
        load: function(data){
            console.log("In load function ...");
            try {
                for(var i in data){
                   console.log("key", i, "value", data[i]);
                }
            }catch (ex){
                console.error("Failure in load function: " + ex);
            }
            console.log("Exiting load function ...");
        },
        error: function(x){
            console.error("Error in ajax ...");
            console.error(x);
        },
        failOk: false
    });
    console.log("After get ...");
}
  • 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-05-26T11:54:25+00:00Added an answer on May 26, 2026 at 11:54 am

    Try creating the following wrapper class:

    @XmlRootElement
    class Countries {
        private List<Country> countries = new ArrayList<Country>()
    
        //getters/setters
    }
    

    And return it from the controller instead of a raw list:

    public @ResponseBody Countries getCountries()
    

    Most likely your problem is caused by JAXB that is unable to marshal Java list (it does not know how to name the root tag of the XML document). Note that your problem probably does not occur when requesting data in JSON (if Jackson is available on your CLASSPATH).

    See also (similar problems):

    • Spring MVC 3: Returning XML through @ResponseBody
    • issues with xml in spring mvc 3
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a controller (Spring-MVC) that generates a PDF report on a get request.
I have a website that uses JSP as its view technology (and Spring MVC
I'm working on a Spring MVC project, and I have unit tests for all
I have a Spring MVC controller with an action that's called using AJAX. @SessionAttributes({userContext})
I have a Spring MVC Controller class (bean): @Controller @RequestMapping(/index.jsp) public class EjbCaller {
I have a Java/Spring MVC/JSP/JSTL webapp. We have a designer that gave us some
I have a Spring MVC Controller class that needs a property set from a
With spring MVC, do you have to use one of the special form controllers
I currently have a Spring MVC controller that takes a MultipartFile @RequestMapping(method = RequestMethod.POST)
I have a pretty simple JSP/Servlet 3.0/Spring MVC 3.1 application. On one of my

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.