我最近用 jboss 和 eclipse 尝试了 JPA 程序。为了连接到 MySQL,我在 JBoss 安装目录路径中放入了所需的 mySQL-connector JAR,并在 jboss 的standalone.xml 中添加了配置,如果我从 eclipse 启动 jboss,它启动正常并显示我也配置了连接。但是,如果我添加我的 ejb 程序并启动服务器,它会给我以下错误,当我搜索解决这个问题时,每个论坛都给了我不同的解决方案,但似乎没有解决我的问题。
错误
17:34:17,195 错误 [org.jboss.msc.service.fail](MSC 服务线程 1-5)MSC00001:无法启动服务 jboss.deployment.unit。“FirstEJBProject.jar”。安装:org.jboss.msc服务 jboss.deployment.unit."FirstEJBProject.jar".INSTALL 中的 .service.StartException:无法在 org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java 处处理部署“FirstEJBProject.jar”的阶段安装: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] 在 org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0. 2.GA] 在 java.util.concurrent。ThreadPoolExecutor.runWorker(Unknown Source) [rt.jar:1.7.0_13] at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [rt.jar:1.7.0_13] at java.lang.Thread.run(未知来源)[rt.jar:1.7.0_13] 原因:java.lang.IllegalArgumentException:org.jboss.msc.service.ServiceName.of(ServiceName.java:85) [jboss] 处的 java 不允许空名称段-msc-1.0.2.GA.jar:1.0.2.GA] 在 org.jboss.msc.service.ServiceName.append(ServiceName.java:112) [jboss-msc-1.0.2.GA.jar:1.0 .2.GA] 在 org.jboss.as.naming.deployment.ContextNames.buildServiceName(ContextNames.java:178) 在 org.jboss.as.naming.deployment.ContextNames$BindInfo.(ContextNames.java:190) 在 org .jboss.as.naming.deployment.ContextNames$BindInfo.(ContextNames.java:181) 在 org.jboss.as.naming。deployment.ContextNames.bindInfoFor(ContextNames.java:124) at org.jboss.as.naming.deployment.ContextNames.bindInfoForEnvEntry(ContextNames.java:165) at org.jboss.as.jpa.processor.PersistenceUnitDeploymentProcessor.deployPersistenceUnit(PersistenceUnitDeploymentProcessor. java:319) 在 org.jboss.as.jpa.processor.PersistenceUnitDeploymentProcessor.handleJarDeployment(PersistenceUnitDeploymentProcessor.java:145) 在 org.jboss.addPuService(PersistenceUnitDeploymentProcessor.java:258) .as.jpa.processor.PersistenceUnitDeploymentProcessor.deploy(PersistenceUnitDeploymentProcessor.java:120) 在 org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:113) [jboss-as-server-7.1.1.Final .jar:7.1.1。决赛] ... 5更多
17:34:17,430 INFO [org.jboss.as.server](DeploymentScanner-threads - 2)JBAS015870:部署“FirstEJBProject.jar”的部署已回滚,并显示失败消息 {“JBAS014671:失败的服务”=> {“jboss .deployment.unit.\"FirstEJBProject.jar\".INSTALL" => "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"FirstEJBProject.jar\".INSTALL: 无法处理阶段安装部署 \"FirstEJBProject.jar\""},"JBAS014771: 缺少/不可用依赖项的服务" => ["jboss.naming.context.java.comp.FirstEJBProject.FirstEJBProject.StudentLogic.Validatorjboss.naming.context.java. comp.FirstEJBProject.FirstEJBProject.StudentLogicMissing[jboss.naming.context.java.comp.FirstEJBProject.FirstEJBProject.StudentLogic。Validatorjboss.naming.context.java.comp.FirstEJBProject.FirstEJBProject.StudentLogic]","jboss.naming.context.java.comp.FirstEJBProject.FirstEJBProject.StudentLogic.ValidatorFactoryjboss.naming.context.java.comp.FirstEJBProject.FirstEJBProject.StudentLogicMissing [jboss.naming.context.java.comp.FirstEJBProject.FirstEJBProject.StudentLogic.ValidatorFactoryjboss.naming.context.java.comp.FirstEJBProject.FirstEJBProject.StudentLogic]"]} 17:34:17,430 信息 [org.jboss.as.server .deployment](MSC 服务线程 1-2)JBAS015877:在 13 毫秒内停止部署 FirstEJBProject.jar 17:34:17,445 INFO [org.jboss.as.controller](DeploymentScanner-threads - 2)JBAS014774:服务状态报告 JBAS014775:新缺少/不满足的依赖项:服务 jboss.naming.context.java.comp.FirstEJBProject.FirstEJBProject。StudentLogic(缺少)依赖项:[服务 jboss.naming.context.java.comp.FirstEJBProject.FirstEJBProject.StudentLogic.ValidatorFactory,服务 jboss.naming.context.java.comp.FirstEJBProject.FirstEJBProject.StudentLogic.Validator] JBAS014777:服务失败启动:service jboss.deployment.unit."FirstEJBProject.jar".INSTALL: org.jboss.msc.service.StartException in service jboss.deployment.unit."FirstEJBProject.jar".INSTALL: 无法处理部署的阶段安装“FirstEJBProject.jar”deployment.unit."FirstEJBProject.jar".INSTALL: org.jboss.msc.service.StartException in service jboss.deployment.unit."FirstEJBProject.jar".INSTALL: 无法处理部署“FirstEJBProject.jar”的阶段安装deployment.unit."FirstEJBProject.jar".INSTALL: org.jboss.msc.service.StartException in service jboss.deployment.unit."FirstEJBProject.jar".INSTALL: 无法处理部署“FirstEJBProject.jar”的阶段安装
17:34:17,461 错误 [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) {"JBAS014653: 复合操作失败并已回滚。失败的步骤:" => {"操作步骤- 2" => {"JBAS014671: 失败的服务" => {"jboss.deployment.unit.\"FirstEJBProject.jar\".INSTALL" => "org.jboss.msc.service.StartException in service jboss.deployment.unit .\"FirstEJBProject.jar\".INSTALL: 无法处理部署的阶段安装\"FirstEJBProject.jar\""},"JBAS014771: 缺少/不可用依赖项的服务" => ["jboss.naming.context.java. comp.FirstEJBProject.FirstEJBProject.StudentLogic.Validatorjboss.naming.context.java.comp.FirstEJBProject.FirstEJBProject.StudentLogicMissing[jboss.naming.context.java.comp.FirstEJBProject.FirstEJBProject.StudentLogic.Validatorjboss.naming.context.java.comp.FirstEJBProject.FirstEJBProject.StudentLogic]","jboss.naming.context.java.comp.FirstEJBProject.FirstEJBProject.StudentLogic.ValidatorFactoryjboss.naming.context.java .comp.FirstEJBProject.FirstEJBProject.StudentLogicMissing[jboss.naming.context.java.comp.FirstEJBProject.FirstEJBProject.StudentLogic.ValidatorFactoryjboss.naming.context.java.comp.FirstEJBProject.FirstEJBProject.StudentLogic]"]}}}FirstEJBProject.FirstEJBProject.StudentLogic.ValidatorFactoryjboss.naming.context.java.comp.FirstEJBProject.FirstEJBProject.StudentLogic]"]}}}FirstEJBProject.FirstEJBProject.StudentLogic.ValidatorFactoryjboss.naming.context.java.comp.FirstEJBProject.FirstEJBProject.StudentLogic]"]}}}
持久性.xml
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
version="1.0">
<!-- MySQL DataSource -->
<persistence-unit name="STUD">
<jta-data-source>java:/</jta-data-source>
<properties>
<property name="showSql" value="true" />
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />
</properties>
</persistence-unit>
独立的.xml
<datasource jndi-name="java:/mydb" pool-name="my_pool" enabled="true" jta="true" use-java-context="true" use-ccm="true">
<connection-url>jdbc:mysql://localhost:3306/myschema</connection-url>
<driver>mysql</driver>
<security>
<user-name>root</user-name>
<password>password</password>
</security>
<statement>
<prepared-statement-cache-size>
100
</prepared-statement-cache-size>
<share-prepared-statements/>
</statement>
</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"/>
</drivers>
</datasources>
我在这里错过了什么吗?
我曾尝试使用 mySQL-ds.xml,如果我使用它,它会给出不同的错误,因为数据源无法解析。如果我也知道解决方案会很有帮助,因为我会打包我的程序并进行部署,我不需要再次在 JBoss 中进行 SQL 连接。
谢谢你。