JBoss EAP 5.1.2 上的 Hibernate4 日志错误 [英] Hibernate4 on JBoss EAP 5.1.2 logging error

查看:26
本文介绍了JBoss EAP 5.1.2 上的 Hibernate4 日志错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望之前有人遇到过这个问题并且可以提供建议.我正在编写一个关于 Hibernate 4 和 Spring 3 的应用程序.这是我的依赖树:

I'm hoping that maybe someone has run into this problem before and can provide advice. I'm writing an application on Hibernate 4 and Spring 3. Here's my dependency tree:

+- javax.servlet:servlet-api:jar:2.5:provided
+- org.springframework:spring-webmvc:jar:3.1.3.RELEASE:compile
|  +- org.springframework:spring-asm:jar:3.1.3.RELEASE:compile
|  +- org.springframework:spring-beans:jar:3.1.3.RELEASE:compile
|  +- org.springframework:spring-context:jar:3.1.3.RELEASE:compile
|  +- org.springframework:spring-context-support:jar:3.1.3.RELEASE:compile
|  +- org.springframework:spring-core:jar:3.1.3.RELEASE:compile
|  +- org.springframework:spring-expression:jar:3.1.3.RELEASE:compile
|  - org.springframework:spring-web:jar:3.1.3.RELEASE:compile
+- org.springframework:spring-orm:jar:3.1.3.RELEASE:compile
+- org.springframework:spring-jdbc:jar:3.1.3.RELEASE:compile
+- org.springframework:spring-tx:jar:3.1.3.RELEASE:compile
|  +- aopalliance:aopalliance:jar:1.0:compile
|  - org.springframework:spring-aop:jar:3.1.3.RELEASE:compile
+- org.springframework.security:spring-security-core:jar:3.1.3.RELEASE:compile
+- org.springframework.security:spring-security-web:jar:3.1.3.RELEASE:compile
+- org.springframework.security:spring-security-config:jar:3.1.3.RELEASE:compile
+- org.hibernate.javax.persistence:hibernate-jpa-2.0-api:jar:1.0.1.Final:compile
+- org.hibernate:hibernate-core:jar:4.1.8.Final:compile
|  +- antlr:antlr:jar:2.7.7:compile
|  +- org.jboss.logging:jboss-logging:jar:3.1.0.GA:compile
|  +- org.jboss.spec.javax.transaction:jboss-transaction-api_1.1_spec:jar:1.0.0.Final:compile
|  +- dom4j:dom4j:jar:1.6.1:compile
|  +- org.javassist:javassist:jar:3.15.0-GA:compile
|  - org.hibernate.common:hibernate-commons-annotations:jar:4.0.1.Final:compile
+- org.hibernate:hibernate-entitymanager:jar:4.1.8.Final:compile
+- org.hibernate:hibernate-validator:jar:4.3.0.Final:compile
+- javax.validation:validation-api:jar:1.0.0.GA:compile
+- commons-lang:commons-lang:jar:2.4:compile
+- commons-beanutils:commons-beanutils:jar:1.8.3:compile
+- commons-beanutils:commons-beanutils-core:jar:1.8.3:compile
+- commons-beanutils:commons-beanutils-bean-collections:jar:1.8.3:compile
+- commons-logging:commons-logging:jar:1.1.1:compile
+- org.aspectj:aspectjrt:jar:1.7.1:compile
+- org.aspectj:aspectjweaver:jar:1.7.1:compile
+- log4j:log4j:jar:1.2.17:compile
+- javax.servlet:jstl:jar:1.2:compile
+- cglib:cglib:jar:2.2.2:compile
|  - asm:asm:jar:3.3.1:compile
+- org.slf4j:slf4j-log4j12:jar:1.7.2:compile
+- org.slf4j:slf4j-api:jar:1.7.2:compile
+- junit:junit:jar:4.10:compile
|  - org.hamcrest:hamcrest-core:jar:1.1:compile
+- org.dbunit:dbunit:jar:2.4.9:test
|  - commons-collections:commons-collections:jar:3.2.1:test
+- org.apache.derby:derby:jar:10.9.1.0:compile
+- org.springframework:spring-test:jar:3.1.3.RELEASE:test
+- org.seleniumhq.selenium:selenium-java:jar:2.26.0:test
|  +- org.seleniumhq.selenium:selenium-android-driver:jar:2.26.0:test
|  - org.seleniumhq.selenium:selenium-remote-driver:jar:2.26.0:test
|  |     +- cglib:cglib-nodep:jar:2.1_3:test
|  |     +- org.json:json:jar:20080701:test
|  |     - com.google.guava:guava:jar:13.0.1:test
|  +- org.seleniumhq.selenium:selenium-chrome-driver:jar:2.26.0:test
|  +- org.seleniumhq.selenium:selenium-htmlunit-driver:jar:2.26.0:test
|  |  +- org.seleniumhq.selenium:selenium-api:jar:2.26.0:test
|  |  +- net.sourceforge.htmlunit:htmlunit:jar:2.10:test
|  |  |  +- xalan:xalan:jar:2.7.1:test
|  |  |  |  - xalan:serializer:jar:2.7.1:test
|  |  |  +- org.apache.commons:commons-lang3:jar:3.1:test
|  |  |  +- org.apache.httpcomponents:httpmime:jar:4.2.1:test
|  |  |  +- commons-codec:commons-codec:jar:1.6:test
|  |  |  +- net.sourceforge.htmlunit:htmlunit-core-js:jar:2.10:test
|  |  |  +- xerces:xercesImpl:jar:2.9.1:test
|  |  |  |  - xml-apis:xml-apis:jar:1.3.04:test
|  |  |  +- net.sourceforge.nekohtml:nekohtml:jar:1.9.16:test
|  |  |  - net.sourceforge.cssparser:cssparser:jar:0.9.7:test
|  |  |     - org.w3c.css:sac:jar:1.3:test
|  |  - org.apache.httpcomponents:httpclient:jar:4.2.1:test
|  |     - org.apache.httpcomponents:httpcore:jar:4.2.1:test
|  +- org.seleniumhq.selenium:selenium-firefox-driver:jar:2.26.0:test
|  |  +- commons-io:commons-io:jar:2.2:test
|  |  - org.apache.commons:commons-exec:jar:1.1:test
|  +- org.seleniumhq.selenium:selenium-ie-driver:jar:2.26.0:test
|  |  +- net.java.dev.jna:jna:jar:3.4.0:test
|  |  - net.java.dev.jna:platform:jar:3.4.0:test
|  +- org.seleniumhq.selenium:selenium-iphone-driver:jar:2.26.0:test
|  +- org.seleniumhq.selenium:selenium-safari-driver:jar:2.26.0:test
|  +- org.seleniumhq.selenium:selenium-support:jar:2.26.0:test
|  - org.webbitserver:webbit:jar:0.4.14:test
|     - io.netty:netty:jar:3.5.2.Final:test

问题是 Hibernate 对 jboss-logging.jar 的依赖.当我将其部署到 JBoss 5.1.2 Enterprise Server 时,出现以下错误:

The problem is the Hibernate dependency on the jboss-logging.jar. When I deploy this to the JBoss 5.1.2 Enterprise Server, I get the following error:

上下文初始化失败org.springframework.beans.factory.BeanCreationException:在 ServletContext 资源 [/WEB-INF/classes/spring/servlet-context.xml] 中定义名称为org.springframework.validation.beanvalidation.MethodValidationPostProcessor#0"的 bean 创建时出错:无法在设置 bean 属性 'validator' 时解析对 bean 'validator' 的引用;嵌套异常是 org.springframework.beans.factory.BeanCreationException:在 ServletContext 资源 [/WEB-INF/classes/spring/application-context.xml] 中定义的名称为validator"的 bean 创建时出错:设置属性值时出错;嵌套异常是 org.springframework.beans.PropertyBatchUpdateException;嵌套的 PropertyAccessExceptions (1) 是:PropertyAccessException 1:org.springframework.beans.MethodInvocationException:属性validationMessageSource"抛出异常;嵌套异常是 java.lang.NoSuchMethodError: org.jboss.logmanager.LogContext.getAttachment(Ljava/lang/String;Lorg/jboss/logmanager/Logger$AttachmentKeyLjava/lang/Object;在 org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:329)

显然与 jboss-logging.jar 和 EAP 服务器存在一些不兼容.我尝试从 Hibernate 依赖项中排除那个 jar,但后来我遇到了这个错误:

There is clearly some incompatibility with jboss-logging.jar and the EAP server. I tried excluding that jar from the Hibernate dependency, but then I run into this error:

引起:java.lang.ClassNotFoundException:org.jboss.logging.BasicLogger在 java.net.URLClassLoader$1.run(URLClassLoader.java:202)在 java.security.AccessController.doPrivileged(Native Method)在 java.net.URLClassLoader.findClass(URLClassLoader.java:190)在 java.lang.ClassLoader.loadClass(ClassLoader.java:306)在 sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)在 java.lang.ClassLoader.loadClass(ClassLoader.java:247)在 java.lang.Class.forName0(Native Method)在 java.lang.Class.forName(Class.java:247)在 org.jboss.classloader.spi.base.BaseClassLoaderDomain.loadClass(BaseClassLoaderDomain.java:311)在 org.jboss.classloader.spi.base.BaseClassLoaderDomain.loadClass(BaseClassLoaderDomain.java:1163)在 org.jboss.classloader.spi.base.BaseClassLoader.loadClassFromDomain(BaseClassLoader.java:862)在 org.jboss.classloader.spi.base.BaseClassLoader.doLoadClass(BaseClassLoader.java:502)在 org.jboss.classloader.spi.base.BaseClassLoader.loadClass(BaseClassLoader.java:447)在 java.lang.ClassLoader.loadClass(ClassLoader.java:247)

我没有找到太多告诉我如何解决这个依赖问题的信息,所以我希望有人知道如何去做.

I'm not finding much that tells me how to get around this dependency issue, so I'm hoping someone knows how to do it.

谢谢!

推荐答案

好吧,在与同事结对时,我们找到了解决我们在 JBoss 和 Hibernate 4 中看到的问题的方法.如果我们明确告诉 JBossEAP 我们的日志实现(-D org.jboss.logging.provider=slf4j),它不扫描日志实现,也没有我看到的 NoSuchMethod 异常.因此,除了设置一项系统属性外,我们无需进行任何其他更改.

Well, while pairing with a co-worker, we found a workaround for the issue we were seeing with JBoss and Hibernate 4. Turns out if we explicitly tell JBoss EAP our logging implementation (-D org.jboss.logging.provider=slf4j), it doesn’t do the scanning for the logging implementation and doesn’t have the NoSuchMethod exception that I was seeing. Thus, we don’t have to make any other changes other than setting one system property.

这篇关于JBoss EAP 5.1.2 上的 Hibernate4 日志错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆