2015-06-24 66 views
4

我正在使用Jetty 8(stable),JDK 1.7。 Eclipse月神最新。Jetty:Java.lang.NoClassDefFoundError:org/apache/jasper/runtime/JspApplicationContextImpl錯誤

我是新來使用碼頭與Java,我試圖運行教程(Link to tutorial

提供了一個示例代碼,但我得到以下錯誤:

2015-06-24 10:52:03.208:WARN:oejuc.AbstractLifeCycle:FAILED  
[email protected]: java.lang.NoClassDefFoundError: org/apache/jasper/runtime/JspApplicationContextImpl Java.lang.NoClassDefFoundError:org/apache/jasper/runtime/JspApplicationContextImpl 

我在Maven的檢查這個文件夾不存在。我認爲這個文件夾會自動創建。但是在運行clean build幾次之後,我得到了同樣的錯誤。

我是否需要手動創建該文件夾,然後我應該重試或者是由於其他原因。請指導我正確的方向。

以下是我的pom.xml:

<properties> 
<jetty-version>8.1.1.v20120215</jetty-version> 
</properties> 

<dependencies> 
<dependency> 
    <groupId>org.eclipse.jetty</groupId> 
    <artifactId>jetty-server</artifactId> 
    <version>${jetty-version}</version> 
</dependency> 
</dependencies> 

<build> 
<plugins> 
    <plugin> 
    <!-- This plugin is needed for the servlet example --> 
    <groupId>org.mortbay.jetty</groupId> 
    <artifactId>jetty-maven-plugin</artifactId> 
    <version>${jetty-version}</version> 
    </plugin> 
    <plugin> 
    <groupId>org.codehaus.mojo</groupId> 
    <artifactId>exec-maven-plugin</artifactId> 
    <version>1.1</version> 
    <executions> 
     <execution><goals><goal>java</goal></goals></execution> 
    </executions> 
    <configuration> 
     <mainClass>org.example.HelloWorld</mainClass> 
    </configuration> 
    </plugin> 
</plugins> 
</build> 

感謝

+0

我需要幫助。如果任何人都可以提供幫助,那將非常感激。 – user1400290

回答

0

事實上,默認的JRE版本因爲我的項目設置爲1.5,但我使用的是JDK 1.7。更正這個&更新maven - 項目更新解決了我的問題。另外,我必須停止所有正在運行的服務器(爲了安全起見)。

感謝slawas的幫助。

2

我認爲你必須添加依賴:

<dependency> 
    <groupId>org.mortbay.jetty</groupId> 
    <artifactId>jsp-2.1</artifactId> 
    <version>6.1.14</version> 
</dependency> 

http://mvnrepository.com/artifact/org.mortbay.jetty/jsp-2.1

+0

但是相同的代碼正在另一臺計算機上工作,即使我試過這個解決方案,但我仍然有錯誤。 – user1400290

+0

你有兩個compiuters一樣的環境? Java,AppServer,Eclipse和其他?該庫在運行時需要。 – slawas