JBOSS 7.1.1 javax.persistence.PersistenceException未找到'org.apache.openjpa.persistence.PersistenceProviderImpl中的PersistenceProvider

时间:2012-04-07 20:05:17

标签: spring jpa jboss7.x persistence.xml

我是JBOSS的新手,并坚持在JBOSS 7.1.1中基本部署应用程序

我创建了一个带有persistent.xml的webapp作为

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0"
    xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
    <persistence-unit name="mydummy-jpa" transaction-type="RESOURCE_LOCAL">
        <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
        <jta-data-source>java:jboss/datasources/mydummyexample</jta-data-source>  
        <class>com.nsn.caobusiness.selfcare.entity.DummyTable</class>
        <properties>
            <property name="jboss.as.jpa.providerModule" value="org.jboss.as.jpa.openjpa" />
            <property name="openjpa.Log" value="DefaultLevel=WARN,SQL=TRACE" />
            <property name="openjpa.jdbc.DBDictionary" value="mysql(UseClobs=true)"/>           
        </properties>
    </persistence-unit>
</persistence>


我的standalone.xml中的数据源如下所示:

<datasource jndi-name="java:jboss/datasources/mydummyexample" pool-name="mydummyexample" enabled="true" use-java-context="true" use-ccm="true" jta="true">
                    <connection-url>jdbc:mysql://localhost:3306/worldonstreet</connection-url>
                    <driver>mysql</driver>
                    <security>
                        <user-name>root</user-name>
                        <password></password>
                    </security>
                    <statement>
                        <prepared-statement-cache-size>100</prepared-statement-cache-size>
                        <share-prepared-statements/>
                    </statement>
                </datasource>


当我部署应用程序时,我得到以下异常:

23:48:06,656 INFO [org.jboss.as.jpa](MSC服务主题1-5)JBAS011401:为mydummy-jpa读取persistence.xml 23:48:08,000 ERROR [org.jboss.msc.service.fail](MSC服务线程1-1)MSC00001:无法启动服务jboss.deployment.unit。“SpringDatabaseTransaction.war”.INSTALL:org.jboss.msc服务jboss.deployment.unit中的.service.StartException。“SpringDatabaseTransaction.war”.INSTALL:无法处理部署的部分INSTALL“SpringDatabaseTransaction.war”     在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:886)[rt.jar:1.6.0_26]     at java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:908)[rt.jar:1.6.0_26]     在java.lang.Thread.run(Thread.java:662)[rt.jar:1.6.0_26]  引起:javax.persistence.PersistenceException:JBAS011466:  PersistenceProvider类  未找到'org.apache.openjpa.persistence.PersistenceProviderImpl'

at org.jboss.as.jpa.processor.PersistenceUnitDeploymentProcessor.lookupProvider(PersistenceUnitDeploymentProcessor.java:555)
at org.jboss.as.jpa.processor.PersistenceUnitDeploymentProcessor.deployPersistenceUnit(PersistenceUnitDeploymentProcessor.java:295)
at org.jboss.as.jpa.processor.PersistenceUnitDeploymentProcessor.addPuService(PersistenceUnitDeploymentProcessor.java:258)
at org.jboss.as.jpa.processor.PersistenceUnitDeploymentProcessor.handleWarDeployment(PersistenceUnitDeploymentProcessor.java:194)
at org.jboss.as.jpa.processor.PersistenceUnitDeploymentProcessor.deploy(PersistenceUnitDeploymentProcessor.java:118)
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:113) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]

我在这一整天都被困住了。非常感谢这个论坛的任何帮助。

此致 莱格拉斯

1 个答案:

答案 0 :(得分:4)

我下载了Apache Openjpa,解压缩了jars,在\ JBOSS_HOME&gt; \ modules \ org \ apache \ openjpa下的jboss中创建了一个模块,并将我在persistent.xml中的属性更改为

  <property name="jboss.as.jpa.providerModule" value="org.apache.openjpa" />

module.xml看起来像:

<module xmlns="urn:jboss:module:1.1" name="org.apache.openjpa"> 
    <resources> 
        <resource-root path="openjpa-2.2.0.jar"/> 
        <resource-root path="serp-1.13.1.jar"/> 
    </resources> 
        <dependencies> 
            <module name="javax.persistence.api"/> 
            <module name="javax.transaction.api"/> 
            <module name="javax.validation.api"/> 
            <module name="org.apache.commons.lang"/> 
            <module name="org.apache.commons.collections"/> 
            <module name="org.apache.log4j"/> 
        </dependencies> 
</module>
它终于奏效了。 :) 谢谢@lurscher的评论。它促使我继续前进。