Win a copy of JDBC Workbook this week in the JDBC and Relational Databases forum
or A Day in Code in the A Day in Code forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

Annotations not being detected

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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>
 
This is my favorite show. And this is my favorite tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic