问题描述
HttpClientclient=newHttpClient();PostMethodpost=newPostMethod("http://sms.webchinese.cn/web_api/");post.addRequestHeader("Content-Type","application/x-www-form-urlencoded;charset=gbk");NameValuePair[]data={newNameValuePair("Uid","...."),newNameValuePair("Key","8f72...."),newNameValuePair("smsMob","18..."),newNameValuePair("smsText","以后给我")};post.setRequestBody(data);client.executeMethod(post);Header[]headers=post.getRequestHeaders();intstatusCode=post.getStatusCode();System.out.println("statusCode:"+statusCode);for(Headerh:headers){System.out.println(h.toString());}Stringresult=newString(post.getResponseBodyAsString().getBytes("gbk"));System.out.println(result);post.releaseConnection();
网上找的代码console出现的提示是严重:Achildcontainerfailedduringstartjava.util.concurrent.ExecutionException:org.apache.catalina.LifecycleException:Failedtostartcomponent[StandardEngine[Catalina].StandardHost[localhost].StandardContext[/MailDev]]atjava.util.concurrent.FutureTask.report(UnknownSource)atjava.util.concurrent.FutureTask.get(UnknownSource)atorg.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1123)atorg.apache.catalina.core.StandardHost.startInternal(StandardHost.java:799)atorg.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)atorg.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)atorg.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)atjava.util.concurrent.FutureTask.run(UnknownSource)atjava.util.concurrent.ThreadPoolExecutor.runWorker(UnknownSource)atjava.util.concurrent.ThreadPoolExecutor$Worker.run(UnknownSource)atjava.lang.Thread.run(UnknownSource)Causedby:org.apache.catalina.LifecycleException:Failedtostartcomponent[StandardEngine[Catalina].StandardHost[localhost].StandardContext[/MailDev]]atorg.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)...6moreCausedby:java.lang.NoClassDefFoundError:org/apache/commons/httpclient/HttpMethodatjava.lang.Class.getDeclaredFields0(NativeMethod)atjava.lang.Class.privateGetDeclaredFields(UnknownSource)atjava.lang.Class.getDeclaredFields(UnknownSource)atorg.apache.catalina.util.Introspection.getDeclaredFields(Introspection.java:106)atorg.apache.catalina.startup.WebAnnotationSet.loadFieldsAnnotation(WebAnnotationSet.java:261)atorg.apache.catalina.startup.WebAnnotationSet.loadApplicationServletAnnotations(WebAnnotationSet.java:140)atorg.apache.catalina.startup.WebAnnotationSet.loadApplicationAnnotations(WebAnnotationSet.java:65)atorg.apache.catalina.startup.ContextConfig.applicationAnnotationsConfig(ContextConfig.java:400)atorg.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:876)atorg.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:371)atorg.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)atorg.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)atorg.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5355)atorg.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)...6moreCausedby:java.lang.ClassNotFoundException:org.apache.commons.httpclient.HttpMethodatorg.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1718)atorg.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1569)...20more一月15,20151:57:57下午org.apache.catalina.core.ContainerBasestartInternal严重:Achildcontainerfailedduringstartjava.util.concurrent.ExecutionException:org.apache.catalina.LifecycleException:Failedtostartcomponent[StandardEngine[Catalina].StandardHost[localhost]]atjava.util.concurrent.FutureTask.report(UnknownSource)atjava.util.concurrent.FutureTask.get(UnknownSource)atorg.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1123)atorg.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:300)atorg.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)atorg.apache.catalina.core.StandardService.startInternal(StandardService.java:443)atorg.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)atorg.apache.catalina.core.StandardServer.startInternal(StandardServer.java:731)atorg.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)atorg.apache.catalina.startup.Catalina.start(Catalina.java:689)atsun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethod)atsun.reflect.NativeMethodAccessorImpl.invoke(UnknownSource)atsun.reflect.DelegatingMethodAccessorImpl.invoke(UnknownSource)atjava.lang.reflect.Method.invoke(UnknownSource)atorg.apache.catalina.startup.Bootstrap.start(Bootstrap.java:321)atorg.apache.catalina.startup.Bootstrap.main(Bootstrap.java:455)Causedby:org.apache.catalina.LifecycleException:Failedtostartcomponent[StandardEngine[Catalina].StandardHost[localhost]]atorg.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)atorg.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)atorg.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)atjava.util.concurrent.FutureTask.run(UnknownSource)atjava.util.concurrent.ThreadPoolExecutor.runWorker(UnknownSource)atjava.util.concurrent.ThreadPoolExecutor$Worker.run(UnknownSource)atjava.lang.Thread.run(UnknownSource)Causedby:org.apache.catalina.LifecycleException:Achildcontainerfailedduringstartatorg.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1131)atorg.apache.catalina.core.StandardHost.startInternal(StandardHost.java:799)atorg.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)...6more一月15,20151:57:57下午org.apache.catalina.startup.Catalinastart严重:TherequiredServercomponentfailedtostartsoTomcatisunabletostart.org.apache.catalina.LifecycleException:Failedtostartcomponent[StandardServer[8004]]atorg.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)atorg.apache.catalina.startup.Catalina.start(Catalina.java:689)atsun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethod)atsun.reflect.NativeMethodAccessorImpl.invoke(UnknownSource)atsun.reflect.DelegatingMethodAccessorImpl.invoke(UnknownSource)atjava.lang.reflect.Method.invoke(UnknownSource)atorg.apache.catalina.startup.Bootstrap.start(Bootstrap.java:321)atorg.apache.catalina.startup.Bootstrap.main(Bootstrap.java:455)Causedby:org.apache.catalina.LifecycleException:Failedtostartcomponent[StandardService[Catalina]]atorg.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)atorg.apache.catalina.core.StandardServer.startInternal(StandardServer.java:731)atorg.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)...7moreCausedby:org.apache.catalina.LifecycleException:Failedtostartcomponent[StandardEngine[Catalina]]atorg.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)atorg.apache.catalina.core.StandardService.startInternal(StandardService.java:443)atorg.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)...9moreCausedby:org.apache.catalina.LifecycleException:Achildcontainerfailedduringstartatorg.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1131)atorg.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:300)atorg.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)...11more一月15,20151:57:57下午org.apache.coyote.AbstractProtocolpause
解决方案
解决方案二:
Causedby:java.lang.NoClassDefFoundError:org/apache/commons/httpclient/HttpMethod你有认真看异常信息吗?检查运行时的classpath.