2016-04-23 146 views
-1

我試圖創建/運行一個java web應用程序,並遇到以下錯誤。我看到其他人也有類似的問題,但是,我嘗試了他們所說的,但他們都沒有工作。無法在本地啓動Tomcat v8.0

A child container failed during start 
java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/CourseServer]] 
at java.util.concurrent.FutureTask.report(FutureTask.java:122) 
at java.util.concurrent.FutureTask.get(FutureTask.java:192) 
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:916) 
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:871) 
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147) 
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1408) 
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1398) 
at java.util.concurrent.FutureTask.run(FutureTask.java:266) 
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) 
at java.lang.Thread.run(Thread.java:745) 
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/CourseServer]] 
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:153) 
... 6 more 
Caused by: java.lang.NoClassDefFoundError: org/json/JSONException 
at java.lang.Class.getDeclaredFields0(Native Method) 
at java.lang.Class.privateGetDeclaredFields(Class.java:2583) 
at java.lang.Class.getDeclaredFields(Class.java:1916) 
at org.apache.catalina.util.Introspection.getDeclaredFields(Introspection.java:106) 
at org.apache.catalina.startup.WebAnnotationSet.loadFieldsAnnotation(WebAnnotationSet.java:256) 
at org.apache.catalina.startup.WebAnnotationSet.loadApplicationServletAnnotations(WebAnnotationSet.java:132) 
at org.apache.catalina.startup.WebAnnotationSet.loadApplicationAnnotations(WebAnnotationSet.java:65) 
at org.apache.catalina.startup.ContextConfig.applicationAnnotationsConfig(ContextConfig.java:334) 
at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:783) 
at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:305) 
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:95) 
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90) 
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5154) 
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147) 
... 6 more 
Caused by: java.lang.ClassNotFoundException: org.json.JSONException 
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1308) 
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1142) 
... 20 more 

,什麼是我的WEB-INF/lib目錄 enter image description here

幫助!

回答

2

下面添加dependency到您pom.xml

<dependency> 
    <groupId>org.json</groupId> 
    <artifactId>json</artifactId> 
    <version>20160212</version> 
</dependency> 

如果你不使用maven,那麼你必須下載並添加此java-json.jar到您的構建路徑

0

NoClassDefFoundError: org/json/JSONException意味着它不能找到類JSONException在運行時。您可以將其作爲依賴項添加到您的pom.xml中,將其添加到您的構建路徑或將JAR添加到您的Tomcat Lib folder

無論哪種方式,你必須得到包含JSONException的JAR。其中可以找到here

0

我試過所有的手段,他們都不工作,直到我重新安裝tomacat ....