繁体   English   中英

具有java.lang.illegalstateexception state == header的WebSphere服务器和Jetty客户端

[英]WebSphere server and Jetty client with java.lang.illegalstateexception state==header

我有2个软件包-1个用于在传统Web服务器(Tomcat 6,Websphere 7)中维护的服务器,以及1个与作为客户端的实时Web服务器Jetty一起维护的服务器。 服务器和代理在Windows 7机器和JRE 6上可以在本地完美运行:(1)服务器已加载到Tomcat。 (2)代理使用自定义端口初始化Jetty 8 Web服务器。

当我将其投入生产时(Linux环境),我将WAR加载到了WebSphere,这似乎工作正常。 我在生产中使用“ jave -jar”执行了Agent jar,它似乎可以工作。 它们进行通信后-如果在'java.lang.illegalstateexception:state == header'异常上失败,则代理失败。

现在,我将WebSphere生产应用程序引用到了我的本地计算机上,并且所有通信都可以正常工作(Agent在Windows 7上本地运行,在Linux上是远程服务器)。

因此,似乎代理(或其内部Jetty)存在问题,代码如下所示:

         private void respondOK(Request baseRequest, HttpServletResponse response)
        throws IOException {
    response.setContentType("text/html;charset=utf-8");
    response.setStatus(HttpServletResponse.SC_OK);
    baseRequest.setHandled(true);
    response.getWriter().println("OK");
}

private boolean handleAgentMonitoringTasks( 
                                    Request baseRequest,
                                    HttpServletRequest request,
                                    HttpServletResponse response) {
    boolean didRespond = false;

    // extract the agent data   
    try {
        String reqContent = readRequestContent(baseRequest);

        // handle the input
        theAgentWorker.updateTasksList(reqContent);

    } catch (IOException e) {
        // send a response indicating the error
        respondError(baseRequest, response, "Error getting request content - " + e.getMessage(), e);
        didRespond = true;
    }


    return didRespond;
 }


 private boolean handleServerInfo(  Request baseRequest,
                                    HttpServletRequest request,
                                    HttpServletResponse response) {

    boolean didRespond = false;

    // extract the request content
    try {
        String reqContent = readRequestContent(baseRequest);

        if (reqContent.length() > 0) {
            try {
                theAgentWorker.handleServerInfoData(reqContent);
            }
            catch (Exception e) {
                respondError(baseRequest, response, "Error setting server information - " + e.getMessage(), e);
                didRespond = true;
            }
        }
        else {
            respondError(baseRequest, response, "Server address not found in the request", null);
            didRespond = true;              
        }

    } catch (IOException e) {
        // send a response indicating the error
        respondError(baseRequest, response, "Error getting request content - " + e.getMessage(), e);
        didRespond = true;
    }

    return didRespond;
 }


private String readRequestContent(Request baseRequest) throws IOException {
    BufferedReader br = baseRequest.getReader();
    StringBuilder sBuilder = new StringBuilder();
    char[] buff = new char[4092];

    int charsRead = br.read(buff, 0, buff.length);
    while (charsRead == buff.length) {
        sBuilder.append(buff);
        charsRead = br.read(buff, 0, buff.length);
    }
    sBuilder.append(buff,0, charsRead);
    return sBuilder.toString();
}

上面所有的代码都输入此类:公共类AgentHttpHandler扩展了AbstractHandler

AbstractHandler是Jetty的处理程序类。

当我研究它时,我发现Jetty的getReader()和getInputStream()存在问题,但是我找不到合理的解释来解释为什么它不稳定-在Windows 7中该Agent可以正常工作,而在Linux上,它具有问题(我尝试了几台Linux服务器)。

您知道Jetty WebServer的某些Linux网络问题吗? 我有更多信息,但我认为此信息应该足够

好的,可能与谁有关:

我决定遍历所有WebSphere配置-并定义了具有TCP链接和新端口的虚拟主机。 然后,我使用新的ant编译工具重新编译了所有软件包。

之后(这是最重要的部分)-我使用[CDATA]定义了配置文件中提到的url,并且不使用localhost。 相反,我使用服务器和客户端的主机名。

中提琴,一切似乎正常。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM