Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » jaxb marshalling unmarshalling exception in jboss servlet(jaxb servlet marshalling)
jaxb marshalling unmarshalling exception in jboss servlet [message #1064414] Wed, 19 June 2013 07:29
yaron illouz is currently offline yaron illouzFriend
Messages: 1
Registered: June 2013
Junior Member


I am trying to send marshalled jaxb data from a gwt server, and read it at reception in a servlet run by jboss.

This is the code in the sending part:

url = new URL(MessageFormat.format(urlStr,ip));
conn = url.openConnection();
conn.setReadTimeout(ApplicationSettings.instance.m_nUrlReadTimeout_ms);
conn.setConnectTimeout(ApplicationSettings.instance.m_nUrlConnectTimeout_ms);
conn.setDoOutput(true);
conn.setDoInput(true);
OutputStreamWriter outStream = new OutputStreamWriter(  conn.getOutputStream());            

Marshaller tmarshaller;
JAXBContext tJAXB= JAXBContext.newInstance(path.to.application.jaxb.componentCurrentKPIs.ComponentCurrentKPIs.class);
tmarshaller = tJAXB.createMarshaller();
tmarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
tmarshaller.marshal(new JAXBElement<ComponentCurrentKPIs>(new QName("componentCurrentKPIs"), ComponentCurrentKPIs.class, currentTableChanges), outStream);          
outStream.flush();

BufferedReader reader = new BufferedReader(new   InputStreamReader(conn.getInputStream()));
String line  = reader.readLine();
reader.close();
outStream.close();


This is the receiving part

public void processRequest(HttpServletRequest pRequest, HttpServletResponse pResponse)throws  IOException
{
    //To avoid new request while a request is processed
    synchronized (lock)
    {
           try
           {
               JAXBContext tJAXB = JAXBContext.newInstance("path.to.class.supervisor.jaxb.componentCurrentKPIs");
               tJAXB = JAXBContext.newInstance(ComponentCurrentKPIs.class);
               Unmarshaller tUnmarshaller = tJAXB.createUnmarshaller();
               JAXBElement model = null;


               BufferedReader rd = new BufferedReader(new InputStreamReader(pRequest.getInputStream()));
               model = (JAXBElement)tUnmarshaller.unmarshal(rd);

               ComponentCurrentKPIs currentKpis = (ComponentCurrentKPIs) model.getValue();

               for(CurrentKPI kpi : currentKpis.getCurrentKPI())
               {
                    Logger.getLogger(SetCurrentKpis.class).debug("in Set Current Kpis  !" + kpi.getName() + " = " +  kpi.getValue());
               }

           } catch (Exception e)
           {
               Logger.getLogger(SetCurrentKpis.class).error("Exception !" ,e);
           }
                    PrintWriter out = pResponse.getWriter();

                    out.println("aaaaaaaaaaaaaaaaa");
            }
        }


}


and i get exception in the servlet(receiving part)

18-06-2013 18:40:22  ERROR  131       path.to.servlets.SetCurrentKpis  -  Exception !
javax.xml.bind.UnmarshalException
 - with linked exception:
[org.xml.sax.SAXParseException: Premature end of file.]
            at javax.xml.bind.helpers.AbstractUnmarshallerImpl.createUnmarshalException(AbstractUnmarshallerImpl.java:315)
            at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.createUnmarshalException(UnmarshallerImpl.java:481)
            at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:203)
            at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:172)
            at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:137)
            at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:194)
            at path.to.applicationName.servlets.SetCurrentKpis.processRequest(SetCurrentKpis.java:120)
            at path.to.applicationName.servlets.infrastructure.AbstractOperationServlet.doPost(AbstractOperationServlet.java:36)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
            at path.to.applicationName.servlets.LoginFilter.doFilter(LoginFilter.java:86)
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
            at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
            at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
            at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
            at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
            at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:153)
            at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
            at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
            at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
            at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
            at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
            at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
            at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
            at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
            at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
            at java.lang.Thread.run(Thread.java:619)
Caused by: org.xml.sax.SAXParseException: Premature end of file.
            at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
            at org.apache.xerces.util.ErrorHandlerWrapper.fatalError(Unknown Source)
            at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
            at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
            at org.apache.xerces.impl.XMLVersionDetector.determineDocVersion(Unknown Source)
            at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
            at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
            at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
            at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
            at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:199)
            ... 29 more


The information i send arrive to the servlet because when i print the headers and parameters of the http request i can see it.

connection : keep-alive
content-type : application/x-www-form-urlencoded
content-length : 353
user : xxxx
  amp;password : xxxx">
    <CurrentKPI value="interface0:interface1" name="Interface"/>
    <CurrentKPI value="false:false" name="Enable"/>
    <CurrentKPI value="interface0:interface1" name="PassThroughPort"/>
</componentCurrentKPIs>

  password : xxxx
  <?xml version : "1.0" encoding="UTF-8" standalone="yes"?>
<componentCurrentKPIs command="http://{0}:8080/monserver/SetCurrentKpis/?user=xxxx
  blablanull

Previous Topic:CanonicalModelProcessor not found
Next Topic:JPQL Composite Key in Dynamic Persistence
Goto Forum:
  


Current Time: Fri Dec 19 23:34:46 GMT 2014

Powered by FUDForum. Page generated in 0.02432 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software