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
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:
Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.validation.beanvalidation.MethodValidationPostProcessor#0' defined in ServletContext resource [/WEB-INF/classes/spring/servlet-context.xml]: Cannot resolve reference to bean 'validator' while setting bean property 'validator'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'validator' defined in ServletContext resource [/WEB-INF/classes/spring/application-context.xml]: Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'validationMessageSource' threw exception; nested exception is java.lang.NoSuchMethodError: org.jboss.logmanager.LogContext.getAttachment(Ljava/lang/String;Lorg/jboss/logmanager/Logger$AttachmentKeyLjava/lang/Object;
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:329)
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:
Caused by: java.lang.ClassNotFoundException: org.jboss.logging.BasicLogger
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
at org.jboss.classloader.spi.base.BaseClassLoaderDomain.loadClass(BaseClassLoaderDomain.java:311)
at org.jboss.classloader.spi.base.BaseClassLoaderDomain.loadClass(BaseClassLoaderDomain.java:1163)
at org.jboss.classloader.spi.base.BaseClassLoader.loadClassFromDomain(BaseClassLoader.java:862)
at org.jboss.classloader.spi.base.BaseClassLoader.doLoadClass(BaseClassLoader.java:502)
at org.jboss.classloader.spi.base.BaseClassLoader.loadClass(BaseClassLoader.java:447)
at 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.
Thanks!
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With