且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

JSP页面犯规在Web服务客户端使用Tomcat运行

更新时间:2023-11-17 23:04:40

这些错误清楚地表明你的JSP无法连接到的 Web服务

当你正在改变域您的 Web服务的你需要改变,以回连接到该客户端的您的连接配置。

I have created a web service . The jsp page works perfectly fine on my local host using tomcat. Now when I deploy it on the virtual host the services are getting deployed but the jsp page wont work. (sorry for the bad code its just for testing)

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
    <%@ page import="com.sayhellotest.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<FORM ACTION="Hi.jsp" METHOD="POST">

<INPUT TYPE="TEXT" NAME="text1">
<BR>
<INPUT TYPE="SUBMIT" value="Submit">
<%
RunnerHello t= new RunnerHello();
String name= t.printName(request.getParameter("text1"));
%>
<% out.println(name); %>
</FORM>

</body>
</html>

The client code is

public class RunnerHello {
    public String printName(String name) throws RemoteException  {
        SayHiStub stub= new SayHiStub();
        SayHiMethod hi= new SayHiMethod();
        hi.setName(name);
        SayHiMethodResponse hires = stub.sayHiMethod(hi);
        return hires.get_return();
    }
}

and the web service code is

public class SayHi {
    public String sayHiMethod(String name) {
        return "hi "+name;
    }

}

When I run it on localhost it works perfectly fine the jsp page run and give the output. But when i run it on the main host the jsp doesnt work (though the services are uploaded). I get the error :

type Exception report

message org.apache.axis2.AxisFault: The host did not accept the connection within timeout of 60000 ms

description The server encountered an internal error that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: org.apache.axis2.AxisFault: The host did not accept the connection within timeout of 60000 ms
    org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:549)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:460)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
root cause

org.apache.axis2.AxisFault: The host did not accept the connection within timeout of 60000 ms
    org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:221)
    org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:452)
    org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:330)
    org.apache.axis2.description.OutInAxisOperationClient.execute(OutInAxisOperation.java:294)
    com.rateexch.RateClassStub.getCurrencyInfo(RateClassStub.java:167)
    com.rateexch.RateRunner.getRateInfo(RateRunner.java:14)
    org.apache.jsp.Rate_jsp._jspService(Rate_jsp.java:81)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
root cause

org.apache.axis2.AxisFault: The host did not accept the connection within timeout of 60000 ms
    org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons(CommonsHTTPTransportSender.java:314)
    org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:201)
    org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:452)
    org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:330)
    org.apache.axis2.description.OutInAxisOperationClient.execute(OutInAxisOperation.java:294)
    com.rateexch.RateClassStub.getCurrencyInfo(RateClassStub.java:167)
    com.rateexch.RateRunner.getRateInfo(RateRunner.java:14)
    org.apache.jsp.Rate_jsp._jspService(Rate_jsp.java:81)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
root cause

org.apache.axis2.AxisFault: The host did not accept the connection within timeout of 60000 ms
    org.apache.axis2.transport.http.HTTPSender.sendViaPost(HTTPSender.java:179)
    org.apache.axis2.transport.http.HTTPSender.send(HTTPSender.java:73)
    org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons(CommonsHTTPTransportSender.java:305)
    org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:201)
    org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:452)
    org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:330)
    org.apache.axis2.description.OutInAxisOperationClient.execute(OutInAxisOperation.java:294)
    com.rateexch.RateClassStub.getCurrencyInfo(RateClassStub.java:167)
    com.rateexch.RateRunner.getRateInfo(RateRunner.java:14)
    org.apache.jsp.Rate_jsp._jspService(Rate_jsp.java:81)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
root cause

org.apache.commons.httpclient.ConnectTimeoutException: The host did not accept the connection within timeout of 60000 ms
    org.apache.commons.httpclient.protocol.ReflectionSocketFactory.createSocket(ReflectionSocketFactory.java:154)
    org.apache.commons.httpclient.protocol.DefaultProtocolSocketFactory.createSocket(DefaultProtocolSocketFactory.java:124)
    org.apache.commons.httpclient.HttpConnection.open(HttpConnection.java:706)
    org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:386)
    org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:170)
    org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:396)
    org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:346)
    org.apache.axis2.transport.http.AbstractHTTPSender.executeMethod(AbstractHTTPSender.java:558)
    org.apache.axis2.transport.http.HTTPSender.sendViaPost(HTTPSender.java:176)
    org.apache.axis2.transport.http.HTTPSender.send(HTTPSender.java:73)
    org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons(CommonsHTTPTransportSender.java:305)
    org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:201)
    org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:452)
    org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:330)
    org.apache.axis2.description.OutInAxisOperationClient.execute(OutInAxisOperation.java:294)
    com.rateexch.RateClassStub.getCurrencyInfo(RateClassStub.java:167)
    com.rateexch.RateRunner.getRateInfo(RateRunner.java:14)
    org.apache.jsp.Rate_jsp._jspService(Rate_jsp.java:81)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
root cause

java.net.SocketTimeoutException: connect timed out
    java.net.PlainSocketImpl.socketConnect(Native Method)
    java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)
    java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)
    java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)
    java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
    java.net.Socket.connect(Socket.java:579)
    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    java.lang.reflect.Method.invoke(Method.java:606)
    org.apache.commons.httpclient.protocol.ReflectionSocketFactory.createSocket(ReflectionSocketFactory.java:139)
    org.apache.commons.httpclient.protocol.DefaultProtocolSocketFactory.createSocket(DefaultProtocolSocketFactory.java:124)
    org.apache.commons.httpclient.HttpConnection.open(HttpConnection.java:706)
    org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:386)
    org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:170)
    org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:396)
    org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:346)
    org.apache.axis2.transport.http.AbstractHTTPSender.executeMethod(AbstractHTTPSender.java:558)
    org.apache.axis2.transport.http.HTTPSender.sendViaPost(HTTPSender.java:176)
    org.apache.axis2.transport.http.HTTPSender.send(HTTPSender.java:73)
    org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons(CommonsHTTPTransportSender.java:305)
    org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:201)
    org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:452)
    org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:330)
    org.apache.axis2.description.OutInAxisOperationClient.execute(OutInAxisOperation.java:294)
    com.rateexch.RateClassStub.getCurrencyInfo(RateClassStub.java:167)
    com.rateexch.RateRunner.getRateInfo(RateRunner.java:14)
    org.apache.jsp.Rate_jsp._jspService(Rate_jsp.java:81)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

The errors clearly show that your jsp can't connect to the webservice.

As you are changing the domain of your webservice you need to change your connection configurations of your client in order to connect back to it.