JBoss AS 7迁移 - java.lang.ClassNotFoundException:org.hibernate.validator.ClassValidator

问题描述:

我有一个运行在JBoss AS 4.2.3上的应用程序,并试图将它迁移到JBoss AS 7.0.2。我也将接缝从2.1.1升级到2.2.2。我已经解决了几个没有发现异常之类的,但我被困在JBoss AS 7迁移 - java.lang.ClassNotFoundException:org.hibernate.validator.ClassValidator

java.lang.ClassNotFoundException: org.hibernate.validator.ClassValidator

我的完整的堆栈跟踪如下。

我不是很清楚AS 7中的新类加载器.Hibernate 4是否可以与seam 2.2.2一起工作?我试过在jboss-deployment-structure.xml中指定导出来使用org.hibernate和org.hibernate.validator。然而,当我在这些位置的罐子里看,我没有看到ClassValidator类...

我也尝试添加休眠3罐到EAR/lib并在清单中指定它们,但不改变一切。我看到hibernate 3 hibernate-validator.jar确实包含classValidator类,但它仍然没有找到它。

UPDATE我也尝试休眠 - 验证 - 传统 - 4.0.2.GA.jar

hibernate-annotations-3.4.0.GA.jar 
hibernate-commons-annotations-3.1.0.GA.jar 
hibernate-core-3.3.0.SP1.jar 
hibernate-validator-3.1.0.GA.jar 
14:16:07,776 INFO [org.jboss.seam.Component] (MSC service thread 1-2) Component: Test, scope: EVENT, type: JAVA_BEAN, class: com.test.Test 
14:16:07,789 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/oneSourceUI]] (MSC service thread 1-2) Exception sending context initialized event to listener instance of class org.jboss.seam.servlet.SeamListener: java.lang.RuntimeException: Could not create Component: Test 
    at org.jboss.seam.init.Initialization.addComponent(Initialization.java:1202) [jboss-seam.jar:] 
    at org.jboss.seam.init.Initialization.installComponents(Initialization.java:1118) [jboss-seam.jar:] 
    at org.jboss.seam.init.Initialization.init(Initialization.java:737) [jboss-seam.jar:] 
    at org.jboss.seam.servlet.SeamListener.contextInitialized(SeamListener.java:36) [jboss-seam.jar:] 
    at org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:3368) [jbossweb-7.0.1.Final.jar:7.0.2.Final] 
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:3821) [jbossweb-7.0.1.Final.jar:7.0.2.Final] 
    at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:70) [jboss-as-web-7.0.2.Final.jar:7.0.2.Final] 
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1824) 
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1759) 
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) [:1.7.0_01] 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [:1.7.0_01] 
    at java.lang.Thread.run(Thread.java:722) [:1.7.0_01] 
Caused by: java.lang.NoClassDefFoundError: org/hibernate/validator/ClassValidator 
    at java.lang.Class.getDeclaredMethods0(Native Method) [:1.7.0_01] 
    at java.lang.Class.privateGetDeclaredMethods(Class.java:2442) [:1.7.0_01] 
    at java.lang.Class.getDeclaredMethods(Class.java:1808) [:1.7.0_01] 
    at org.jboss.seam.Component.initMembers(Component.java:553) [jboss-seam.jar:] 
    at org.jboss.seam.Component.(Component.java:247) [jboss-seam.jar:] 
    at org.jboss.seam.Component.(Component.java:208) [jboss-seam.jar:] 
    at org.jboss.seam.init.Initialization.addComponent(Initialization.java:1186) [jboss-seam.jar:] 
    ... 11 more 
Caused by: java.lang.ClassNotFoundException: org.hibernate.validator.ClassValidator from [Module "deployment.test-ear.ear.jboss-seam.jar:main" from Service Module Loader] 
    at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:191) 
    at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:361) 
    at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:333) 
    at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:310) 
    at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:103) 
    ... 18 more 

14:16:07,798 INFO [javax.enterprise.resource.webcontainer.jsf.config] (MSC service thread 1-2) Initializing Mojarra (1.2_15-20110809-SNAPSHOT) for context '/test 
14:16:07,828 SEVERE [javax.enterprise.resource.webcontainer.jsf.application] (MSC service thread 1-2) JSF1051: Service entry 'org.jboss.as.web.deployment.jsf.JsfInjectionProvider' does not extend DiscoverableInjectionProvider. Entry will be ignored. 
14:16:07,829 INFO [javax.enterprise.resource.webcontainer.jsf.application] (MSC service thread 1-2) JSF1048: PostConstruct/PreDestroy annotations present. ManagedBeans methods marked with these annotations will have said annotations processed. 
14:16:07,852 ERROR [org.apache.catalina.core.StandardContext] (MSC service thread 1-2) Error listenerStart 
14:16:07,854 ERROR [org.apache.catalina.core.StandardContext] (MSC service thread 1-2) Context [/test] startup failed due to previous errors 
14:16:07,855 INFO [org.jboss.web] (MSC service thread 1-2) registering web context: /oneSourceUI 
14:16:08,101 INFO [org.apache.catalina.core.StandardContext] (MSC service thread 1-1) Container org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/oneSourceUI] has not been started 
14:16:08,816 INFO [org.jboss.as.server.controller] (DeploymentScanner-threads - 2) Deployment of "test-ear.ear" was rolled back with failure message {"Services with missing/unavailable dependencies" => ["jboss.persistenceunit.\"test-ear.ear/test-ejb.jar#testBackout\" missing [ jboss.naming.context.java.testBackoutDatasource ]","jboss.persistenceunit.\"test-ear.ear/test-ejb.jar#test\" missing [ jboss.naming.context.java.testDatasource ]"]} 
14:16:08,857 INFO [org.jboss.as.server.deployment] (MSC service thread 1-1) Stopped deployment test-ejb.jar in 760ms 
14:16:08,857 INFO [org.jboss.as.server.deployment] (MSC service thread 1-1) Stopped deployment jboss-seam.jar in 761ms 
14:16:09,613 INFO [org.jboss.as.server.deployment] (MSC service thread 1-1) Stopped deployment oneSourceUI.war in 1517ms 
14:16:09,720 INFO [org.jboss.as.server.deployment] (MSC service thread 1-1) Stopped deployment oneSourceUI-ear.ear in 1624ms 
14:16:09,728 ERROR [org.jboss.as.deployment] (DeploymentScanner-threads - 1) {"Composite operation failed and was rolled back. Steps that failed:" => {"Operation step-2" => {"Services with missing/unavailable dependencies" => ["jboss.persistenceunit.\"test-ear.ear/test-ejb.jar#testBackout\" missing [ jboss.naming.context.java.testBackoutDatasource ]","jboss.persistenceunit.\"test-ear.ear/test-ejb.jar#test\" missing [ jboss.naming.context.java.testDatasource ]"]}}} 
+0

,因为我改变了他们中的大多数在这里发布,请忽略堆栈跟踪的路径和名称。 – Mike

+1

欢迎来到不兼容的Java EE应用程序服务器的奇妙世界......(即使它们来自同一个供应商)。 –

+0

奇怪的是,我只是将它与Hibernate 4一起使用,并且在部署中使用了hibernate-validator 3.1.0.GA(没有Hibernate 3 JAR)来满足Seam 2对hibernate-validator的依赖。至少这对我的测试HTTP servlet有效。顺便说一下,我发现JBoss AS 7.0.1是最稳定的。 – Kawu

类加载模型中的JBoss 7改变它隐藏了,这不是显式声明太多的东西。

你必须让familar与这些链接:

https://docs.jboss.org/author/display/AS7/Developer+Guide#DeveloperGuide-HowtoresolveClassNotFoundExceptionsandNoCLassDefFoundErrors

https://docs.jboss.org/author/display/AS7/Class+Loading+in+AS7

1 - 我在jboss7.1.1 2通过声明模块解决这个问题 - 修改MANIFEST.MF文件中的lib文件夹

in \ jboss-as-7.1.1.Final \ modules \ folder创建此文件夹:

\ jboss-as-7.1.1.Final \ modules ** org \ hibernate \ validator \ main **

然后我将hibernate-validator-4.2.0.Final.jar文件复制到主文件夹\

然后创建主文件夹文件module.xml和修改由娄代码:

<?xml version="1.0" encoding="UTF-8"?> 
<module xmlns="urn:jboss:module:1.1" name="org.hibernate.validator"> 
    <resources> 
    <resource-root path="hibernate-validator-4.2.0.Final.jar"/> 
    </resources> 

    <dependencies> 
    <module name="javax.api"/> 
    <module name="javax.persistence.api"/> 
    <module name="javax.validation.api"/> 
    <module name="javax.persistence.api"/> 
    <module name="javax.xml.bind.api"/> 
    <module name="org.jboss.logging"/> 
    <module name="org.jboss.common-core"/> 
    <module name="org.joda.time"/> 
    <module name="org.slf4j"/> 
    <module name="org.apache.xerces" services="import"/> 
    <module name="sun.jdk" services="import"/> 
    </dependencies> 
</module> 

现在,你的模块中的JBoss模块创建。

看看这个行:

<module xmlns="urn:jboss:module:1.1" name="org.hibernate.validator"> 

你必须依赖部分在MANIFEST.MF文件使用org.hibernate.validator像波纹管:

Manifest-Version: 1.0 
Implementation-Vendor: Sahand Samaneh 
Implementation-Title: Sahand System Security Product 
Implementation-Version: 5.0.0-SNAPSHOT 
Implementation-Vendor-Id: com.sahand.product 
Built-By: pooladi.morteza 
Build-Jdk: 1.6.0_21 
Created-By: Apache Maven 3.0.4 
Archiver-Version: Plexus Archiver 
Dependencies: com.sahand.common.util,com.sahand.common.security,com.sahand.model.common,com.sahand.model.user.management,com.sahand.model.security,com.sahand.security.api,com.sahand.security.persistence,com.sahand.security.service,org.apache.commons.codec,org.slf4j,ch.qos.logback.core,ch.qos.logback.classic,javax.validation.api,org.hibernate.validator 

那么你的问题必须通过: D

如果您收到任何ClassNotFoundException的消息,则必须声明jboss模块并在您的MANIFEST.MF文件中使用该名称。

:d

把这个persistence.xml中工作,我对这个错误:

property name="javax.persistence.validation.mode" value="none"