0

struts2とspring3を使用するWebアプリケーションがあります。springを構成するために、Eclipseとtomcatのビルドパスを使用して、プロジェクトに必要なライブラリを追加しました。web.xmlにもリスナーを追加しましたが、アプリケーションを実行すると、次のエラーが表示されます。重大:クラスorg.springframework.web.context.ContextLoaderListener java.lang.ClassNotFoundExceptionのアプリケーションリスナーの構成中にエラーが発生しました:org.springframework.web .context.ContextLoaderListenerグーグルしすぎましたが、何も起こりません。誰かが、application libとtomacatの両方にspring-web.jarを追加するように言われましたが、何も変わりません。助けてください。

クラスパス:

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry exported="true" kind="con"    path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jre6">
    <attributes>
        <attribute name="owner.project.facets" value="java"/>
    </attributes>
</classpathentry>
<classpathentry exported="true" kind="con" path="org.eclipse.jst.server.core.container/org.eclipse.jst.server.tomcat.runtimeTarget/Apache Tomcat v6.0">
    <attributes>
        <attribute name="owner.project.facets" value="jst.web"/>
    </attributes>
</classpathentry>
<classpathentry exported="true" kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
<classpathentry exported="true" kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/>
<classpathentry exported="true" kind="con" path="org.eclipse.jdt.USER_LIBRARY/hibernate"/>
<classpathentry exported="true" kind="lib" path="WebContent/WEB-INF/lib/antlr-2.7.6.jar"/>
<classpathentry exported="true" kind="lib" path="WebContent/WEB-INF/lib/asm-attrs.jar"/>
<classpathentry exported="true" kind="lib" path="WebContent/WEB-INF/lib/asm.jar"/>
<classpathentry exported="true" kind="lib" path="WebContent/WEB-INF/lib/cglib-2.1.3.jar"/>
<classpathentry exported="true" kind="lib" path="WebContent/WEB-INF/lib/commons-beanutils-1.8.2.jar"/>
<classpathentry exported="true" kind="lib" path="WebContent/WEB-INF/lib/commons-collections-3.1.jar"/>
<classpathentry exported="true" kind="lib" path="WebContent/WEB-INF/lib/commons-collections-3.2.1.jar"/>
<classpathentry exported="true" kind="lib" path="WebContent/WEB-INF/lib/commons-digester-2.1.jar"/>
<classpathentry exported="true" kind="lib" path="WebContent/WEB-INF/lib/commons-fileupload-1.2.2.jar"/>
<classpathentry exported="true" kind="lib" path="WebContent/WEB-INF/lib/commons-logging-1.0.4.jar"/>
<classpathentry exported="true" kind="lib" path="WebContent/WEB-INF/lib/commons-logging-1.1.jar"/>
<classpathentry exported="true" kind="lib" path="WebContent/WEB-INF/lib/commons-logging.jar"/>
<classpathentry exported="true" kind="lib" path="WebContent/WEB-INF/lib/DateConverter.jar"/>
<classpathentry exported="true" kind="lib" path="WebContent/WEB-INF/lib/dom4j-1.6.1.jar"/>
<classpathentry exported="true" kind="lib" path="WebContent/WEB-INF/lib/ejb3-persistence.jar"/>
<classpathentry exported="true" kind="lib" path="WebContent/WEB-INF/lib/freemarker-2.3.13.jar"/>
<classpathentry exported="true" kind="lib" path="WebContent/WEB-INF/lib/groovy-all-1.7.5.jar"/>
<classpathentry exported="true" kind="lib" path="WebContent/WEB-INF/lib/hibernate-annotations.jar"/>
<classpathentry exported="true" kind="lib" path="WebContent/WEB-INF/lib/hibernate-commons-annotations.jar"/>
<classpathentry exported="true" kind="lib" path="WebContent/WEB-INF/lib/hibernate-validator.jar"/>
<classpathentry exported="true" kind="lib" path="WebContent/WEB-INF/lib/hibernate3.jar"/>
<classpathentry exported="true" kind="lib" path="WebContent/WEB-INF/lib/hsqldb.jar"/>
<classpathentry exported="true" kind="lib" path="WebContent/WEB-INF/lib/imaging.jar"/>
<classpathentry exported="true" kind="lib" path="WebContent/WEB-INF/lib/iText-2.1.7.jar"/>
<classpathentry exported="true" kind="lib" path="WebContent/WEB-INF/lib/jasperreports-4.5.1.jar"/>
<classpathentry exported="true" kind="lib" path="WebContent/WEB-INF/lib/javassist-3.9.0.GA.jar"/>
<classpathentry exported="true" kind="lib" path="WebContent/WEB-INF/lib/jdt-compiler-3.1.1.jar"/>
<classpathentry exported="true" kind="lib" path="WebContent/WEB-INF/lib/jstl-1.2.jar"/>
<classpathentry exported="true" kind="lib" path="WebContent/WEB-INF/lib/jta-1.1.jar"/>
<classpathentry exported="true" kind="lib" path="WebContent/WEB-INF/lib/junit-3.8.1.jar"/>
<classpathentry exported="true" kind="lib" path="WebContent/WEB-INF/lib/log4j-1.2.15.jar"/>
<classpathentry exported="true" kind="lib" path="WebContent/WEB-INF/lib/ocrs12.jar"/>
<classpathentry exported="true" kind="lib" path="WebContent/WEB-INF/lib/ognl-2.6.11.jar"/>
<classpathentry exported="true" kind="lib" path="WebContent/WEB-INF/lib/orai18n.jar"/>
<classpathentry exported="true" kind="lib" path="WebContent/WEB-INF/lib/simplecaptcha-1.1.1.jar"/>
<classpathentry exported="true" kind="lib" path="WebContent/WEB-INF/lib/slf4j-api-1.5.8.jar"/>
<classpathentry exported="true" kind="lib" path="WebContent/WEB-INF/lib/slf4j-log4j12-1.5.8.jar"/>
<classpathentry exported="true" kind="lib" path="WebContent/WEB-INF/lib/sqljdbc4.jar"/>
<classpathentry exported="true" kind="lib" path="WebContent/WEB-INF/lib/standard.jar"/>
<classpathentry exported="true" kind="lib" path="WebContent/WEB-INF/lib/struts2-convention-plugin-2.1.6.jar"/>
<classpathentry exported="true" kind="lib" path="WebContent/WEB-INF/lib/struts2-core-2.1.6.jar"/>
<classpathentry exported="true" kind="lib" path="WebContent/WEB-INF/lib/struts2-fullhibernatecore-plugin-1.4-GA.jar"/>
<classpathentry exported="true" kind="lib" path="WebContent/WEB-INF/lib/xwork-2.1.2.jar"/>
<classpathentry exported="true" kind="con" path="org.eclipse.jdt.USER_LIBRARY/spring"/>
<classpathentry kind="output" path="WebContent/WEB-INF/classes"/>

4

3 に答える 3

1

org.springframework.web.context.ContextLoaderListener java.lang.ClassNotFoundException EclipseがアプリケーションをTomcatサーバーに修正しない場合にこの問題が発生することがよくあります(これは、1日で初めてEclipseを開始したとき、またはより大きなsvnチェックアウト後に頻繁に発生します)

私の場合、一連のアクションを実行するのに役立ちます(そして、前のステップが完了するまで、常に次のステップで待機します!!)

  • 最初にプロジェクトを更新し(F5)、次に
  • クリーンなプロジェクトビルド(プロジェクト/クリーン)があり、
  • プロジェクトを再度更新し(F5)、次に
  • サーバーをクリーンアップする
  • プロジェクトをサーバーに公開する
于 2013-02-03T12:18:54.510 に答える
0

自由にそうすることができるのであれば、Eclipseクラスパスを手動でいじる代わりにMavenを使用することをお勧めします。実行できる簡単な手順は次のとおりです。

mvn archetype:generate -DgroupId=com.test -DartifactId=test -DarchetypeArtifactId=maven-archetype-webapp -DinteractiveMode=false

これにより、必要なMavenプロジェクト構造が生成されます。次に、pom.xmlファイルを次のように編集します。

<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.test</groupId>
  <artifactId>test</artifactId>
  <packaging>war</packaging>
  <version>1.0-SNAPSHOT</version>
  <name>test Maven Webapp</name>
  <url>http://maven.apache.org</url>
  <repositories>
    <repository>
      <id>java.net</id>
      <url>http://download.java.net/maven/2/</url>
    </repository>
  </repositories>
  <dependencies>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-context</artifactId>
      <version>3.0.0.RELEASE</version>
      <scope>runtime</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.struts</groupId>
      <artifactId>struts2-core</artifactId>
      <version>2.1.8</version>
    </dependency>
    <dependency>
      <groupId>org.hibernate</groupId>
      <artifactId>hibernate</artifactId>
      <version>3.2.7.ga</version>
    </dependency>
    <dependency>
      <groupId>dom4j</groupId>
      <artifactId>dom4j</artifactId>
      <version>1.6.1</version>
    </dependency>
    <dependency>
      <groupId>commons-logging</groupId>
      <artifactId>commons-logging</artifactId>
      <version>1.1.1</version>
    </dependency>
    <dependency>
      <groupId>commons-collections</groupId>
      <artifactId>commons-collections</artifactId>
      <version>3.2.1</version>
    </dependency>
    <dependency>
      <groupId>cglib</groupId>
      <artifactId>cglib</artifactId>
      <version>2.2</version>
    </dependency>
    <dependency>
      <groupId>antlr</groupId>
      <artifactId>antlr</artifactId>
      <version>2.7.7</version>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
  <build>
    <finalName>test</finalName>
  </build>
</project>

プロジェクトをビルドします。

mvn clean package

そして、Eclipse構成ソースファイルを生成します。

mvn eclipse:eclipse -DdownloadSources=true

この手順は、ソースがアタッチされたクラスパスにライブラリが必要なプロジェクト構造を作成するのに十分です。

最後に、プロジェクトをEclipseにインポートできます。

File > Import > General > Existing project into Workspace > Select the project directory

mavenはhttp://maven.apache.org/download.cgiからダウンロードしてインストールできます。

于 2013-02-03T12:49:55.170 に答える
0

Webアプリを実行するためにEclipsewtpプラグインを使用しているのがわかります。次に、ファイルシステムで拡張Webアプリを見つけて、libディレクトリにspring.jarがあることを確認します。また、これを確認できます。私のアプリケーションにはContextLoaderListenerが表示されません。

于 2013-02-05T02:02:46.963 に答える