Vandy Gov

Greenhorn
+ Follow
since Aug 20, 2015
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Vandy Gov

Hi All,

If any one can help me resolve this issue , would really appreciate it.

I am not sure why my spring controller doesn't pick up the @XmlRootElement name and @XmlElement name of the domain objects.

my controller request mapping syntax

package com.chat.controller;


import java.io.File;


@RequestMapping("/chatlive")
@Controller
public class GetChatUserDetails {

private static final Logger logger = LoggerFactory.getLogger("APPDEBUG.com.chat.controller.GetChatUserDetails");
@Autowired
private IGetChatUserDetailService iGetChatUserDetailService;

@Autowired
@Qualifier("messageSource")
private MessageSource messageSource;

@RequestMapping(value="/getChatUserDetails")
public ChatUserDetail getUserDetails(ModelMap model,@RequestParam("userId") String userId,@RequestParam("ipaddr") String ipAddr) throws Exception
{
ChatUserDetail chatUserDetail =null;
try{
logger.debug("in GetUser Details Service");
chatCustDetail = iGetChatUserDetailService.getChatCustDetail(userId, ipAddr);
logger.debug("Returning response to the handler");
}
catch(Exception ex){
model.addAttribute(Message.MESSAGES, populateMessageObject("livechat.service.error",6002));
logger.error("Error. Error Message: "+ex.getMessage());
}


//model.addAttribute("model",chatCustDetail);
logger.debug("*********190");
return chatCustDetail;
}

private Object populateMessageObject(String string,int errorCode) {

Message messageObject = new Message();
messageObject.setType(MessageType.ERROR);
messageObject.setCode(String.valueOf(errorCode));
String messageText = messageSource.getMessage(string,null, null);
messageObject.setText( messageText);
return messageObject;
}

}//end of class


package com.stock.domain;

import java.util.List;

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

@XmlRootElement(name="GetChatDetailsResp")
@XmlAccessorType(XmlAccessType.FIELD)
public class ChatUserDetail {


private List<ChatUserAccount> chatUserlist;
private ChatUserLocation userLoc;


public List<ChatUserAccount> getChatUserlist() {
return chatUserlist;
}
@XmlElement(name="User")
public void setChatUserlist(List<ChatUserAccount> chatUserlist) {
this.chatUserlist = chatUserlist;
}

public ChatUserLocation getUserLoc() {
return userLoc;
}
public void setUserLoc(ChatUserLocation userLoc) {
this.userLoc = userLoc;
}


}

spring context xml

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

<context:component-scan base-package="com.chat.controller" />
<context:component-scan base-package="com.chat.service" />
<context:component-scan base-package="com.chat.dao" />
<mvc:annotation-driven/>
<context:annotation-config />
<bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
<property name="basenames">
<list>
<value>classpath:config/resource-bundles/chaterrors</value>
</list>
</property>
</bean>
</beans>
8 years ago