【问题标题】:Why do I get FileNotFoundException with slf4j-api-1.6.1.jar?为什么我会使用 slf4j-api-1.6.1.jar 获得 FileNotFoundException?
【发布时间】:2018-09-21 20:35:14
【问题描述】:

我是 spring 和 maven 新手,我无法让我的项目正常运行...我开始使用 webapp 原型创建一个新的 Maven 项目,并让它正常运行,即使有一些 spring 安全性。但是现在我在 maven 中包含了休眠依赖项,无论我是保留它们还是从 pom.xml 中删除它们,我都会得到:

HTTP 状态 500 – 内部服务器错误

Type Exception Report

Message javax.servlet.ServletException: java.lang.IllegalStateException: java.io.FileNotFoundException: C:\eclipse-workspace3\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\prueba6\WEB-INF\lib\slf4j-api-1.6.1.jar (The system cannot find the file specified)

Description The server encountered an unexpected condition that prevented it from fulfilling the request.

我在控制台收到以下错误:

Sep 21, 2018 5:22:08 PM org.apache.catalina.core.StandardContext backgroundProcess
WARNING: Exception processing loader [WebappLoader[StandardEngine[Catalina].StandardHost[localhost].StandardContext[/prueba6]]] background process
java.lang.IllegalStateException: java.io.FileNotFoundException: C:\eclipse-workspace3\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\prueba6\WEB-INF\lib\slf4j-api-1.6.1.jar (The system cannot find the file specified)
    at org.apache.catalina.webresources.AbstractSingleArchiveResourceSet.getArchiveEntry(AbstractSingleArchiveResourceSet.java:101)
    at org.apache.catalina.webresources.AbstractArchiveResourceSet.getResource(AbstractArchiveResourceSet.java:256)
    at org.apache.catalina.webresources.StandardRoot.getResourceInternal(StandardRoot.java:281)
    at org.apache.catalina.webresources.Cache.getResource(Cache.java:62)
    at org.apache.catalina.webresources.StandardRoot.getResource(StandardRoot.java:216)
    at org.apache.catalina.webresources.StandardRoot.getClassLoaderResource(StandardRoot.java:225)
    at org.apache.catalina.loader.WebappClassLoaderBase.modified(WebappClassLoaderBase.java:708)
    at org.apache.catalina.loader.WebappLoader.modified(WebappLoader.java:343)
    at org.apache.catalina.loader.WebappLoader.backgroundProcess(WebappLoader.java:287)
    at org.apache.catalina.core.StandardContext.backgroundProcess(StandardContext.java:5465)
    at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1396)
    at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1400)
    at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1400)
    at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1368)
    at java.lang.Thread.run(Unknown Source)
Caused by: java.io.FileNotFoundException: C:\eclipse-workspace3\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\prueba6\WEB-INF\lib\slf4j-api-1.6.1.jar (The system cannot find the file specified)
    at java.util.zip.ZipFile.open(Native Method)
    at java.util.zip.ZipFile.<init>(Unknown Source)
    at java.util.zip.ZipFile.<init>(Unknown Source)
    at java.util.jar.JarFile.<init>(Unknown Source)
    at java.util.jar.JarFile.<init>(Unknown Source)
    at org.apache.tomcat.util.compat.JreCompat.jarFileNewInstance(JreCompat.java:164)
    at org.apache.tomcat.util.compat.JreCompat.jarFileNewInstance(JreCompat.java:149)
    at org.apache.catalina.webresources.AbstractArchiveResourceSet.openJarFile(AbstractArchiveResourceSet.java:307)
    at org.apache.catalina.webresources.AbstractSingleArchiveResourceSet.getArchiveEntry(AbstractSingleArchiveResourceSet.java:97)
    ... 14 more

我的 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/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.luv2code</groupId>
    <artifactId>spring-security-demo</artifactId>
    <version>1.0</version>
    <packaging>war</packaging>

    <name>spring-security-demo</name>

    <properties>
        <springframework.version>5.0.2.RELEASE</springframework.version>

        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
    </properties>

    <dependencies>

        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-web</artifactId>
            <version>5.1.0.RELEASE</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-config</artifactId>
            <version>5.1.0.RELEASE</version>
        </dependency>

        <!-- Spring MVC support -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>${springframework.version}</version>
        </dependency>

        <!-- Servlet, JSP and JSTL support -->
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>3.1.0</version>
        </dependency>

        <dependency>
            <groupId>javax.servlet.jsp</groupId>
            <artifactId>javax.servlet.jsp-api</artifactId>
            <version>2.3.1</version>
        </dependency>

        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
        </dependency>

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
            <scope>test</scope>
        </dependency>


    </dependencies>



</project>

我已经尝试在 pom.xml 中包含具有给定版本的 slf4j 依赖项,但没有成功。我读到有时某些依赖项使用不同的 slf4j 版本会发生冲突,但我不知道如何检查! :( 我想我犯了一个与休眠无关的错误,但我无法找出在哪里......

【问题讨论】:

  • 尝试在Package Explorer窗格中选择项目,右键单击,刷新。
  • 没用。
  • 看起来你需要 .jar 文件,你可以get it here。另外,检查您的项目中是否已经有 org.slf4j.jar
  • 嗯,你为什么要从 Eclipse 依赖项中导入任何东西?
  • mvn clean package

标签: java spring hibernate maven


【解决方案1】:

这些步骤对我有用: - 停止 Tomcat。 - 右键单击​​ Tomcat /Clean。 - 右键单击​​ Tomcat /Clean Tomcat 工作目录。 - 将 .war 添加到 Tomcat 并启动它。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-12-16
    • 1970-01-01
    • 1970-01-01
    • 2020-05-28
    • 1970-01-01
    • 1970-01-01
    • 2011-12-09
    • 2019-12-25
    相关资源
    最近更新 更多