我一直在努力解决这个问题一整天。有人可以指出我正确的方向来理解我做错了什么吗?
应用程序在上使用 maven + hibernate + Spring Data JPA + Atmosphere JBoss AS 7.1.1 Final 。在我以前的Windows机器上,甚至在Openshift上,使用以下 jboss-deployment-structure.xml (使用Jboss模块)部署应用程序,而其他依赖项由 maven 解决
<?xml version="1.0"?>
<jboss-deployment-structure>
<deployment>
<dependencies>
<module name="org.apache.commons.io"/>
<module name="org.apache.commons.lang3"></module>
<module name="org.apache.commons.collections"></module>
<module name="org.apache.commons.fileupload"></module>
<module name="org.apache.commons.digester"/>
<module name="org.apache.commons.validator"/>
<module name="org.apache.httpcomponents.latest"></module>
<module name="org.apache.velocity17"></module>
<module name="org.apache.velocity17.view"></module>
<module name="org.jsoup"></module>
<module name="org.quartz"></module>
<module name="com.google.gson"></module>
<module name="com.mongodb"></module>
<module name="com.mysql"></module>
<module name="com.thoughtworks.paranamer"></module>
<module name="com.vanso.sxmp"></module>
<module name="net.java.dev.jets3t"></module>
</dependencies>
</deployment>
</jboss-deployment-structure>
在我的旧计算机上,我开始移动所有Jboss模块依赖项以充分利用Maven的pom.xml,所以在我的eclipse IDE中,每当我 项目右键单击菜单&gt; Maven&gt;更新项目... ,然后运行应用程序,我开始获得以下StackTrace;
<小时/> 异常Stacktrace
09:14:26,025 INFO [org.jboss.as.jpa] (MSC service thread 1-2) JBAS011401: Read persistence.xml for app
09:14:26,478 INFO [org.jboss.weld.deployer] (MSC service thread 1-6) JBAS016002: Processing weld deployment app-1.0.war
09:14:26,541 INFO [org.springframework.data.jpa.repository.cdi.JpaRepositoryExtension] (MSC service thread 1-6) Activating CDI extension for Spring Data JPA repositories.
09:14:26,603 WARN [org.jboss.as.ee] (MSC service thread 1-7) JBAS011006: Not installing optional component base.modules.views.AppDispatcherServlet due to exception: java.lang.ClassNotFoundException: base.modules.views.AppDispatcherServlet from [Module "deployment.app-1.0.war: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.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.Class.forName0(Native Method) [rt.jar:1.7.0_80]
at java.lang.Class.forName(Class.java:278) [rt.jar:1.7.0_80]
at org.jboss.as.server.deployment.reflect.DeploymentClassIndex.classIndex(DeploymentClassIndex.java:54) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.as.ee.component.deployers.EEModuleConfigurationProcessor.deploy(EEModuleConfigurationProcessor.java:79)
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:113) [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.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_80]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_80]
at java.lang.Thread.run(Thread.java:745) [rt.jar:1.7.0_80]
09:14:26,619 WARN [org.jboss.as.ee] (MSC service thread 1-7) JBAS011006: Not installing optional component base.modules.atmosphere.AtmosphereFrameworkServletFacade due to exception: java.lang.ClassNotFoundException: base.modules.atmosphere.AtmosphereFrameworkServletFacade from [Module "deployment.app-1.0.war: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.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.Class.forName0(Native Method) [rt.jar:1.7.0_80]
at java.lang.Class.forName(Class.java:278) [rt.jar:1.7.0_80]
at org.jboss.as.server.deployment.reflect.DeploymentClassIndex.classIndex(DeploymentClassIndex.java:54) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.as.ee.component.deployers.EEModuleConfigurationProcessor.deploy(EEModuleConfigurationProcessor.java:79)
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:113) [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.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_80]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_80]
at java.lang.Thread.run(Thread.java:745) [rt.jar:1.7.0_80]
09:14:26,775 INFO [org.jboss.weld.deployer] (MSC service thread 1-7) JBAS016005: Starting Services for CDI deployment: app-1.0.war
09:14:26,806 INFO [org.jboss.weld.Version] (MSC service thread 1-7) WELD-000900 1.1.5 (AS71)
09:14:26,869 INFO [org.jboss.as.jpa] (MSC service thread 1-3) JBAS011402: Starting Persistence Unit Service 'app-1.0.war#app'
09:14:26,994 INFO [org.hibernate.annotations.common.Version] (MSC service thread 1-3) HCANN000001: Hibernate Commons Annotations {4.0.1.Final}
09:14:27,009 INFO [org.hibernate.Version] (MSC service thread 1-3) HHH000412: Hibernate Core {4.0.1.Final}
09:14:27,009 INFO [org.hibernate.cfg.Environment] (MSC service thread 1-3) HHH000206: hibernate.properties not found
09:14:27,009 INFO [org.hibernate.cfg.Environment] (MSC service thread 1-3) HHH000021: Bytecode provider name : javassist
09:14:27,025 INFO [org.hibernate.ejb.Ejb3Configuration] (MSC service thread 1-3) HHH000204: Processing PersistenceUnitInfo [
name: app
...]
09:14:27,214 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-3) MSC00001: Failed to start service jboss.persistenceunit."app-1.0.war#app": org.jboss.msc.service.StartException in service jboss.persistenceunit."app-1.0.war#app": Failed to start service
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1767) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_80]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_80]
at java.lang.Thread.run(Thread.java:745) [rt.jar:1.7.0_80]
Caused by: javax.persistence.PersistenceException: [PersistenceUnit: app] class or package not found
at org.hibernate.ejb.Ejb3Configuration.addNamedAnnotatedClasses(Ejb3Configuration.java:1400)
at org.hibernate.ejb.Ejb3Configuration.addClassesToSessionFactory(Ejb3Configuration.java:1183)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:1047)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:692)
at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:72)
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.createContainerEntityManagerFactory(PersistenceUnitServiceImpl.java:162)
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.start(PersistenceUnitServiceImpl.java:85)
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]
... 3 more
Caused by: java.lang.ClassNotFoundException: base.model.CardSetting from [Module "org.hibernate:main" from local module loader @701b206f (roots: C:\jBoss\jboss-as-7.1.1.Final\modules)]
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 java.lang.Class.forName0(Native Method) [rt.jar:1.7.0_80]
at java.lang.Class.forName(Class.java:278) [rt.jar:1.7.0_80]
at org.hibernate.internal.util.ReflectHelper.classForName(ReflectHelper.java:170)
at org.hibernate.ejb.Ejb3Configuration.classForName(Ejb3Configuration.java:1317)
at org.hibernate.ejb.Ejb3Configuration.addNamedAnnotatedClasses(Ejb3Configuration.java:1389)
... 11 more
09:14:27,230 INFO [org.jboss.as] (MSC service thread 1-5) JBAS015951: Admin console listening on http://127.0.0.1:9990
09:14:27,230 ERROR [org.jboss.as] (MSC service thread 1-5) JBAS015875: JBoss AS 7.1.1.Final "Brontes" started (with errors) in 22084ms - Started 309 of 586 services (193 services failed or missing dependencies, 80 services are passive or on-demand)
09:14:27,449 INFO [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS015870: Deploy of deployment "app-1.0.war" was rolled back with failure message {"JBAS014671: Failed services" => {"jboss.persistenceunit.\"app-1.0.war#app\"" => "org.jboss.msc.service.StartException in service jboss.persistenceunit.\"app-1.0.war#app\": Failed to start service"}}
09:14:27,777 INFO [org.jboss.as.server.deployment] (MSC service thread 1-8) JBAS015877: Stopped deployment app-1.0.war in 331ms
09:14:27,777 INFO [org.jboss.as.controller] (DeploymentScanner-threads - 2) JBAS014774: Service status report
JBAS014777: Services which failed to start: service jboss.persistenceunit."app-1.0.war#app": org.jboss.msc.service.StartException in service jboss.persistenceunit."app-1.0.war#app": Failed to start service
09:14:27,777 ERROR [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) {"JBAS014653: Composite operation failed and was rolled back. Steps that failed:" => {"Operation step-2" => {"JBAS014671: Failed services" => {"jboss.persistenceunit.\"app-1.0.war#app\"" => "org.jboss.msc.service.StartException in service jboss.persistenceunit.\"app-1.0.war#app\": Failed to start service"}}}}
<小时/> 但是,当我转到JBOSS_HOME / standalone文件夹并删除&#39; 和&#39; tmp&#39; 文件夹时,请运行
mvn clean install -U
从windows cmd开始,然后Application部署并正常运行。
过了一段时间,我最终不得不搬到另一台电脑。现在该项目将永远不再部署,我总是得到那个例外。
<小时/> 我目前有该应用程序的以下配置;
jboss模块 (JBOSS_HOME / modules / com / mysql / main / module.xml)
<module xmlns="urn:jboss:module:1.1" name="com.mysql">
<resources>
<resource-root path="mysql-connector-java-5.1.39-bin.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
</dependencies>
</module>
<小时/> standalone.xml (数据源子系统)
<subsystem xmlns="urn:jboss:domain:datasources:1.0">
<datasources>
<datasource jta="true" jndi-name="java:jboss/datasources/db_name" pool-name="pool_name" enabled="true" use-java-context="true" use-ccm="false">
<connection-url>jdbc:mysql://<db-url-here>:3306/db_name</connection-url>
<driver>mysql</driver>
<transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation>
<pool>
<flush-strategy>IdleConnections</flush-strategy>
</pool>
<security>
<user-name>username</user-name>
<password>password</password>
</security>
<validation>
<validate-on-match>true</validate-on-match>
<background-validation>true</background-validation>
</validation>
</datasource>
<drivers>
<driver name="h2" module="com.h2database.h2">
<xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
</driver>
<driver name="mysql" module="com.mysql">
<driver-class>com.mysql.jdbc.Driver</driver-class>
<xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>
</driver>
</drivers>
</datasources>
</subsystem>
<小时/> 的的persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1"
xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
<persistence-unit name="app"> <!-- tratransaction-type="JTA" -->
<class>base.model.CardSetting</class>
<class>base.model.Circle</class>
<!-- others omitted for brevity -->
<properties>
<property name="hibernate.connection.datasource" value="java:jboss/datasources/db_name"/>
</properties>
</persistence-unit>
</persistence>
<小时/> maven pom.xml (...相关部分)
<dependencies>
<dependency>
<groupId>org.jboss.spec</groupId>
<artifactId>jboss-javaee-6.0</artifactId>
<version>1.0.0.Final</version>
<exclusions>
<exclusion>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.0-api</artifactId>
</exclusion>
</exclusions>
<type>pom</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.as</groupId>
<artifactId>jboss-as-security</artifactId>
<version>7.1.1.Final</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.ejb3</groupId>
<artifactId>jboss-ejb3-ext-api</artifactId>
<version>2.0.0</version>
<scope>provided</scope>
</dependency>
<!-- JPA Dependencies -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>4.3.8.Final</version>
<exclusions>
<exclusion>
<groupId>org.jboss.spec.javax.transaction</groupId>
<artifactId>jboss-transaction-api_1.2_spec</artifactId>
</exclusion>
</exclusions>
<!-- <scope>provided</scope> -->
</dependency>
<!-- <dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.1-api</artifactId>
<version>${hibernate.jpa.api.version}</version>
<scope>provided</scope>
</dependency> -->
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
<version>1.9.2.RELEASE</version>
<exclusions>
<exclusion>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.0-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.atmosphere.client</groupId>
<artifactId>javascript</artifactId>
<version>[2.3.0, )</version>
<type>war</type>
<!-- <scope>provided</scope> -->
</dependency>
<dependency>
<groupId>org.atmosphere</groupId>
<artifactId>atmosphere-runtime-native</artifactId>
<version>2.4.2</version>
</dependency>
<dependency>
<groupId>org.atmosphere.jboss.as</groupId>
<artifactId>jboss-as-websockets</artifactId>
<version>0.5</version>
</dependency>
</dependencies>
正如你在这里看到的,我试图排除hibernate-jpa-2.0-api
只是因为它可以使用来自JBoss的本机实例的单独的hibernate(即``hibernate-jpa-2.1-api`随附hibernate 4.3.8),但还是无济于事。
<小时/> Erring类 - &gt;
AppDispatcherServlet
和AtmosphereFrameworkServletFacade
分别位于;
base.modules.views.AppDispatcherServlet
base.modules.atmosphere.AtmosphereFrameworkServletFacade
<小时/> 并在 web.xml
中
<servlet>
<servlet-name>app-dispatcher</servlet-name>
<servlet-class>base.modules.views.AppDispatcherServlet</servlet-class>
<load-on-startup>0</load-on-startup>
</servlet>
<servlet>
<description>AtmosphereServlet</description>
<servlet-name>AtmosphereServlet</servlet-name>
<servlet-class>base.modules.atmosphere.AtmosphereFrameworkServletFacade</servlet-class>
<init-param>
<param-name>org.atmosphere.cpr.packages</param-name>
<param-value>base</param-value>
</init-param>
<load-on-startup>0</load-on-startup>
<async-supported>true</async-supported>
</servlet>