简体   繁体   English

java.lang.NoClassDefFoundError:org / slf4j / impl / StaticLoggerBinder

[英]java.lang.NoClassDefFoundError: org/slf4j/impl/StaticLoggerBinder

We're trying to initialize a hibernate database in our Vaadin-project but it throws the following error. 我们正在尝试在Vaadin项目中初始化一个休眠数据库,但会引发以下错误。 We've been searching for several days, but no solution has worked so far and we are out of ideas. 我们已经搜索了几天,但是到目前为止,没有任何解决方案有效,并且我们没有想法。 Hope anybody can help. 希望任何人都能提供帮助。 We are using NetBeans. 我们正在使用NetBeans。

Schwerwiegend:   SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
Schwerwiegend:   SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Schwerwiegend:   java.lang.NoClassDefFoundError: org/slf4j/impl/StaticLoggerBinder
    at org.slf4j.LoggerFactory.getSingleton(LoggerFactory.java:223)
    at org.slf4j.LoggerFactory.bind(LoggerFactory.java:120)
    at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:111)
    at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:269)
    at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:242)
    at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:255)
    at org.hibernate.cfg.Configuration.<clinit>(Configuration.java:163)

Our automatically generated pom.xml 我们自动生成的pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<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.mycompany</groupId>
<artifactId>DirectFeedback</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>DirectFeedback</name>

<properties>
    <vaadin.version>7.5.8</vaadin.version>
    <vaadin.plugin.version>${vaadin.version}</vaadin.plugin.version>
    <jetty.plugin.version>9.2.3.v20140905</jetty.plugin.version>
    <project.source.version>1.7</project.source.version>
    <project.target.version>1.7</project.target.version>
    <project.encoding>UTF-8</project.encoding>
</properties>

<repositories>
    <repository>
        <id>vaadin-addons</id>
        <url>http://maven.vaadin.com/vaadin-addons</url>
    </repository>
    <repository>
        <id>vaadin-snapshots</id>
        <url>https://oss.sonatype.org/content/repositories/vaadin-snapshots/</url>
        <releases>
            <enabled>false</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </repository>
</repositories>

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>com.vaadin</groupId>
            <artifactId>vaadin-bom</artifactId>
            <version>${vaadin.version}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

<dependencies>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>javax.servlet-api</artifactId>
        <version>3.0.1</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>com.vaadin</groupId>
        <artifactId>vaadin-server</artifactId>
    </dependency>
    <dependency>
        <groupId>com.vaadin</groupId>
        <artifactId>vaadin-push</artifactId>
    </dependency>
    <dependency>
        <groupId>com.vaadin</groupId>
        <artifactId>vaadin-client</artifactId>
        <scope>provided</scope>
    </dependency>
    <!--
      Needed when using the widgetset optimizer (custom ConnectorBundleLoaderFactory).

      For widgetset compilation, vaadin-client-compiler is automatically added on the
      compilation classpath by vaadin-maven-plugin so normally there is no need for an
      explicit dependency.
    -->
    <!--
    <dependency>
        <groupId>com.vaadin</groupId>
        <artifactId>vaadin-client-compiler</artifactId>
        <scope>provided</scope>
    </dependency>
    -->
    <dependency>
        <groupId>com.vaadin</groupId>
        <artifactId>vaadin-themes</artifactId>
    </dependency>
 <dependency>
  <groupId>com.github.livesense</groupId>
  <artifactId>org.liveSense.misc.javax.persistence</artifactId>
  <version>1.0.5</version>
 </dependency>
 <dependency>
  <groupId>org.hibernate</groupId>
  <artifactId>hibernate-maven-plugin</artifactId>
  <version>3.3.2.GA</version>
  <exclusions>
   <exclusion>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-api</artifactId>
   </exclusion>
  </exclusions>
 </dependency>
 <dependency>
  <groupId>org.hibernate</groupId>
  <artifactId>hibernate-core</artifactId>
  <version>3.5.0.Beta-1</version>
  <type>jar</type>
  <exclusions>
   <exclusion>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-api</artifactId>
   </exclusion>
  </exclusions>
 </dependency>
 <dependency>
  <groupId>ch.qos.logback</groupId>
  <artifactId>logback-classic</artifactId>
  <version>1.1.3</version>
  <exclusions>
   <exclusion>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-api</artifactId>
   </exclusion>
  </exclusions>
 </dependency>
     <dependency>
     <groupId>org.slf4j </groupId>
     <artifactId>slf4j-log4j12</artifactId>
     <version>1.5.8</version>
     </dependency>
 <dependency>
  <groupId>org.slf4j</groupId>
  <artifactId>slf4j-jdk14</artifactId>
  <version>1.7.13</version>
  <exclusions>
   <exclusion>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-api</artifactId>
   </exclusion>
  </exclusions>
 </dependency>
 <dependency>
  <groupId>org.slf4j</groupId>
  <artifactId>slf4j-log4j12</artifactId>
  <version>1.5.8</version>
  <exclusions>
   <exclusion>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-api</artifactId>
   </exclusion>
  </exclusions>
 </dependency>
</dependencies>

I've seen problem in your .pom file. 我在您的.pom文件中看到了问题。 " maven install " fails with your .pom file, but after the updates below, " maven install " works fine; 您的.pom文件无法执行“ maven install ”,但是在下面的更新之后,“ maven install ”可以正常工作;

Just remove the dependency below, maven install is failed with this one; 只需删除下面的依赖项, maven install因此失败;

    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-jdk14</artifactId>
        <version>1.7.13</version>
        <exclusions>
            <exclusion>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-api</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

Simply, update your .pom file (or copy/paste the updated .pom just down below) and then, run maven clean and maven install on the project directory via command line. 简单地说,更新您的.pom文件(或复制/粘贴更新.pom只是向下跌破),然后运行maven cleanmaven install上通过命令行的项目目录。

I've just run your pom file without the dependency slf4j-api with version 1.7.13 and maven install successfully worked [ BUILD SUCCESS ] 我刚刚运行了1.7.13版不带依赖项slf4j-api的 pom文件,并且maven install成功运行[ 构建成功 ]

<?xml version="1.0" encoding="UTF-8"?>
<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.mycompany</groupId>
    <artifactId>DirectFeedback</artifactId>
    <packaging>war</packaging>
    <version>1.0-SNAPSHOT</version>
    <name>DirectFeedback</name>
    <url>http://maven.apache.org</url>

    <properties>
        <vaadin.version>7.5.8</vaadin.version>
        <vaadin.plugin.version>${vaadin.version}</vaadin.plugin.version>
        <jetty.plugin.version>9.2.3.v20140905</jetty.plugin.version>
        <project.source.version>1.7</project.source.version>
        <project.target.version>1.7</project.target.version>
        <project.encoding>UTF-8</project.encoding>
    </properties>

    <repositories>
        <repository>
            <id>vaadin-addons</id>
            <url>http://maven.vaadin.com/vaadin-addons</url>
        </repository>
        <repository>
            <id>vaadin-snapshots</id>
            <url>https://oss.sonatype.org/content/repositories/vaadin-snapshots/</url>
            <releases>
                <enabled>false</enabled>
            </releases>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>
    </repositories>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>com.vaadin</groupId>
                <artifactId>vaadin-bom</artifactId>
                <version>${vaadin.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>3.0.1</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.vaadin</groupId>
            <artifactId>vaadin-server</artifactId>
        </dependency>
        <dependency>
            <groupId>com.vaadin</groupId>
            <artifactId>vaadin-push</artifactId>
        </dependency>
        <dependency>
            <groupId>com.vaadin</groupId>
            <artifactId>vaadin-client</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>com.vaadin</groupId>
            <artifactId>vaadin-themes</artifactId>
        </dependency>
        <dependency>
            <groupId>com.github.livesense</groupId>
            <artifactId>org.liveSense.misc.javax.persistence</artifactId>
            <version>1.0.5</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-maven-plugin</artifactId>
            <version>3.3.2.GA</version>
            <exclusions>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>slf4j-api</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>3.5.0.Beta-1</version>
            <type>jar</type>
            <exclusions>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>slf4j-api</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
            <version>1.1.3</version>
            <exclusions>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>slf4j-api</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.slf4j </groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>1.5.8</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>1.5.8</version>
            <exclusions>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>slf4j-api</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
    </dependencies>

</project>

In my case I got the same exception but the cause was totally different. 就我而言,我有同样的例外,但原因完全不同。

I was loading all the dependencies with the latest version ie 1.3.0-alpha4 . 我正在使用最新版本1.3.0-alpha4加载所有依赖项。 In my case had to to use older version to 1.2.3 . 以我为例,必须使用1.2.3之前的版本。

Below is the working dependence for me - 以下是我的工作依赖-

<dependency>
    <groupId>ch.qos.logback</groupId>
    <artifactId>logback-classic</artifactId>
    <version>1.2.3</version>
    <scope>test</scope>
</dependency>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 嵌套的异常是java.lang.NoClassDefFoundError:org / slf4j / impl / StaticLoggerBinder - nested exception is java.lang.NoClassDefFoundError: org/slf4j/impl/StaticLoggerBinder springboot2.7.5启动报错 Caused by: java.lang.NoClassDefFoundError: org/slf4j/impl/StaticLoggerBinder - springboot2.7.5 start error Caused by: java.lang.NoClassDefFoundError: org/slf4j/impl/StaticLoggerBinder NoClassDefFoundError: org/slf4j/impl/StaticLoggerBinder - NoClassDefFoundError: org/slf4j/impl/StaticLoggerBinder 嵌套的异常是java.lang.NoClassDefFoundError:org / slf4j / impl / MessageFormatter - nested exception is java.lang.NoClassDefFoundError: org/slf4j/impl/MessageFormatter 线程“ main”中的异常java.lang.NoSuchMethodError:org.slf4j.impl.StaticLoggerBinder.getSingleton()Lorg / slf4j / impl / StaticLoggerBinder - Exception in thread “main” java.lang.NoSuchMethodError: org.slf4j.impl.StaticLoggerBinder.getSingleton()Lorg/slf4j/impl/StaticLoggerBinder 休眠-java.lang.NoClassDefFoundError:org / slf4j / LoggerFactory - Hibernate - java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory java.lang.NoClassDefFoundError:org / slf4j / Logger - java.lang.NoClassDefFoundError: org/slf4j/Logger java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory 问题 - java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory problem java.lang.NoClassDefFoundError: OSGi 中的 org/slf4j/LoggerFactory - java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory in OSGi 带有 Logback 的 SLF4J:NoClassDefFoundError:org/slf4j/impl/StaticLoggerBinder - SLF4J with Logback: NoClassDefFoundError: org/slf4j/impl/StaticLoggerBinder
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM