0

我正在尝试将应用程序迁移到 JBoss 7.1.1 Final。我使用的是 mojarra 2.0.2 版本,可以在 pom.xml 中看到:

<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>2.0.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>2.0.2</version>
<scope>provided</scope>
</dependency>

使用 JBoss 7.1.1 Final jsf 嵌入式版本 (jsf-impl-2.1.7-jbossorg-2),AS 显示此异常:

 09:21:16,456 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-5) MSC00001: Failed to start service jboss.deployment.subunit."Projeto316Aplicacao.ear"."Projeto316Apresentacao-1.0.0-SNAPSHOT.war".POST_MODULE: org.jboss.msc.service.StartException in service jboss.deployment.subunit."Projeto316Aplicacao.ear"."Projeto316Apresentacao-1.0.0-SNAPSHOT.war".POST_MODULE: Failed to process phase POST_MODULE of subdeployment "Projeto316Apresentacao-1.0.0-SNAPSHOT.war" of deployment "Projeto316Aplicacao.ear"
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:119) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885) [rt.jar:1.6.0_07]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907) [rt.jar:1.6.0_07]
at java.lang.Thread.run(Thread.java:619) [rt.jar:1.6.0_07]
Caused by: java.lang.NoClassDefFoundError: javax/faces/model/DataModel
at java.lang.Class.getDeclaredConstructors0(Native Method) [rt.jar:1.6.0_07]
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2389) [rt.jar:1.6.0_07]
at java.lang.Class.getConstructor0(Class.java:2699) [rt.jar:1.6.0_07]
at java.lang.Class.getConstructor(Class.java:1657) [rt.jar:1.6.0_07]
at org.jboss.as.web.deployment.jsf.JsfManagedBeanProcessor.deploy(JsfManagedBeanProcessor.java:108)
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:113) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]
... 5 more
 Caused by: java.lang.ClassNotFoundException: javax.faces.model.DataModel from [Module "deployment.Projeto316Aplicacao.ear:main" from Service Module Loader]
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190) [jboss-modules.jar:1.1.1.GA]
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468) [jboss-modules.jar:1.1.1.GA]
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456) [jboss-modules.jar:1.1.1.GA]
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:423) [jboss-modules.jar:1.1.1.GA]
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398) [jboss-modules.jar:1.1.1.GA]
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120) [jboss-modules.jar:1.1.1.GA]
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319) [rt.jar:1.6.0_07]
... 11 more

请有人知道为什么会发生这种情况以及如何解决它?

谢谢

4

1 回答 1

0

JBoss AS 7.1.1.Final 中 java.lang.NoClassDefFoundError: javax/faces/model/DataModel 异常的解决方案正是@BalusC 之前所说的:

看起来像 JBoss 类加载中的一个错误:community.jboss.org/thread/177061 如果您在 EAR/lib 中提供 JSF API/impl(实际上是错误的地方),那么它就解决了。– BalusC 1 月 24 日 12:09

如果您使用的是maven,只需放

<dependency>
    <groupId>javax.faces</groupId>
    <artifactId>jsf-impl</artifactId>
    <scope>compile</scope>
</dependency>
....
<defaultLibBundleDir>lib</defaultLibBundleDir>

另一种解决方案(这不是一个好的做法)是将 jboss-as-7.1.1.Final\modules\com\sun\jsf-impl\main 中的 jar 替换为 jsf 规范的另一个实现。

于 2013-02-01T10:59:16.023 回答