Eclipse STS Hibernate错误:“获取数据库的子项”。 org.slf4j.spi.LocationAwareLogger.log

时间:2013-04-04 17:44:29

标签: eclipse hibernate maven logging slf4j

我已经查看并尝试过处理SLF4J相关问题的各种解决方案但没有任何效果。我想要做的就是在STS中使用Hibernate插件。我只需单击Hibernate透视图,然后单击项目上的向下箭头和数据库上的向下箭头,就会发生此异常。

我在Hibernate控制台的属性中看到有一个Eclipse日志文件目录到了logback。我是否必须在我的pom中设置logback?

我在网上找到的eclipse教程中使用了我的设置。唯一的区别是我使用的是特定的STS版本和更新版本的Spring和Hibernate。我已经设置了hibernate conifig和console config。

任何有助于使用Maven进行日志记录的Hibernate插件正常工作的帮助将非常感激。在此先感谢!!

以下是我的设置:

STS v3.2,MySQL DB,vFabric Server(自带STS),使用Maven

POM版本:

    <java-version>1.6</java-version>
    <spring.version>3.2.2.RELEASE</spring.version>
    <spring.security.version>3.1.3.RELEASE</spring.security.version>
    <org.aspectj-version>1.6.10</org.aspectj-version>
    <org.slf4j-version>1.7.2</org.slf4j-version>
    <org.apache.tiles>2.2.2</org.apache.tiles>      
    <mysql>5.1.24</mysql>               
    <hibernate.version>4.1.5.Final</hibernate.version>
    <junit.version>4.11</junit.version>

Spring,Hibernate&amp;记录部分:

    <!-- Spring -->
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>${spring.version}</version>
        <exclusions>
            <!-- Exclude Commons Logging in favor of SLF4j -->
            <exclusion>
                <groupId>commons-logging</groupId>
                <artifactId>commons-logging</artifactId>
             </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>${spring.version}</version>
    </dependency>

    <!-- Hibernate -->
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-core</artifactId>
        <version>${hibernate.version}</version>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-entitymanager</artifactId>
        <version>${hibernate.version}</version>
    </dependency>               
   <!-- Saw this fix online and was trying - doesn't work, temp commented out
   <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-validator</artifactId>           
        <version>4.3.1.Final</version>
        <exclusions>
            Exclude SLF4j to avoid version conflicts (we have 1.6.2, this drags in 1.6.1)
            <exclusion>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-api</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.hibernate.common</groupId>
        <artifactId>hibernate-commons-annotations</artifactId>
        <version>4.0.1.Final</version>
        <classifier>tests</classifier>
    </dependency>
    <dependency>
        <groupId>org.hibernate.javax.persistence</groupId>
        <artifactId>hibernate-jpa-2.0-api</artifactId>
        <version>1.0.1.Final</version>
    </dependency> 
    END Saw this fix online and was trying - doesn't work, temp commented out -->

    <dependency>
        <groupId>javax.validation</groupId>
        <artifactId>validation-api</artifactId>
        <version>1.0.0.GA</version>
        <scope>provided</scope>
    </dependency>     


<!-- Logging -->        
    <dependency>
        <groupId>org.jboss.logging</groupId>
        <artifactId>jboss-logging</artifactId>
        <version>3.1.0.CR2</version>
    </dependency>       
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>${org.slf4j-version}</version>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>jcl-over-slf4j</artifactId>
        <version>${org.slf4j-version}</version>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-log4j12</artifactId>
        <version>${org.slf4j-version}</version>
    </dependency>
    <dependency>
        <groupId>log4j</groupId>
        <artifactId>log4j</artifactId>
        <version>1.2.16</version>
    </dependency>

下面是堆栈跟踪:

java.lang.NoSuchMethodError: org.slf4j.spi.LocationAwareLogger.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;[Ljava/lang/Object;Ljava/lang/Throwable;)V
    at org.apache.commons.logging.impl.SLF4JLocationAwareLog.debug(SLF4JLocationAwareLog.java:133)
    at org.hibernate.cfg.reveng.dialect.JDBCMetaDataDialect.getTables(JDBCMetaDataDialect.java:26)
    at org.hibernate.cfg.reveng.JDBCReader.processTables(JDBCReader.java:476)
    at org.hibernate.cfg.reveng.JDBCReader.readDatabaseSchema(JDBCReader.java:74)
    at org.hibernate.eclipse.console.workbench.LazyDatabaseSchemaWorkbenchAdapter$2.execute(LazyDatabaseSchemaWorkbenchAdapter.java:126)
    at org.hibernate.console.execution.DefaultExecutionContext.execute(DefaultExecutionContext.java:63)
    at org.hibernate.console.ConsoleConfiguration.execute(ConsoleConfiguration.java:107)
    at org.hibernate.eclipse.console.workbench.LazyDatabaseSchemaWorkbenchAdapter.readDatabaseSchema(LazyDatabaseSchemaWorkbenchAdapter.java:115)
    at org.hibernate.eclipse.console.workbench.LazyDatabaseSchemaWorkbenchAdapter.getChildren(LazyDatabaseSchemaWorkbenchAdapter.java:65)
    at org.hibernate.eclipse.console.workbench.BasicWorkbenchAdapter.fetchDeferredChildren(BasicWorkbenchAdapter.java:106)
    at org.eclipse.ui.progress.DeferredTreeContentManager$1.run(DeferredTreeContentManager.java:235)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)

谢谢!实际上我最终只是记录了几分钟的记录,而我让Hibernate的工具做了它的事情。根据这篇文章论坛.hibernate.org/viewtopic.php?p = 2441023然后我读完了它们,一切都很好! :D -

1 个答案:

答案 0 :(得分:1)

具有6个参数的NoSuchMethodError on LocationAwareLogger.log()方法是类路径上1.6之前版本的slf4j绑定的症状。 'mvn依赖:树'应该表明同样多,即你有一个较旧的绑定,比如说slf4j-log4j-1.5.jar