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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:57:57+00:00 2026-05-27T04:57:57+00:00

I’m trying to parse the result from a RESTFull call using RestTemplate following this

  • 0

I’m trying to parse the result from a RESTFull call using RestTemplate following this sample http://thekspace.com/home/component/content/article/57-restful-clients-in-spring-3.html

The XML Response is something like that:

<brands>
    <brand>
        <nodeRef>1111111</nodeRef>
        <name>Test</name>
    </brand>
</brands>

For first, I configured my application-context.xml like that:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
                           http://www.springframework.org/schema/beans/spring-beans.xsd">

    <bean id="restTemplate" class="org.springframework.web.client.RestTemplate">
        <property name="messageConverters">
            <list>
                <bean id="messageConverter" class="org.springframework.http.converter.xml.MarshallingHttpMessageConverter">
                    <property name="marshaller" ref="xstreamMarshaller" />
                    <property name="unmarshaller" ref="xstreamMarshaller" />
                </bean>
            </list>
        </property>
    </bean>

    <bean id="xstreamMarshaller" class="org.springframework.oxm.xstream.XStreamMarshaller">
        <property name="aliases">
            <props>
                <prop key="brand">com.kipcast.dataModel.drugs.bean.BrandViewList</prop>
            </props>
        </property>
    </bean>


</beans>

The class com.kipcast.dataModel.drugs.bean.BrandViewList is a bean with an @XStreamAlias(“brand”) defined.

Here how I do the rest call:

ApplicationContext applicationContext = new ClassPathXmlApplicationContext("application-context.xml", WebscriptCaller.class); 
RestTemplate restTemplate = applicationContext.getBean("restTemplate", RestTemplate.class);     

String url = "http://localhost:8081/alfresco/service/search/brand.xml?q={keyword}&alf_ticket={ticket}"; 
List<BrandViewList> results = (List<BrandViewList>) restTemplate.getForObject(url, List.class, params);

WebscriptCaller.class is the class from which I execute these instructions.

When I try to execute that, the getForObject() fails and I get that exception:

XStream unmarshalling exception; nested exception is com.thoughtworks.xstream.mapper.CannotResolveClassException: brands

My question is, how can I fix that? Why I get this kind of Exception? How can I tell him to skip root tag?

————– UPDATED ————–
fixed some issue and in particular:

List<Brand> brandViewList = (List<Brand>) restTemplate.getForObject(url, Brand.class, params);

but the result now is:

org.springframework.http.converter.HttpMessageNotReadableException: Could not read [class com.kipcast.dataModel.drugs.bean.Brand]; nested exception is org.springframework.oxm.UnmarshallingFailureException: XStream unmarshalling exception; nested exception is com.thoughtworks.xstream.converters.ConversionException: nodeRef : nodeRef
---- Debugging information ----
message             : nodeRef
cause-exception     : com.thoughtworks.xstream.mapper.CannotResolveClassException
cause-message       : nodeRef
class               : java.util.ArrayList
required-type       : java.util.ArrayList
converter-type      : com.thoughtworks.xstream.converters.collections.CollectionConverter
path                : /brands/brand/nodeRef
line number         : 3
class[1]            : com.kipcast.dataModel.drugs.bean.Brands
converter-type[1]   : com.thoughtworks.xstream.converters.reflection.ReflectionConverter
version             : null
-------------------------------
  • 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-27T04:57:58+00:00Added an answer on May 27, 2026 at 4:57 am

    EDIT: updated to contain only pertaining information

    It’s best if you have distinct classes handling “brands” and “brand” tags. I would create a Brand class, rename BrandList to Brands (to be closer to the XML parts they refer to), and let Brands hold a List<Brand>. Put the proper annotations to both classes and you should be done, e.g.:

    @XStreamAlias("brands")
    class Brands {
      @XStreamImplicit
      List<Brand> brand;
    }
    
    @XStreamAlias("brand")
    class Brand {
      String nodeRef;
      String name;
    }
    

    The above code works perfectly when marshalling objects to XML, but fails as you describe when unmarshalling from XML to objects. For that to work fine, you need to tell the marshaller which annotated classes you have:

    <bean name="marshaller" class="org.springframework.oxm.xstream.XStreamMarshaller">
        <property name="autodetectAnnotations" value="true"/>
        <property name="annotatedClasses">
            <array>
                <value>com.kipcast.dataModel.drugs.bean.BrandViewList</value>
                <value>com.kipcast.dataModel.drugs.bean.BrandView</value>
            </array>
        </property>
    </bean>
    

    I created a sample project where I verify the setup.

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

Sidebar

Related Questions

I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
For some reason, after submitting a string like this Jack’s Spindle from a text
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
Does anyone know how can I replace this 2 symbol below from the string
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i

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.