4 Replies Latest reply on Apr 16, 2009 4:15 PM by Craig

    Specification violation EJB3 JPA 6.2.1.2

    Daniel Kluge Newbie

      Hi all,


      I want to start my TestNG-Test in the Embedded JBoss with Maven.
      Here is my persistence.xml in the src/test/resources/META-INF folder:


      <?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="MyProjectTest">
        <provider>org.hibernate.ejb.HibernatePersistence</provider>
        <!-- My-Classes -->
              <class>my.classes.are.listed.here</class>
       <properties>
        <property name="hibernate.archive.autodetection" value="class, hbm" /> 
        <property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect" /> 
        <property name="hibernate.connection.driver_class" value="org.hsqldb.jdbcDriver" /> 
        <property name="hibernate.connection.url" value="jdbc:hsqldb:." /> 
        <property name="hibernate.connection.username" value="sa" /> 
        <property name="hibernate.connection.password" value="" /> 
        <property name="hibernate.hbm2ddl.auto" value="create-drop" /> 
        
        <property name="hibernate.jdbc.batch_size" value="20" />
        
        <property name="hibernate.transaction.factory_class" value="org.hibernate.transaction.JTATransactionFactory"/> 
      
           
        </properties>
        </persistence-unit>
        
      </persistence>



      If I execute the test with Maven I get the following error:


      ERROR [org.jboss.kernel.plugins.dependency.AbstractKernelController] Error installing to Start: name=persistence.units:unitName=MyProjectTest state=Create
      java.lang.RuntimeException: Specification violation [EJB3 JPA 6.2.1.2] - You have not defined a jta-data-source for a JTA enabled persistence context named: MyProjectTest
              at org.jboss.ejb3.entity.PersistenceUnitDeployment.start(PersistenceUnitDeployment.java:230)[...]
      at org.testng.SuiteRunner.privateRun(SuiteRunner.java:262)
              at org.testng.SuiteRunner.run(SuiteRunner.java:191)
              at org.testng.TestNG.createAndRunSuiteRunners(TestNG.java:808)
              at org.testng.TestNG.runSuitesLocally(TestNG.java:776)
              at org.testng.TestNG.run(TestNG.java:701)



      Are the settings of the persistence.xml incorrect, or it is a bug?


      Any help appreciated.


      Regards



        • 1. Re: Specification violation EJB3 JPA 6.2.1.2
          Olivier Thierry Apprentice

          I think the way you configure it would be OK with JPA outside an application server, you should use a datasource instead. Moreover the Hibernate transaction factory class you chose talks about JTA, and you have to run within an application server to have JTA available, so I understand it expects a JTA datasource.


          I run unit tests too with Maven, but I don't use JBoss embedded (OpenEJB instead). My persistence.xml is like this, hope it will help you :


          <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="t4Seam" >
                  <provider>org.hibernate.ejb.HibernatePersistence</provider>
                  <jta-data-source>java:/jdbc/t4Seam</jta-data-source>
                  <properties>
                      <property name="hibernate.hbm2ddl.auto" value="update"/>
                      <property name="hibernate.show_sql" value="false"/>
                  </properties>
              </persistence-unit>
          </persistence>



          • 2. Re: Specification violation EJB3 JPA 6.2.1.2
            Daniel Kluge Newbie

            Thx for your reply.
            Unfortunately this persistence.xml solves the problem at all.


            If I execute the test with the TestNG Plugin, this debug extract is very interesting:


            DEBUG [org.hibernate.util.DTDEntityResolver] trying to resolve system-id [http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd]
            DEBUG [org.hibernate.cfg.EJB3DTDEntityResolver] recognized EJB3 ORM namespace; attempting to resolve on classpath under org/hibernate/ejb
            DEBUG [org.hibernate.cfg.EJB3DTDEntityResolver] located [http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd] in classpath
            TRACE [org.hibernate.ejb.packaging.PersistenceXmlLoader] Persistent Unit name from persistence.xml: MyProject
            FAILED CONFIGURATION: @BeforeSuite startSeam
            org.jboss.deployers.client.spi.IncompleteDeploymentException: Summary of incomplete deployments (SEE PREVIOUS ERRORS FOR DETAILS):
            
            *** CONTEXTS MISSING DEPENDENCIES: Name -> Dependency{Required State:Actual State}
            
            jboss.j2ee:jar=classes,name=BeanA,service=EJB3
             -> <UNKNOWN>{Described:** UNRESOLVED Demands 'persistence.units:jar=classes.jar,unitName=MyProject**}
            
            jboss.j2ee:jar=classes,name=BeanB,service=EJB3
             -> <UNKNOWN>{Described:** UNRESOLVED Demands 'persistence.units:jar=classes.jar,unitName=MyProject**}
            
            jboss.j2ee:jar=classes,name=BeanC,service=EJB3
             -> <UNKNOWN>{Described:** UNRESOLVED Demands 'persistence.units:jar=classes.jar,unitName=MyProject **}
            
            jboss.j2ee:jar=classes,name=BeanD,service=EJB3
             -> <UNKNOWN>{Described:** UNRESOLVED Demands 'persistence.units:jar=classes.jar,unitName=MyProject **}
            
            jboss.j2ee:jar=classes,name=BeanF,service=EJB3
             -> <UNKNOWN>{Described:** UNRESOLVED Demands 'persistence.units:jar=classes.jar,unitName=MyProject **}
            
            persistence.units:jar=classes.jar,unitName=MyProject
             -> <UNKNOWN>{Described:** UNRESOLVED Demands 'jboss.jca:name=jdbc/MyProject,service=DataSourceBinding **}
            
            
            *** CONTEXTS IN ERROR: Name -> Error
            
            <UNKNOWN> -> ** UNRESOLVED Demands 'jboss.jca:name=jdbc/MyProject,service=DataSourceBinding **



            We have to distinguish between persistence.xml of the EJB-Project named MyProject (PU is also called) in the Embedded JBoss (PU: MyProjectTest) which the tests are running in and the Embedded JBoss is inside of the EJB-Project.


            As you can see: The persistence unit MyProjectTest for the test is not mentioned here. Addiotionally my Test is very simple:


            public class MyTest extends SeamTest
            {
              @Test
              public void sayHello()
              {
                assert true;
              }
            }



            I can't imagine why there are problems with the EJBBeans in MyProject, because my test does not use them.


            The Embedded JBoss is a source of pain.


            Could anybody give me a hint?

            • 3. Re: Specification violation EJB3 JPA 6.2.1.2
              Daniel Kluge Newbie

              After some changes in my pom.xml I get this error here:



              WARN  [org.jboss.mx.loading.UnifiedLoaderRepository3] Tried to add non-URLClassLoader.  Ignored
              WARN  [org.jboss.aop.deployment.AspectManagerService] Could not find base-aspects.xml file in the resources of sun.misc.Launcher$AppClassLoader@133056f
              INFO  [org.jboss.aop.deployers.AspectDeployer] Deploying xml into org.jboss.aop.AspectManager@95ef17 for sun.misc.Launcher$AppClassLoader@133056f
              ERROR [org.jboss.kernel.plugins.dependency.AbstractKernelController] Error installing to Real: name=vfsfile:/C:/Projekte/My_Project/main/Sourcen_maven/myproject-ejb/target/test-classes/deploy/hsqldb-ds.xml state=PostClassLoader mode=Manual requiredState=Real
              org.jboss.deployers.spi.DeploymentException: Error during deploy: vfsfile:/C:/Projekte/My_Project/main/Sourcen_maven/myproject-ejb/target/test-classes/deploy/hsqldb-ds.xml
                   at org.jboss.deployers.spi.DeploymentException.rethrowAsDeploymentException(DeploymentException.java:49)



              I changed the jre from 1.6.13 to 5.0.16 but the same problem occurs.


              Could anybody tell me why?


              Regards

              • 4. Re: Specification violation EJB3 JPA 6.2.1.2
                Craig  Newbie

                I get the same problem


                Did you manage to fix this?


                Thanks


                Craig