Bellow I am giving my xml which i want to consume using spring requestBody
<?xml version="1.0" encoding="UTF-8"?>
<UTILITYTYPE CODE="1">
<ALERT_INFORMATION>
<ALERT_SRC>MODEM</ALERT_SRC>
<MODEM_SERIAL_NUMBER>B00101</MODEM_SERIAL_NUMBER>
<G1>GET06253</G1>
<METER_MFR_NAME>SECURE</METER_MFR_NAME>
<METER_TYPE>FEEDER</METER_TYPE>
<DISCOM>MGVCL</DISCOM>
<ALERT_CODE>73</ALERT_CODE>
<ALERT_STATUS>0</ALERT_STATUS>
<ALERT_DESCRIPTION>11KV RAIYOLIFEEDER Power Failed</ALERT_DESCRIPTION>
<ALERT_GENERATED_DATE_TIME>06-07-2016 15:16:06</ALERT_GENERATED_DATE_TIME>
</ALERT_INFORMATION>
</UTILITYTYPE>
My main issue is i want to mapped the XML parameter to a java bean. i have created the bean as given bellow
@XmlRootElement(name="UTILITYTYPE")
public class UtilityType implements Serializable{
/**
*
*/
private static final long serialVersionUID = 1L;
@XmlAttribute(name="ALERT_INFORMATION")
private List<AlertInformation> alertInformationBean;
public List<AlertInformation> getAlertInformationBean() {
return alertInformationBean;
}
public void setAlertInformationBean(List<AlertInformation> alertInformationBean) {
this.alertInformationBean = alertInformationBean;
}
}
and another bean is
@XmlRootElement
public class AlertInformation implements Serializable{
/**
*
*/
private static final long serialVersionUID = 1L;
@XmlAttribute(name="MODEM_SERIAL_NUMBER")
private String modelSerialNo;
@XmlAttribute(name="G1")
private String generate;
@XmlAttribute(name="METER_MFR_NAME")
private String meterName;
@XmlAttribute(name="METER_TYPE")
private String meterType;
@XmlAttribute(name="DISCOM")
private String disCom;
@XmlAttribute(name="ALERT_CODE")
private int alertCode;
@XmlAttribute(name="ALERT_STATUS")
private int alertStatus;
@XmlAttribute(name="ALERT_DESCRIPTION")
private String alertDesc;
@XmlAttribute(name="ALERT_GENERATED_DATE_TIME")
private String alertDatetime;
@XmlAttribute(name="ALERT_SRC")
private String alertSrc;
The spring controller which is consuming the response are given as bellow
@RequestMapping(value="/getMdasInformation" ,method=RequestMethod.POST, consumes = MediaType.APPLICATION_XML_VALUE)
public @ResponseBody List<ResponseBean> getMdasDetails(@RequestBody UtilityType mdasUBean){
}
Following are the Exception i am getting
@XmlAttribute/@XmlValue need to reference a Java type that maps to text in XML.
this problem is related to the following location:
at private java.util.List com.cnetinfotech.rec.beans.UtilityType.alertInformationBean
at com.cnetinfotech.rec.beans.UtilityType
Class has two properties of the same name "alertInformationBean"
this problem is related to the following location:
at public java.util.List com.cnetinfotech.rec.beans.UtilityType.getAlertInformationBean()
at com.cnetinfotech.rec.beans.UtilityType
this problem is related to the following location:
at private java.util.List com.cnetinfotech.rec.beans.UtilityType.alertInformationBean
at com.cnetinfotech.rec.beans.UtilityType
Class has two properties of the same name "alertCode"
this problem is related to the following location:
at public int com.cnetinfotech.rec.beans.AlertInformation.getAlertCode()
at com.cnetinfotech.rec.beans.AlertInformation
at private java.util.List com.cnetinfotech.rec.beans.UtilityType.alertInformationBean
at com.cnetinfotech.rec.beans.UtilityType
this problem is related to the following location:
at private int com.cnetinfotech.rec.beans.AlertInformation.alertCode
at com.cnetinfotech.rec.beans.AlertInformation
at private java.util.List com.cnetinfotech.rec.beans.UtilityType.alertInformationBean
at com.cnetinfotech.rec.beans.UtilityType
Class has two properties of the same name "alertDatetime"
this problem is related to the following location:
at public java.lang.String com.cnetinfotech.rec.beans.AlertInformation.getAlertDatetime()
at com.cnetinfotech.rec.beans.AlertInformation
at private java.util.List com.cnetinfotech.rec.beans.UtilityType.alertInformationBean
at com.cnetinfotech.rec.beans.UtilityType
this problem is related to the following location:
at private java.lang.String com.cnetinfotech.rec.beans.AlertInformation.alertDatetime
at com.cnetinfotech.rec.beans.AlertInformation
at private java.util.List com.cnetinfotech.rec.beans.UtilityType.alertInformationBean
at com.cnetinfotech.rec.beans.UtilityType
Class has two properties of the same name "alertDesc"
this problem is related to the following location:
at public java.lang.String com.cnetinfotech.rec.beans.AlertInformation.getAlertDesc()
at com.cnetinfotech.rec.beans.AlertInformation
at private java.util.List com.cnetinfotech.rec.beans.UtilityType.alertInformationBean
at com.cnetinfotech.rec.beans.UtilityType
this problem is related to the following location:
at private java.lang.String com.cnetinfotech.rec.beans.AlertInformation.alertDesc
at com.cnetinfotech.rec.beans.AlertInformation
at private java.util.List com.cnetinfotech.rec.beans.UtilityType.alertInformationBean
at com.cnetinfotech.rec.beans.UtilityType
Class has two properties of the same name "alertSrc"
this problem is related to the following location:
at public java.lang.String com.cnetinfotech.rec.beans.AlertInformation.getAlertSrc()
at com.cnetinfotech.rec.beans.AlertInformation
at private java.util.List com.cnetinfotech.rec.beans.UtilityType.alertInformationBean
at com.cnetinfotech.rec.beans.UtilityType
this problem is related to the following location:
at private java.lang.String com.cnetinfotech.rec.beans.AlertInformation.alertSrc
at com.cnetinfotech.rec.beans.AlertInformation
at private java.util.List com.cnetinfotech.rec.beans.UtilityType.alertInformationBean
at com.cnetinfotech.rec.beans.UtilityType
Class has two properties of the same name "alertStatus"
this problem is related to the following location:
at public int com.cnetinfotech.rec.beans.AlertInformation.getAlertStatus()
at com.cnetinfotech.rec.beans.AlertInformation
at private java.util.List com.cnetinfotech.rec.beans.UtilityType.alertInformationBean
at com.cnetinfotech.rec.beans.UtilityType
this problem is related to the following location:
at private int com.cnetinfotech.rec.beans.AlertInformation.alertStatus
at com.cnetinfotech.rec.beans.AlertInformation
at private java.util.List com.cnetinfotech.rec.beans.UtilityType.alertInformationBean
at com.cnetinfotech.rec.beans.UtilityType
Class has two properties of the same name "disCom"
this problem is related to the following location:
at public java.lang.String com.cnetinfotech.rec.beans.AlertInformation.getDisCom()
at com.cnetinfotech.rec.beans.AlertInformation
at private java.util.List com.cnetinfotech.rec.beans.UtilityType.alertInformationBean
at com.cnetinfotech.rec.beans.UtilityType
this problem is related to the following location:
at private java.lang.String com.cnetinfotech.rec.beans.AlertInformation.disCom
at com.cnetinfotech.rec.beans.AlertInformation
at private java.util.List com.cnetinfotech.rec.beans.UtilityType.alertInformationBean
at com.cnetinfotech.rec.beans.UtilityType
Class has two properties of the same name "generate"
this problem is related to the following location:
at public java.lang.String com.cnetinfotech.rec.beans.AlertInformation.getGenerate()
at com.cnetinfotech.rec.beans.AlertInformation
at private java.util.List com.cnetinfotech.rec.beans.UtilityType.alertInformationBean
at com.cnetinfotech.rec.beans.UtilityType
this problem is related to the following location:
at private java.lang.String com.cnetinfotech.rec.beans.AlertInformation.generate
at com.cnetinfotech.rec.beans.AlertInformation
at private java.util.List com.cnetinfotech.rec.beans.UtilityType.alertInformationBean
at com.cnetinfotech.rec.beans.UtilityType
Class has two properties of the same name "meterName"
this problem is related to the following location:
at public java.lang.String com.cnetinfotech.rec.beans.AlertInformation.getMeterName()
at com.cnetinfotech.rec.beans.AlertInformation
at private java.util.List com.cnetinfotech.rec.beans.UtilityType.alertInformationBean
at com.cnetinfotech.rec.beans.UtilityType
this problem is related to the following location:
at private java.lang.String
com.cnetinfotech.rec.beans.AlertInformation.meterName
at com.cnetinfotech.rec.beans.AlertInformation
at private java.util.List com.cnetinfotech.rec.beans.UtilityType.alertInformationBean
at com.cnetinfotech.rec.beans.UtilityType
Class has two properties of the same name "meterType"
this problem is related to the following location:
at public java.lang.String com.cnetinfotech.rec.beans.AlertInformation.getMeterType()
at com.cnetinfotech.rec.beans.AlertInformation
at private java.util.List com.cnetinfotech.rec.beans.UtilityType.alertInformationBean
at com.cnetinfotech.rec.beans.UtilityType
this problem is related to the following location:
at private java.lang.String com.cnetinfotech.rec.beans.AlertInformation.meterType
at com.cnetinfotech.rec.beans.AlertInformation
at private java.util.List com.cnetinfotech.rec.beans.UtilityType.alertInformationBean
at com.cnetinfotech.rec.beans.UtilityType
Class has two properties of the same name "modelSerialNo"
this problem is related to the following location:
at public java.lang.String com.cnetinfotech.rec.beans.AlertInformation.getModelSerialNo()
at com.cnetinfotech.rec.beans.AlertInformation
at private java.util.List com.cnetinfotech.rec.beans.UtilityType.alertInformationBean
at com.cnetinfotech.rec.beans.UtilityType
this problem is related to the following location:
at private java.lang.String com.cnetinfotech.rec.beans.AlertInformation.modelSerialNo
at com.cnetinfotech.rec.beans.AlertInformation
at private java.util.List com.cnetinfotech.rec.beans.UtilityType.alertInformationBean
at com.cnetinfotech.rec.beans.UtilityType
] with root cause
com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 12 counts of IllegalAnnotationExceptions
@XmlAttribute/@XmlValue need to reference a Java type that maps to text in XML.
this problem is related to the following location:
at private java.util.List com.cnetinfotech.rec.beans.UtilityType.alertInformationBean
at com.cnetinfotech.rec.beans.UtilityType
Class has two properties of the same name "alertInformationBean"
this problem is related to the following location:
at public java.util.List com.cnetinfotech.rec.beans.UtilityType.getAlertInformationBean()
at com.cnetinfotech.rec.beans.UtilityType
this problem is related to the following location:
at private java.util.List com.cnetinfotech.rec.beans.UtilityType.alertInformationBean
at com.cnetinfotech.rec.beans.UtilityType
Class has two properties of the same name "alertCode"
this problem is related to the following location:
at public int com.cnetinfotech.rec.beans.AlertInformation.getAlertCode()
at com.cnetinfotech.rec.beans.AlertInformation
at private java.util.List com.cnetinfotech.rec.beans.UtilityType.alertInformationBean
at com.cnetinfotech.rec.beans.UtilityType
this problem is related to the following location:
at private int com.cnetinfotech.rec.beans.AlertInformation.alertCode
at com.cnetinfotech.rec.beans.AlertInformation
at private java.util.List com.cnetinfotech.rec.beans.UtilityType.alertInformationBean
at com.cnetinfotech.rec.beans.UtilityType
Class has two properties of the same name "alertDatetime"
this problem is related to the following location:
at public java.lang.String com.cnetinfotech.rec.beans.AlertInformation.getAlertDatetime()
at com.cnetinfotech.rec.beans.AlertInformation
at private java.util.List com.cnetinfotech.rec.beans.UtilityType.alertInformationBean
at com.cnetinfotech.rec.beans.UtilityType
this problem is related to the following location:
at private java.lang.String com.cnetinfotech.rec.beans.AlertInformation.alertDatetime
at com.cnetinfotech.rec.beans.AlertInformation
at private java.util.List com.cnetinfotech.rec.beans.UtilityType.alertInformationBean
at com.cnetinfotech.rec.beans.UtilityType
Class has two properties of the same name "alertDesc"
this problem is related to the following location:
at public java.lang.String com.cnetinfotech.rec.beans.AlertInformation.getAlertDesc()
at com.cnetinfotech.rec.beans.AlertInformation
at private java.util.List com.cnetinfotech.rec.beans.UtilityType.alertInformationBean
at com.cnetinfotech.rec.beans.UtilityType
this problem is related to the following location:
at private java.lang.String com.cnetinfotech.rec.beans.AlertInformation.alertDesc
at com.cnetinfotech.rec.beans.AlertInformation
at private java.util.List com.cnetinfotech.rec.beans.UtilityType.alertInformationBean
at com.cnetinfotech.rec.beans.UtilityType
Class has two properties of the same name "alertSrc"
this problem is related to the following location:
at public java.lang.String com.cnetinfotech.rec.beans.AlertInformation.getAlertSrc()
at com.cnetinfotech.rec.beans.AlertInformation
at private java.util.List com.cnetinfotech.rec.beans.UtilityType.alertInformationBean
at com.cnetinfotech.rec.beans.UtilityType
this problem is related to the following location:
at private java.lang.String com.cnetinfotech.rec.beans.AlertInformation.alertSrc
at com.cnetinfotech.rec.beans.AlertInformation
at private java.util.List com.cnetinfotech.rec.beans.UtilityType.alertInformationBean
at com.cnetinfotech.rec.beans.UtilityType
Class has two properties of the same name "alertStatus"
this problem is related to the following location:
at public int com.cnetinfotech.rec.beans.AlertInformation.getAlertStatus()
at com.cnetinfotech.rec.beans.AlertInformation
at private java.util.List com.cnetinfotech.rec.beans.UtilityType.alertInformationBean
at com.cnetinfotech.rec.beans.UtilityType
this problem is related to the following location:
at private int com.cnetinfotech.rec.beans.AlertInformation.alertStatus
at com.cnetinfotech.rec.beans.AlertInformation
at private java.util.List com.cnetinfotech.rec.beans.UtilityType.alertInformationBean
at com.cnetinfotech.rec.beans.UtilityType
Class has two properties of the same name "disCom"
this problem is related to the following location:
at public java.lang.String com.cnetinfotech.rec.beans.AlertInformation.getDisCom()
at com.cnetinfotech.rec.beans.AlertInformation
at private java.util.List com.cnetinfotech.rec.beans.UtilityType.alertInformationBean
at com.cnetinfotech.rec.beans.UtilityType
this problem is related to the following location:
at private java.lang.String com.cnetinfotech.rec.beans.AlertInformation.disCom
at com.cnetinfotech.rec.beans.AlertInformation
at private java.util.List com.cnetinfotech.rec.beans.UtilityType.alertInformationBean
at com.cnetinfotech.rec.beans.UtilityType
Class has two properties of the same name "generate"
this problem is related to the following location:
at public java.lang.String com.cnetinfotech.rec.beans.AlertInformation.getGenerate()
at com.cnetinfotech.rec.beans.AlertInformation
at private java.util.List com.cnetinfotech.rec.beans.UtilityType.alertInformationBean
at com.cnetinfotech.rec.beans.UtilityType
this problem is related to the following location:
at private java.lang.String com.cnetinfotech.rec.beans.AlertInformation.generate
at com.cnetinfotech.rec.beans.AlertInformation
at private java.util.List com.cnetinfotech.rec.beans.UtilityType.alertInformationBean
at com.cnetinfotech.rec.beans.UtilityType
Class has two properties of the same name "meterName"
this problem is related to the following location:
at public java.lang.String com.cnetinfotech.rec.beans.AlertInformation.getMeterName()
at com.cnetinfotech.rec.beans.AlertInformation
at private java.util.List com.cnetinfotech.rec.beans.UtilityType.alertInformationBean
at com.cnetinfotech.rec.beans.UtilityType
this problem is related to the following location:
at private java.lang.String com.cnetinfotech.rec.beans.AlertInformation.meterName
at com.cnetinfotech.rec.beans.AlertInformation
at private java.util.List com.cnetinfotech.rec.beans.UtilityType.alertInformationBean
at com.cnetinfotech.rec.beans.UtilityType
Class has two properties of the same name "meterType"
this problem is related to the following location:
at public java.lang.String com.cnetinfotech.rec.beans.AlertInformation.getMeterType()
at com.cnetinfotech.rec.beans.AlertInformation
at private java.util.List com.cnetinfotech.rec.beans.UtilityType.alertInformationBean
at com.cnetinfotech.rec.beans.UtilityType
this problem is related to the following location:
at private java.lang.String com.cnetinfotech.rec.beans.AlertInformation.meterType
at com.cnetinfotech.rec.beans.AlertInformation
at private java.util.List com.cnetinfotech.rec.beans.UtilityType.alertInformationBean
at com.cnetinfotech.rec.beans.UtilityType
Class has two properties of the same name "modelSerialNo"
this problem is related to the following location:
at public java.lang.String com.cnetinfotech.rec.beans.AlertInformation.getModelSerialNo()
at com.cnetinfotech.rec.beans.AlertInformation
at private java.util.List com.cnetinfotech.rec.beans.UtilityType.alertInformationBean
at com.cnetinfotech.rec.beans.UtilityType
this problem is related to the following location:
at private java.lang.String com.cnetinfotech.rec.beans.AlertInformation.modelSerialNo
at com.cnetinfotech.rec.beans.AlertInformation
at private java.util.List com.cnetinfotech.rec.beans.UtilityType.alertInformationBean
at com.cnetinfotech.rec.beans.UtilityType
at com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException$Builder.check(Unknown Source)
at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(Unknown Source)
at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.<init>(Unknown Source)
at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.<init>(Unknown Source)
at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(Unknown Source)
at com.sun.xml.internal.bind.v2.ContextFactory.createContext(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at javax.xml.bind.ContextFinder.newInstance(Unknown Source)
at javax.xml.bind.ContextFinder.newInstance(Unknown Source)
at javax.xml.bind.ContextFinder.find(Unknown Source)
at javax.xml.bind.JAXBContext.newInstance(Unknown Source)
at javax.xml.bind.JAXBContext.newInstance(Unknown Source)
at org.springframework.http.converter.xml.AbstractJaxb2HttpMessageConverter.getJaxbContext(AbstractJaxb2HttpMessageConverter.java:111)
at org.springframework.http.converter.xml.AbstractJaxb2HttpMessageConverter.createUnmarshaller(AbstractJaxb2HttpMessageConverter.java:79)
at org.springframework.http.converter.xml.Jaxb2RootElementHttpMessageConverter.readFromSource(Jaxb2RootElementHttpMessageConverter.java:103)
at org.springframework.http.converter.xml.AbstractXmlHttpMessageConverter.readInternal(AbstractXmlHttpMessageConverter.java:61)
at org.springframework.http.converter.AbstractHttpMessageConverter.read(AbstractHttpMessageConverter.java:159)
at org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodArgumentResolver.readWithMessageConverters(AbstractMessageConverterMethodArgumentResolver.java:154)
at org.springframework.web.servlet.mvc.method.annotation.RequestResponseBodyMethodProcessor.readWithMessageConverters(RequestResponseBodyMethodProcessor.java:149)
at org.springframework.web.servlet.mvc.method.annotation.RequestResponseBodyMethodProcessor.resolveArgument(RequestResponseBodyMethodProcessor.java:100)
at org.springframework.web.method.support.HandlerMethodArgumentResolverComposite.resolveArgument(HandlerMethodArgumentResolverComposite.java:77)
at org.springframework.web.method.support.InvocableHandlerMethod.getMethodArgumentValues(InvocableHandlerMethod.java:162)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:129)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:110)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:776)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:705)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:959)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:966)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:868)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:842)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at com.thetransactioncompany.cors.CORSFilter.doFilter(CORSFilter.java:174)
at com.thetransactioncompany.cors.CORSFilter.doFilter(CORSFilter.java:237)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:987)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:579)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:307)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
but i am not able to consume it and its giving 404 error. Please help me to solve it. Big thanks in advance.