hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "林桦" <fjlin...@gmail.com>
Subject the question used httpClient in the websphere 5.1 system
Date Sat, 13 Jan 2007 06:19:41 GMT
httpclient-user,
          help!!!!.
            I use HttpClient in the Websphere 5.1 ND server.
            this java version is J2RE 1.4.2 IBM build
cxia32142ifx-20060209 (SR4-1)
            I find websphere will become cored when use HttpClient in
the product enviroment.
           the websphere core is :
                  1XMCURTHDINFO  Current Thread Details
NULL           ----------------------
3XMTHREADINFO      "Servlet.Engine.Transports : 13" (TID:10395AD0,
sys_thread_t:AD786EE0, state:R, native ID:2A808A) prio=5
4XESTACKTRACE          at java.net.PlainSocketImpl.socketConnect(Native Method)
4XESTACKTRACE          at
java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:336)
4XESTACKTRACE          at
java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:201)
4XESTACKTRACE          at
java.net.PlainSocketImpl.connect(PlainSocketImpl.java:188)
4XESTACKTRACE          at java.net.Socket.connect(Socket.java:478)
4XESTACKTRACE          at
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
4XESTACKTRACE          at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:85)
4XESTACKTRACE          at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:58)
4XESTACKTRACE          at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:60)
4XESTACKTRACE          at java.lang.reflect.Method.invoke(Method.java:391)
4XESTACKTRACE          at
org.apache.commons.httpclient.protocol.ReflectionSocketFactory.createSocket(ReflectionSocketFactory.java:139)
4XESTACKTRACE          at
org.apache.commons.httpclient.protocol.DefaultProtocolSocketFactory.createSocket(DefaultProtocolSocketFactory.java:124)
4XESTACKTRACE          at
org.apache.commons.httpclient.HttpConnection.open(HttpConnection.java:704)
4XESTACKTRACE          at
org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:382)
4XESTACKTRACE          at
org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:168)
4XESTACKTRACE          at
org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:396)
4XESTACKTRACE          at
org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:324)
4XESTACKTRACE          at
com.telthink.iserv.util.HttpUtil.PostPage(HttpUtil.java:119)
4XESTACKTRACE          at
com.telthink.iserv.util.HttpUtil.PostPage(HttpUtil.java:62)
4XESTACKTRACE          at
com.telthink.bean.fjibs.CallIBSImpl.callService(CallIBSImpl.java:224)
4XESTACKTRACE          at
com.telthink.bean.fjibs.CallIBSImpl.call(CallIBSImpl.java:106)
4XESTACKTRACE          at com.telthink.link.service.Call.call(Call.java:114)
4XESTACKTRACE          at com.telthink.link.service.Call.call(Call.java:42)
4XESTACKTRACE          at
com.telthink.iserv.pub.IarDataProxy.runCommonProxy(Unknown Source)
4XESTACKTRACE          at
com.telthink.iserv.pub.IarDataProxy.runProxy(Unknown Source)
4XESTACKTRACE          at
org.apache.jsp._IarDataProxy._jspService(_IarDataProxy.java:79)
4XESTACKTRACE          at
com.ibm.ws.webcontainer.jsp.runtime.HttpJspBase.service(HttpJspBase.java:89)
4XESTACKTRACE          at
javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
4XESTACKTRACE          at
com.ibm.ws.webcontainer.jsp.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:385)
4XESTACKTRACE          at
com.ibm.ws.webcontainer.jsp.servlet.JspServlet.serviceJspFile(JspServlet.java:739)
4XESTACKTRACE          at
com.ibm.ws.webcontainer.jsp.servlet.JspServlet.service(JspServlet.java:837)
4XESTACKTRACE          at
javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
4XESTACKTRACE          at
com.ibm.ws.webcontainer.servlet.StrictServletInstance.doService(StrictServletInstance.java:110)
4XESTACKTRACE          at
com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._service(StrictLifecycleServlet.java:174)
4XESTACKTRACE          at
com.ibm.ws.webcontainer.servlet.ServicingServletState.service(StrictLifecycleServlet.java:333)
4XESTACKTRACE          at
com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.service(StrictLifecycleServlet.java:116)
4XESTACKTRACE          at
com.ibm.ws.webcontainer.servlet.ServletInstance.service(ServletInstance.java:283)
4XESTACKTRACE          at
com.ibm.ws.webcontainer.servlet.ValidServletReferenceState.dispatch(ValidServletReferenceState.java:42)
4XESTACKTRACE          at
com.ibm.ws.webcontainer.servlet.ServletInstanceReference.dispatch(ServletInstanceReference.java:40)
4XESTACKTRACE          at
com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:76)
4XESTACKTRACE          at
filters.SetCharacterEncodingFilter.doFilter(Unknown Source)
4XESTACKTRACE          at
com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:132)
4XESTACKTRACE          at
com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:71)
4XESTACKTRACE          at
com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java:1162)
4XESTACKTRACE          at
com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:676)
4XESTACKTRACE          at
com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:203)
4XESTACKTRACE          at
com.ibm.ws.webcontainer.srt.WebAppInvoker.doForward(WebAppInvoker.java:125)
4XESTACKTRACE          at
com.ibm.ws.webcontainer.srt.WebAppInvoker.handleInvocationHook(WebAppInvoker.java:300)
4XESTACKTRACE          at
com.ibm.ws.webcontainer.cache.invocation.CachedInvocation.handleInvocation(CachedInvocation.java:71)
4XESTACKTRACE          at
com.ibm.ws.webcontainer.cache.invocation.CacheableInvocationContext.invoke(CacheableInvocationContext.java:120)
4XESTACKTRACE          at
com.ibm.ws.webcontainer.srp.ServletRequestProcessor.dispatchByURI(ServletRequestProcessor.java:250)
4XESTACKTRACE          at
com.ibm.ws.webcontainer.oselistener.OSEListenerDispatcher.service(OSEListener.java:334)
4XESTACKTRACE          at
com.ibm.ws.webcontainer.http.HttpConnection.handleRequest(HttpConnection.java:56)
4XESTACKTRACE          at
com.ibm.ws.http.HttpConnection.readAndHandleRequest(HttpConnection.java:652)
4XESTACKTRACE          at
com.ibm.ws.http.HttpConnection.run(HttpConnection.java:448)
4XESTACKTRACE          at
com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:936)
	



my HttpClient code is :
              public static String PostPage(String sURL, String
sParams, String sContent,
    		String sURLEncodeType, String sContentEncodeType,
    		int iConnectTimeout, int iContentTimeout) throws Exception {
    	String sResult = "";
		FileLogger log = new FileLogger();
		StringBuffer sbLog = new StringBuffer("");
		PostMethod postMethod = null;
		try {
			HttpClient httpClient=new HttpClient();
			
			//如果有参数,URL就加上参数内容
			if(sParams!=null) {
				if(sParams.trim().startsWith("?"))
					sURL+=sParams;
				else
					sURL+="?"+sParams;
			}
			
			//设定请求参数
			sURLEncodeType = sURLEncodeType==null?"GBK":sURLEncodeType;
			sContentEncodeType = sContentEncodeType==null?"GBK":sContentEncodeType;
			httpClient.getHttpConnectionManager().getParams()
				.setConnectionTimeout(iConnectTimeout);				//建立连接超时时长
			
			postMethod = new PostMethod(sURL);
			postMethod.getParams().setSoTimeout(iContentTimeout);		//取内容超时时长
			postMethod.getParams().setHttpElementCharset(sURLEncodeType);	//元素字符集
			postMethod.getParams().setContentCharset(sContentEncodeType);	//内部字符集
			if (sContent!=null && sContent.length()>0) {	//设置Body的内容
				StringRequestEntity requestBodyEntity = new StringRequestEntity(sContent);
				postMethod.setRequestEntity(requestBodyEntity);
			}
			
			//日志处理
			sbLog.append("sURL=").append(sURL);
			sbLog.append(", iConnectTimeout=").append(iConnectTimeout).append("ms");
			sbLog.append(", iContentTimeout=").append(iContentTimeout).append("ms");
			sbLog.append(", sURLEncodeType=").append(sURLEncodeType);
			sbLog.append(", sContentEncodeType=").append(sContentEncodeType);
			sbLog.append(", sContent=").append(sContent);

			//开始请求
			int iRespState = httpClient.executeMethod(postMethod);
			sbLog.append(", iRespState=").append(iRespState);
			if (iRespState==HttpStatus.SC_OK) {
				byte[] respBinaryData=postMethod.getResponseBody();
				sResult = new String(respBinaryData).trim();
			}
			else {
				throw new HttpUtilException(iRespState,
HttpStatus.getStatusText(iRespState));
			}
			sbLog.append(", sResult=").append(sResult);
			log.debug("HttpUtil.PostPage() " + sbLog.toString());
		}
		catch (ConnectTimeoutException e) {
			sbLog.append(", ErrorType=ConnectTimeoutException");
			log.error("HttpUtil.PostPage() " + sbLog.toString() + ", ex=" + e);
			throw e;
		}
		catch (SocketTimeoutException e) {
			sbLog.append(", ErrorType=SocketTimeoutException");
			log.error("HttpUtil.PostPage() " + sbLog.toString() + ", ex=" + e);
			throw e;
		}
		catch (HttpException e) {
			sbLog.append(", ErrorType=HttpException");
			log.error("HttpUtil.PostPage() " + sbLog.toString() + ", ex=" + e);
			throw e;
		}
		catch (IOException e) {
			sbLog.append(", ErrorType=IOException");
			log.error("HttpUtil.PostPage() " + sbLog.toString() + ", ex=" + e);
			throw e;
		}
		catch (Exception e) {
			sbLog.append(", ErrorType=Exception");
			log.error("HttpUtil.PostPage() " + sbLog.toString() + ", ex=" + e);
			e.printStackTrace();
			throw e;
		}
		finally{
			if (postMethod!=null)
				postMethod.releaseConnection();
		}
		
    	return sResult;
    }
Mime
View raw message