1 Reply Latest reply: Apr 17, 2012 10:28 AM by Stephen Coy RSS

    Problem with Web Application Deployment in JBoss EAP 5.1

    Luis Martín Cubas Newbie

      Good night people in the community. I explain my problem, I have a web application made ​​with JPA2.0 using EclipseLink2.0 (with jars: EclipseLink and javaxpersistence), when generating the war and raise it in an apache-tomcat my application works without problems, but when deploying the same war in jboss 5.1 EAP I get the following error:

       

      2012-03-25 17:35:25,288 INFO  [org.jboss.web.tomcat.service.deployers.TomcatDeployment] (main) deploy, ctxPath=/

      2012-03-25 17:35:25,410 INFO  [org.jboss.jpa.deployment.PersistenceUnitDeployment] (main) Starting persistence unit persistence.unit:unitName=Ventas.war#Ventas

      2012-03-25 17:35:25,487 ERROR [org.jboss.kernel.plugins.dependency.AbstractKernelController] (main) Error installing to Start: name=persistence.unit:unitName=Ventas.war#Ventas state=Create

      java.lang.RuntimeException: Specification violation [EJB3 JPA 6.2.1.2] - You have not defined a non-jta-data-source for a RESOURCE_LOCAL enabled persistence context named: Ventas

       

      My persistence.xml is as follows:

       

      <?xml version="1.0" encoding="UTF-8"?>

      <persistence 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"

                   version="1.0">

           <persistence-unit name="Ventas" transaction-type="RESOURCE_LOCAL">

        <class>modelo.Cliente</class>

        <class>modelo.Detallefactura</class>

        <class>modelo.Factura</class>

        <class>modelo.Producto</class>

        <properties>

        <property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/ventasdb"/>

        <property name="javax.persistence.jdbc.user" value="root"/>

        <property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver"/>

        <property name="javax.persistence.jdbc.password" value="root"/>

        </properties>

        </persistence-unit>

      </persistence>

       

      Looking found that I must define my datasource for my connection to my database: MySQL5.0, in addition to change my persistence.xml to include a JTA. Copy to the folder: default / deploy-ds.xml file Sales is my datasource (configured with my database mysql5.0) whose JNDI VentasDatasource

       

      <?xml version="1.0" encoding="UTF-8"?>

      <persistence 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"

                   version="1.0">

                    <persistence-unit name="Ventas" transaction-type="JTA">

                   <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>

               <jta-data-source>java:/VentasDatasource</jta-data-source>

                          <class>modelo.Cliente</class>

                          <class>modelo.Detallefactura</class>

                          <class>modelo.Factura</class>

                          <class>modelo.Producto</class>

                          <properties>

                                    <property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/ventasdb"/>

                                    <property name="javax.persistence.jdbc.user" value="root"/>

                                    <property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver"/>

                                    <property name="javax.persistence.jdbc.password" value="root"/>

                          </properties>

                </persistence-unit>

      </persistence>

       

      However, I generated the following error in the JBoss EAP5.1

       

      2012-03-25 23:18:11,505 INFO  [org.jboss.web.tomcat.service.deployers.TomcatDeployment] (HDScanner) undeploy, ctxPath=/Ventas

      2012-03-25 23:18:29,918 INFO  [org.jboss.jpa.deployment.PersistenceUnitDeployment] (HDScanner) Starting persistence unit persistence.unit:unitName=Ventas.war#Ventas

      2012-03-25 23:18:29,934 ERROR [org.jboss.kernel.plugins.dependency.AbstractKernelController] (HDScanner) Error installing to Start: name=persistence.unit:unitName=Ventas.war#Ventas state=Create

      java.lang.ClassCastException: org.eclipse.persistence.jpa.PersistenceProvider cannot be cast to javax.persistence.spi.PersistenceProvider

       

      Thanks for your response