JBoss AS 7错误:WAR部署成功,EAR部署失败
我采用完全相同的 Web 应用程序并将其部署为 WAR,没有任何问题。但是,部署为 EAR 的同一应用程序失败。相同的文件,只是不同的部署。首先,看看 WAR:
Webapp.war
.
|-- error.xhtml
|-- index.xhtml
|-- language.xhtml
|-- login.xhtml
|-- META-INF
|-- register.xhtml
|-- resources
| |-- css
| | `-- layout.css
| |-- images
| | `-- logo.png
| `-- javascript
| `-- detectScreenSize.js
|-- sendMail.xhtml
|-- templates
| `-- masterLayout.xhtml
`-- WEB-INF
|-- beans.xml
|-- classes
| |-- ApplicationResources_es.properties
| |-- ApplicationResources.properties
| |-- com
| | `-- webapp
| | |-- controller
| | | |-- auth
| | | | |-- ClientInfo.class
| | | | |-- LoginModule.class
| | | | |-- RBAC.class
| | | | |-- SimpleGroup.class
| | | | `-- SimplePrincipal.class
| | | |-- LocaleManager.class
| | | |-- SendMailBean.class
| | | |-- UserRegistration.class
| | | `-- UserRemoval.class
| | |-- data
| | | `-- UserListProducer.class
| | |-- exception
| | | |-- ViewExpiredExceptionExceptionHandler.class
| | | `-- ViewExpiredExceptionExceptionHandlerFactory.class
| | |-- model
| | | |-- Entity.class
| | | |-- LoginHistory.class
| | | |-- Role.class
| | | |-- User.class
| | | `-- UserRole.class
| | `-- util
| | |-- Resources.class
| | |-- TimestampAdapter.class
| | `-- Util.class
| |-- META-INF
| | |-- beans.xml
| | `-- persistence.xml
| `-- ValidationMessages.properties
|-- faces-config.xml
|-- jboss-web.xml
|-- lib
| |-- cssparser-0.9.5.jar
| |-- guava-r08.jar
| |-- richfaces-components-api-4.0.0.Final.jar
| |-- richfaces-components-ui-4.0.0.Final.jar
| |-- richfaces-core-api-4.0.0.Final.jar
| |-- richfaces-core-impl-4.0.0.Final.jar
| `-- sac-1.3.jar
|-- navigation.xml
`-- web.xml
现在,这是 EAR。相同的文件(除了现在有 application.xml ),只是结构不同。
Webapp.ear
.
|-- META-INF
| |-- application.xml
| |-- MANIFEST.MF
| `-- maven
| `-- com.webapp
| `-- Webapp-ear
| |-- pom.properties
| `-- pom.xml
|-- Webapp-ejb-1.0-SNAPSHOT.jar
`-- Webapp-web-1.0-SNAPSHOT.war
这是 EJB JAR 文件:
Webapp-ejb-1.0-SNAPSHOT.jar
.
|-- ApplicationResources_es.properties
|-- ApplicationResources.properties
|-- com
| `-- webapp
| |-- controller
| | |-- auth
| | | |-- ClientInfo.class
| | | |-- LoginModule.class
| | | |-- RBAC.class
| | | |-- SimpleGroup.class
| | | `-- SimplePrincipal.class
| | |-- LocaleManager.class
| | |-- SendMailBean.class
| | |-- UserRegistration.class
| | `-- UserRemoval.class
| |-- data
| | `-- UserListProducer.class
| |-- exception
| | |-- ViewExpiredExceptionExceptionHandler.class
| | `-- ViewExpiredExceptionExceptionHandlerFactory.class
| |-- model
| | |-- Entity.class
| | |-- LoginHistory.class
| | |-- Role.class
| | |-- User.class
| | `-- UserRole.class
| `-- util
| |-- Resources.class
| |-- TimestampAdapter.class
| `-- Util.class
|-- META-INF
| |-- beans.xml
| |-- MANIFEST.MF
| |-- maven
| | `-- com.webapp
| | `-- Webapp-ejb
| | |-- pom.properties
| | `-- pom.xml
| `-- persistence.xml
`-- ValidationMessages.properties
这是 WAR 文件:
Webapp-web-1.0-SNAPSHOT.war
.
|-- error.xhtml
|-- index.xhtml
|-- language.xhtml
|-- login.xhtml
|-- META-INF
| |-- MANIFEST.MF
| `-- maven
| `-- com.webapp
| `-- Webapp-web
| |-- pom.properties
| `-- pom.xml
|-- register.xhtml
|-- resources
| |-- css
| | `-- layout.css
| |-- images
| | `-- logo.png
| `-- javascript
| `-- detectScreenSize.js
|-- sendMail.xhtml
|-- templates
| `-- masterLayout.xhtml
`-- WEB-INF
|-- beans.xml
|-- faces-config.xml
|-- jboss-web.xml
|-- lib
| |-- cssparser-0.9.5.jar
| |-- guava-r08.jar
| |-- richfaces-components-api-4.0.0.Final.jar
| |-- richfaces-components-ui-4.0.0.Final.jar
| |-- richfaces-core-api-4.0.0.Final.jar
| |-- richfaces-core-impl-4.0.0.Final.jar
| `-- sac-1.3.jar
|-- navigation.xml
`-- web.xml
这是 EAR 部署中的 application.xml:
<?xml version="1.0" encoding="UTF-8"?>
<application xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_6.xsd" version="6">
<display-name>Webapp-ear</display-name>
<module>
<web>
<web-uri>Webapp-web-1.0-SNAPSHOT.war</web-uri>
<context-root>/Webapp</context-root>
</web>
</module>
<module>
<ejb>Webapp-ejb-1.0-SNAPSHOT.jar</ejb>
</module>
<library-directory>lib</library-directory>
</application>
WAR 部署没有错误,但是 EAR 部署失败,如下所示:
17:41:02,059 WARN [org.jboss.modules] (MSC service thread 1-2) Failed to define class com.webapp.exception.ViewExpiredExceptionExceptionHandler in Module "deployment.Webapp.ear.Webapp-ejb-1.0-SNAPSHOT.jar:main" from Service Module Loader: java.lang.LinkageError: Failed to link com/webapp/exception/ViewExpiredExceptionExceptionHandler (Module "deployment.Webapp.ear.Webapp-ejb-1.0-SNAPSHOT.jar:main" from Service Module Loader)
at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:396)
at org.jboss.modules.ModuleClassLoader.loadClassLocal(ModuleClassLoader.java:243)
at org.jboss.modules.ModuleClassLoader$1.loadClassLocal(ModuleClassLoader.java:73)
at org.jboss.modules.Module.loadModuleClass(Module.java:505)
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:182)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456)
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120)
at org.jboss.as.jpa.hibernate4.HibernateAnnotationScanner.getPackagesInJar(HibernateAnnotationScanner.java:92)
at org.hibernate.ejb.Ejb3Configuration.addScannedEntries(Ejb3Configuration.java:490) [hibernate-entitymanager-4.0.0.Final.jar:4.0.0.Final]
at org.hibernate.ejb.Ejb3Configuration.scanForClasses(Ejb3Configuration.java:852) [hibernate-entitymanager-4.0.0.Final.jar:4.0.0.Final]
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:597) [hibernate-entitymanager-4.0.0.Final.jar:4.0.0.Final]
at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:72) [hibernate-entitymanager-4.0.0.Final.jar:4.0.0.Final]
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.createContainerEntityManagerFactory(PersistenceUnitServiceImpl.java:149) [jboss-as-jpa-7.1.0.CR1b.jar:7.1.0.CR1b]
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.start(PersistenceUnitServiceImpl.java:79) [jboss-as-jpa-7.1.0.CR1b.jar:7.1.0.CR1b]
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_02]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [:1.7.0_02]
at java.lang.Thread.run(Thread.java:722) [:1.7.0_02]
Caused by: java.lang.NoClassDefFoundError: javax/faces/context/ExceptionHandlerWrapper
at java.lang.ClassLoader.defineClass1(Native Method) [:1.7.0_02]
at java.lang.ClassLoader.defineClass(ClassLoader.java:791) [:1.7.0_02]
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) [:1.7.0_02]
at org.jboss.modules.ModuleClassLoader.doDefineOrLoadClass(ModuleClassLoader.java:327)
at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:391)
... 20 more
Caused by: java.lang.ClassNotFoundException: javax.faces.context.ExceptionHandlerWrapper from [Module "deployment.Webapp.ear.Webapp-ejb-1.0-SNAPSHOT.jar:main" from Service Module Loader]
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456)
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120)
... 25 more
17:41:02,143 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-2) MSC00001: Failed to start service jboss.persistenceunit."Webapp.ear/Webapp-ejb-1.0-SNAPSHOT.jar#PostgresPersistenceUnit": org.jboss.msc.service.StartException in service jboss.persistenceunit."Webapp.ear/Webapp-ejb-1.0-SNAPSHOT.jar#PostgresPersistenceUnit": Failed to start service
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1780) [jboss-msc-1.0.1.GA.jar:1.0.1.GA]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) [:1.7.0_02]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [:1.7.0_02]
at java.lang.Thread.run(Thread.java:722) [:1.7.0_02]
Caused by: java.lang.RuntimeException: error trying to scan <jar-file>: vfs:/content/Webapp.ear/Webapp-ejb-1.0-SNAPSHOT.jar/
at org.hibernate.ejb.Ejb3Configuration.scanForClasses(Ejb3Configuration.java:855)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:597)
at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:72)
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.createContainerEntityManagerFactory(PersistenceUnitServiceImpl.java:149)
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.start(PersistenceUnitServiceImpl.java:79)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1824) [jboss-msc-1.0.1.GA.jar:1.0.1.GA]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1759) [jboss-msc-1.0.1.GA.jar:1.0.1.GA]
... 3 more
Caused by: java.lang.RuntimeException: JBAS011431: Could not load entity class 'com.webapp.exception.ViewExpiredExceptionExceptionHandler' with PersistenceUnitInfo.getNewTempClassLoader()
at org.jboss.as.jpa.hibernate4.HibernateAnnotationScanner.getPackagesInJar(HibernateAnnotationScanner.java:96)
at org.hibernate.ejb.Ejb3Configuration.addScannedEntries(Ejb3Configuration.java:490)
at org.hibernate.ejb.Ejb3Configuration.scanForClasses(Ejb3Configuration.java:852)
... 9 more
Caused by: java.lang.ClassNotFoundException: com.webapp.exception.ViewExpiredExceptionExceptionHandler from [Module "deployment.Webapp.ear.Webapp-ejb-1.0-SNAPSHOT.jar:main" from Service Module Loader]
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456)
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120)
at org.jboss.as.jpa.hibernate4.HibernateAnnotationScanner.getPackagesInJar(HibernateAnnotationScanner.java:92)
... 11 more
奇怪的是,错误是:
Caused by :java.lang.RuntimeException:JBAS011431:无法加载实体类'com.webapp.exception.ViewExpiredExceptionExceptionHandler' PersistenceUnitInfo.getNewTempClassLoader()
ViewExpiredExceptionHandler
不是一个实体,那么为什么 PersistenceUnitInfo
会尝试加载它呢?
我使用 "org.jboss.spec.archetypes:jboss-javaee6-ear-webapp"
maven archetype 为 EAR 项目生成模板和 poms,并使用 maven jboss-as:部署
插件来部署 EAR。我正在使用jboss-as-7.1.0.CR1b
。
我的 web.xml 是 servlet 规范 3.0:
<web-app
version="3.0"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
我在这里没有得到什么?请帮忙。
I take the same exact same web application and deploy it as an WAR with no problems. However, same application deployed as EAR fails. Same files, just different deployment. First, look at the WAR:
Webapp.war
.
|-- error.xhtml
|-- index.xhtml
|-- language.xhtml
|-- login.xhtml
|-- META-INF
|-- register.xhtml
|-- resources
| |-- css
| | `-- layout.css
| |-- images
| | `-- logo.png
| `-- javascript
| `-- detectScreenSize.js
|-- sendMail.xhtml
|-- templates
| `-- masterLayout.xhtml
`-- WEB-INF
|-- beans.xml
|-- classes
| |-- ApplicationResources_es.properties
| |-- ApplicationResources.properties
| |-- com
| | `-- webapp
| | |-- controller
| | | |-- auth
| | | | |-- ClientInfo.class
| | | | |-- LoginModule.class
| | | | |-- RBAC.class
| | | | |-- SimpleGroup.class
| | | | `-- SimplePrincipal.class
| | | |-- LocaleManager.class
| | | |-- SendMailBean.class
| | | |-- UserRegistration.class
| | | `-- UserRemoval.class
| | |-- data
| | | `-- UserListProducer.class
| | |-- exception
| | | |-- ViewExpiredExceptionExceptionHandler.class
| | | `-- ViewExpiredExceptionExceptionHandlerFactory.class
| | |-- model
| | | |-- Entity.class
| | | |-- LoginHistory.class
| | | |-- Role.class
| | | |-- User.class
| | | `-- UserRole.class
| | `-- util
| | |-- Resources.class
| | |-- TimestampAdapter.class
| | `-- Util.class
| |-- META-INF
| | |-- beans.xml
| | `-- persistence.xml
| `-- ValidationMessages.properties
|-- faces-config.xml
|-- jboss-web.xml
|-- lib
| |-- cssparser-0.9.5.jar
| |-- guava-r08.jar
| |-- richfaces-components-api-4.0.0.Final.jar
| |-- richfaces-components-ui-4.0.0.Final.jar
| |-- richfaces-core-api-4.0.0.Final.jar
| |-- richfaces-core-impl-4.0.0.Final.jar
| `-- sac-1.3.jar
|-- navigation.xml
`-- web.xml
Now, here is the EAR. Same files (except for now it has application.xml), just different structure.
Webapp.ear
.
|-- META-INF
| |-- application.xml
| |-- MANIFEST.MF
| `-- maven
| `-- com.webapp
| `-- Webapp-ear
| |-- pom.properties
| `-- pom.xml
|-- Webapp-ejb-1.0-SNAPSHOT.jar
`-- Webapp-web-1.0-SNAPSHOT.war
Here's the EJB JAR file:
Webapp-ejb-1.0-SNAPSHOT.jar
.
|-- ApplicationResources_es.properties
|-- ApplicationResources.properties
|-- com
| `-- webapp
| |-- controller
| | |-- auth
| | | |-- ClientInfo.class
| | | |-- LoginModule.class
| | | |-- RBAC.class
| | | |-- SimpleGroup.class
| | | `-- SimplePrincipal.class
| | |-- LocaleManager.class
| | |-- SendMailBean.class
| | |-- UserRegistration.class
| | `-- UserRemoval.class
| |-- data
| | `-- UserListProducer.class
| |-- exception
| | |-- ViewExpiredExceptionExceptionHandler.class
| | `-- ViewExpiredExceptionExceptionHandlerFactory.class
| |-- model
| | |-- Entity.class
| | |-- LoginHistory.class
| | |-- Role.class
| | |-- User.class
| | `-- UserRole.class
| `-- util
| |-- Resources.class
| |-- TimestampAdapter.class
| `-- Util.class
|-- META-INF
| |-- beans.xml
| |-- MANIFEST.MF
| |-- maven
| | `-- com.webapp
| | `-- Webapp-ejb
| | |-- pom.properties
| | `-- pom.xml
| `-- persistence.xml
`-- ValidationMessages.properties
Here's the WAR file:
Webapp-web-1.0-SNAPSHOT.war
.
|-- error.xhtml
|-- index.xhtml
|-- language.xhtml
|-- login.xhtml
|-- META-INF
| |-- MANIFEST.MF
| `-- maven
| `-- com.webapp
| `-- Webapp-web
| |-- pom.properties
| `-- pom.xml
|-- register.xhtml
|-- resources
| |-- css
| | `-- layout.css
| |-- images
| | `-- logo.png
| `-- javascript
| `-- detectScreenSize.js
|-- sendMail.xhtml
|-- templates
| `-- masterLayout.xhtml
`-- WEB-INF
|-- beans.xml
|-- faces-config.xml
|-- jboss-web.xml
|-- lib
| |-- cssparser-0.9.5.jar
| |-- guava-r08.jar
| |-- richfaces-components-api-4.0.0.Final.jar
| |-- richfaces-components-ui-4.0.0.Final.jar
| |-- richfaces-core-api-4.0.0.Final.jar
| |-- richfaces-core-impl-4.0.0.Final.jar
| `-- sac-1.3.jar
|-- navigation.xml
`-- web.xml
Here is the application.xml in the EAR deployment:
<?xml version="1.0" encoding="UTF-8"?>
<application xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_6.xsd" version="6">
<display-name>Webapp-ear</display-name>
<module>
<web>
<web-uri>Webapp-web-1.0-SNAPSHOT.war</web-uri>
<context-root>/Webapp</context-root>
</web>
</module>
<module>
<ejb>Webapp-ejb-1.0-SNAPSHOT.jar</ejb>
</module>
<library-directory>lib</library-directory>
</application>
The WAR deploys without errors, but the EAR fails to be deployed as follows:
17:41:02,059 WARN [org.jboss.modules] (MSC service thread 1-2) Failed to define class com.webapp.exception.ViewExpiredExceptionExceptionHandler in Module "deployment.Webapp.ear.Webapp-ejb-1.0-SNAPSHOT.jar:main" from Service Module Loader: java.lang.LinkageError: Failed to link com/webapp/exception/ViewExpiredExceptionExceptionHandler (Module "deployment.Webapp.ear.Webapp-ejb-1.0-SNAPSHOT.jar:main" from Service Module Loader)
at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:396)
at org.jboss.modules.ModuleClassLoader.loadClassLocal(ModuleClassLoader.java:243)
at org.jboss.modules.ModuleClassLoader$1.loadClassLocal(ModuleClassLoader.java:73)
at org.jboss.modules.Module.loadModuleClass(Module.java:505)
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:182)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456)
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120)
at org.jboss.as.jpa.hibernate4.HibernateAnnotationScanner.getPackagesInJar(HibernateAnnotationScanner.java:92)
at org.hibernate.ejb.Ejb3Configuration.addScannedEntries(Ejb3Configuration.java:490) [hibernate-entitymanager-4.0.0.Final.jar:4.0.0.Final]
at org.hibernate.ejb.Ejb3Configuration.scanForClasses(Ejb3Configuration.java:852) [hibernate-entitymanager-4.0.0.Final.jar:4.0.0.Final]
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:597) [hibernate-entitymanager-4.0.0.Final.jar:4.0.0.Final]
at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:72) [hibernate-entitymanager-4.0.0.Final.jar:4.0.0.Final]
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.createContainerEntityManagerFactory(PersistenceUnitServiceImpl.java:149) [jboss-as-jpa-7.1.0.CR1b.jar:7.1.0.CR1b]
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.start(PersistenceUnitServiceImpl.java:79) [jboss-as-jpa-7.1.0.CR1b.jar:7.1.0.CR1b]
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_02]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [:1.7.0_02]
at java.lang.Thread.run(Thread.java:722) [:1.7.0_02]
Caused by: java.lang.NoClassDefFoundError: javax/faces/context/ExceptionHandlerWrapper
at java.lang.ClassLoader.defineClass1(Native Method) [:1.7.0_02]
at java.lang.ClassLoader.defineClass(ClassLoader.java:791) [:1.7.0_02]
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) [:1.7.0_02]
at org.jboss.modules.ModuleClassLoader.doDefineOrLoadClass(ModuleClassLoader.java:327)
at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:391)
... 20 more
Caused by: java.lang.ClassNotFoundException: javax.faces.context.ExceptionHandlerWrapper from [Module "deployment.Webapp.ear.Webapp-ejb-1.0-SNAPSHOT.jar:main" from Service Module Loader]
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456)
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120)
... 25 more
17:41:02,143 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-2) MSC00001: Failed to start service jboss.persistenceunit."Webapp.ear/Webapp-ejb-1.0-SNAPSHOT.jar#PostgresPersistenceUnit": org.jboss.msc.service.StartException in service jboss.persistenceunit."Webapp.ear/Webapp-ejb-1.0-SNAPSHOT.jar#PostgresPersistenceUnit": Failed to start service
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1780) [jboss-msc-1.0.1.GA.jar:1.0.1.GA]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) [:1.7.0_02]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [:1.7.0_02]
at java.lang.Thread.run(Thread.java:722) [:1.7.0_02]
Caused by: java.lang.RuntimeException: error trying to scan <jar-file>: vfs:/content/Webapp.ear/Webapp-ejb-1.0-SNAPSHOT.jar/
at org.hibernate.ejb.Ejb3Configuration.scanForClasses(Ejb3Configuration.java:855)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:597)
at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:72)
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.createContainerEntityManagerFactory(PersistenceUnitServiceImpl.java:149)
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.start(PersistenceUnitServiceImpl.java:79)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1824) [jboss-msc-1.0.1.GA.jar:1.0.1.GA]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1759) [jboss-msc-1.0.1.GA.jar:1.0.1.GA]
... 3 more
Caused by: java.lang.RuntimeException: JBAS011431: Could not load entity class 'com.webapp.exception.ViewExpiredExceptionExceptionHandler' with PersistenceUnitInfo.getNewTempClassLoader()
at org.jboss.as.jpa.hibernate4.HibernateAnnotationScanner.getPackagesInJar(HibernateAnnotationScanner.java:96)
at org.hibernate.ejb.Ejb3Configuration.addScannedEntries(Ejb3Configuration.java:490)
at org.hibernate.ejb.Ejb3Configuration.scanForClasses(Ejb3Configuration.java:852)
... 9 more
Caused by: java.lang.ClassNotFoundException: com.webapp.exception.ViewExpiredExceptionExceptionHandler from [Module "deployment.Webapp.ear.Webapp-ejb-1.0-SNAPSHOT.jar:main" from Service Module Loader]
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456)
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120)
at org.jboss.as.jpa.hibernate4.HibernateAnnotationScanner.getPackagesInJar(HibernateAnnotationScanner.java:92)
... 11 more
It's strange that the error is:
Caused by: java.lang.RuntimeException: JBAS011431: Could not load entity class 'com.webapp.exception.ViewExpiredExceptionExceptionHandler' with PersistenceUnitInfo.getNewTempClassLoader()
The ViewExpiredExceptionHandler
is not an entity, so why would PersistenceUnitInfo
try to be loading it?
I used the "org.jboss.spec.archetypes:jboss-javaee6-ear-webapp"
maven archetype to generate the template and poms for the EAR project and I use maven jboss-as:deploy
plugin to deploy the EAR. I am using jboss-as-7.1.0.CR1b
.
My web.xml is servlet spec 3.0:
<web-app
version="3.0"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
What am I not getting here? Please help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
首先,您的 EJB bean 永远不应该依赖于 JSF 库。 JSF 是为应用程序的视图部分(html+backing beans)而设计的框架。 EJB 模块应该在不了解 JSF 的情况下运行。
如果您确实需要从 EJB 方法引用 JSF,则必须显式通知容器(JBoss 7.1.)该模块依赖于 JSF 模块。您可以在这里找到详细信息:
https://docs.jboss.org/author/display/AS7 /类+加载+in+AS7
First of all Your EJB beans should never depend on JSF libraries. JSF is framework designed for view part of the application (html+backing beans). EJB module should operate without the knowledge about JSF.
If You really need to reference JSF from EJB method you have to explicitly inform container (JBoss 7.1.) that this module depends on JSF module. You can find details here:
https://docs.jboss.org/author/display/AS7/Class+Loading+in+AS7
使用 EAR 部署时,EJB 应位于 EAR 的false < /code> 让 EE 子系统识别 EJB JAR。
/lib
目录中,否则您需要添加另一种选择是将
Dependency: Webapp-ejb-1.0-SNAPSHOT
添加到 WAR 中的 MANIFEST.MF。您可以从以下文档中获取有关使用 EAR 进行类加载的更多信息 https://docs.jboss.org/author/display/AS7/Class+Loading+in+AS7。
When using an EAR deployment, EJB's should be in the
/lib
directory of the EAR or you need to add<ear-subdeployments-isolated>false</ear-subdeployments-isolated>
to get the EE subsystem to recognize the EJB JAR.Another option would be to add
Dependencies: Webapp-ejb-1.0-SNAPSHOT
to the MANIFEST.MF in your WAR.You can get more information on class loading with EAR's from the following documentation https://docs.jboss.org/author/display/AS7/Class+Loading+in+AS7.