PWC1406: Servlet.service() threw exception java.io.IOException: Invalid chunk header When client se

Posted by Nivek on Stack Overflow See other posts from Stack Overflow or by Nivek
Published on 2010-04-08T07:15:13Z Indexed on 2010/04/08 11:43 UTC
Read the original article Hit count: 714

Filed under:
|
|
|

I am developing an application using J2ME to send the GPS coordinates received to the server and i am new to developing client server application.

Everything works fine with the use of Nokia N97mini or E71. But when i tried it on HTC HD2, i get the exception from the server. I am using Netbeans 6.5.1 GlassFish V2 as Server. I have no idea why this error occurs only on the HTC HD2. Any help will be greatly appreciated. Thanks...

Below is the error message:

StandardWrapperValve[FindHospitalServlet]: PWC1406: Servlet.service() for servlet FindHospitalServlet threw exception
java.io.IOException: Invalid chunk header
    at org.apache.coyote.http11.filters.ChunkedInputFilter.doRead(ChunkedInputFilter.java:171)
    at org.apache.coyote.http11.InternalInputBuffer.doRead(InternalInputBuffer.java:719)
    at org.apache.coyote.Request.doRead(Request.java:482)
    at org.apache.coyote.tomcat5.InputBuffer.realReadBytes(InputBuffer.java:342)
    at org.apache.tomcat.util.buf.ByteChunk.substract(ByteChunk.java:378)
    at org.apache.coyote.tomcat5.InputBuffer.readByte(InputBuffer.java:351)
    at org.apache.coyote.tomcat5.CoyoteInputStream.read(CoyoteInputStream.java:159)
    at java.io.DataInputStream.readUnsignedShort(DataInputStream.java:320)
    at java.io.DataInputStream.readUTF(DataInputStream.java:572)
    at java.io.DataInputStream.readUTF(DataInputStream.java:547)
    at myPackage.FindHospitalServlet.doPost(FindHospitalServlet.java:28)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:754)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
    at org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:427)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:315)
    at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:287)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:218)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:648)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:593)
    at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:94)
    at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:98)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:222)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:648)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:593)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:587)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1096)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:166)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:648)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:593)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:587)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1096)
    at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:288)
    at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.invokeAdapter(DefaultProcessorTask.java:647)
    at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.doProcess(DefaultProcessorTask.java:579)
    at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.process(DefaultProcessorTask.java:831)
    at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.executeProcessorTask(DefaultReadTask.java:341)
    at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:263)
    at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:214)
    at com.sun.enterprise.web.portunif.PortUnificationPipeline$PUTask.doTask(PortUnificationPipeline.java:380)
    at com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:265)
    at com.sun.enterprise.web.connector.grizzly.ssl.SSLWorkerThread.run(SSLWorkerThread.java:106)

Below is the code that i wrote to connect to the server:

private void connectFindHospServlet()
{
    String url = "http://172.22.190.13:8080/UpdateServlet/FindHospitalServlet";
    StringBuffer sb = new StringBuffer();

    String info = lat+"!"+lng+"!";

    try
    {
        HttpConnection c = (HttpConnection) Connector.open(url);
        c.setRequestProperty("User-Agent","Profile/MIDP-2.0, Configuration/CLDC-1.0");
        c.setRequestProperty("Content-Language","en-US");
        c.setRequestMethod(HttpConnection.POST);

        DataOutputStream os = (DataOutputStream)c.openDataOutputStream();
        os.writeUTF(info);
        os.flush();
        os.close();

        // Get the response from the servlet page.
        DataInputStream is =(DataInputStream)c.openDataInputStream();

        int ch;
        sb = new StringBuffer();

        while ((ch = is.read()) != -1)
            sb.append((char)ch);

        is.close();
        c.close();

        if(sb.toString().charAt(0) == 'n')
        {
            formDisplayResultFindHosp();
            display.setCurrent(formDisplayResultFindHosp);
        }
        else
        {
            PlannerMain pm = new PlannerMain();
            hospInfo = pm.getFindHospInfo(sb.toString().substring(0, sb.length()-2));
            formDisplayResultFindHosp(hospInfo);
            display.setCurrent(formDisplayResultFindHosp);
        }
    }
    catch (Exception e)
    {
        System.out.println("Error recieve find user");
    }
}

Any information needed to better help in understanding the problem, do let me know. I will try to provide as much as possible.

© Stack Overflow or respective owner

Related posts about servlets

Related posts about j2me