论坛首页 Java企业应用论坛

用httpclient开发的在线自动抢订火车票系统(已上传源代码)

浏览 182716 次
该帖已经被评为精华帖
作者 正文
   发表时间:2012-01-09  
tidehunter 写道
lianglove_0 写道
c下面没有啊


自己看看其他盘 ,不行就看看源码,这点时间都没  回去过年干嘛

有病 肯定是在订票啊!!!!!!
0 请登录后投票
   发表时间:2012-01-09  
搞久 了 他就 封IP了
0 请登录后投票
   发表时间:2012-01-09  
哥们牛逼啊
0 请登录后投票
   发表时间:2012-01-09  
java.lang.IllegalStateException: Invalid use of SingleClientConnManager: connection still allocated.
Make sure to release the connection before allocating another one.
at org.apache.http.impl.conn.SingleClientConnManager.getConnection(SingleClientConnManager.java:199)
at org.apache.http.impl.conn.SingleClientConnManager$1.getConnection(SingleClientConnManager.java:173)
at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:390)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:641)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:576)
at com.bincode.util.HttpUtils.doGetBody(HttpUtils.java:247)
at com.bincode.start.OrderMain$3.run(OrderMain.java:51)

这个错误怎么解决?
0 请登录后投票
   发表时间:2012-01-09  
牛逼。。。很给力
0 请登录后投票
   发表时间:2012-01-09  
强悍  把程序应用到了实际生活中  不错啊
0 请登录后投票
   发表时间:2012-01-09  
Jar包下载地址:http://115.com/file/cl01kzot#
0 请登录后投票
   发表时间:2012-01-09   最后修改:2012-01-09
leopardoing 写道
java.lang.IllegalStateException: Invalid use of SingleClientConnManager: connection still allocated.
Make sure to release the connection before allocating another one.
at org.apache.http.impl.conn.SingleClientConnManager.getConnection(SingleClientConnManager.java:199)
at org.apache.http.impl.conn.SingleClientConnManager$1.getConnection(SingleClientConnManager.java:173)
at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:390)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:641)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:576)
at com.bincode.util.HttpUtils.doGetBody(HttpUtils.java:247)
at com.bincode.start.OrderMain$3.run(OrderMain.java:51)

这个错误怎么解决?


这个因为所有线程都共享一下httpclient,造成http发送请求的冲突,可以改造一下HttpUtils,为每个线程分配一个独立的httpclient,使用ThreadLocal;
private static ThreadLocal<DefaultHttpClient> _threadHttpClient = new ThreadLocal<DefaultHttpClient> ();

/**
	 * 获取请求URL的网页内容
	 */
	public static HttpClient createHttpClient() {
		DefaultHttpClient httpclient = _threadHttpClient.get();
		if (httpclient != null) {
			return httpclient;
		}
		httpclient = new DefaultHttpClient();
		_threadHttpClient.set(httpclient);
....
}
0 请登录后投票
   发表时间:2012-01-09  
javax.net.ssl.SSLException: hostname in certificate didn't match: <dynamic.12306.cn/123.103.14.224> != <dynamic.12306.cn>
	at org.apache.http.conn.ssl.AbstractVerifier.verify(AbstractVerifier.java:228)
	at org.apache.http.conn.ssl.BrowserCompatHostnameVerifier.verify(BrowserCompatHostnameVerifier.java:54)
	at org.apache.http.conn.ssl.AbstractVerifier.verify(AbstractVerifier.java:149)
	at org.apache.http.conn.ssl.AbstractVerifier.verify(AbstractVerifier.java:130)
	at org.apache.http.conn.ssl.SSLSocketFactory.connectSocket(SSLSocketFactory.java:397)
	at org.apache.http.conn.ssl.SSLSocketFactory.connectSocket(SSLSocketFactory.java:495)
	at org.apache.http.conn.scheme.SchemeSocketFactoryAdaptor.connectSocket(SchemeSocketFactoryAdaptor.java:62)
	at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:148)
	at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:149)
	at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:121)
	at org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:573)
	at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:425)
	at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:820)
	at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:754)
	at com.bincode.util.HttpUtils.doGetFile(HttpUtils.java:313)
	at com.bincode.start.OrderMain.waitSetSubmitCode(OrderMain.java:191)
	at com.bincode.start.OrderMain.main(OrderMain.java:34)
null
Exception in thread "main" java.lang.NullPointerException: Source must not be null
	at org.apache.commons.io.FileUtils.copyFile(FileUtils.java:761)
	at org.apache.commons.io.FileUtils.copyFile(FileUtils.java:731)
	at com.bincode.start.OrderMain.waitSetSubmitCode(OrderMain.java:196)
	at com.bincode.start.OrderMain.main(OrderMain.java:34)

什么情况?
0 请登录后投票
   发表时间:2012-01-09  
SSL证书有问题吧
0 请登录后投票
论坛首页 Java企业应用版

跳转论坛:
Global site tag (gtag.js) - Google Analytics