9 Replies Latest reply on Jul 7, 2006 4:22 AM by fabiorusso

    Embedded Alpha 5 can't find persistence.unit

    jgilbert

      I just upgraded from embedded alpha 4 to alpha 5 and the container can't find the persistence unit unless I create a jar first. I didn't have to do this with alpha 4. Here is the output from the simple-tutorial.

      WARN 05-02 17:25:00,921 (BeanSchemaBinding.java:init:227) -You should use the 2.0 version of the Microcontainer xml. xmlns='urn:jboss:bean-deployer:2.0'
      ERROR 05-02 17:25:02,375 (KernelErrors.java:validate:107) -
      *** DEPLOYMENTS MISSING DEPENDENCIES:
      jboss.j2ee:service=EJB3,jar=bin,name=CustomerDAOBean depends on:
      persistence.units:unitName=custdb'{Create:NOT FOUND}
      persistence.units:unitName=custdb'{Start:NOT FOUND}

      Exception in thread "main" java.lang.RuntimeException: Problems scanning classpath
      at org.jboss.ejb3.embedded.EJB3StandaloneBootstrap.scanClasspath(EJB3StandaloneBootstrap.java:245)
      at org.jboss.tutorial.simple.Main.main(Main.java:39)


      For some reason putting archiveByResource and deployDirs in my ejb3-deployment.xml doesn't seem to work anymore. Any ideas?




      .




      META-INF/persistence.xml


        • 1. Re: Embedded Alpha 5 can't find persistence.unit
          jgilbert

          ahhh!
          i see that alpha 5 upgraded the persistence.xml format to spec.
          problem solved!

          • 2. Re: Embedded Alpha 5 can't find persistence.unit
            dhinojosa

             

            "jgilbert" wrote:
            ahhh!
            i see that alpha 5 upgraded the persistence.xml format to spec.
            problem solved!


            What was your solution?

            • 3. Re: Embedded Alpha 5 can't find persistence.unit
              lucluc

              I have same problem too.
              Please, post the detailed solution.
              Thanks in advance.
              Regards
              F

              • 4. Re: Embedded Alpha 5 can't find persistence.unit
                dhinojosa

                I got mine to work..... My error was that my bean mappings in embedded-jboss-beans.xml did not match those in my persistence.xml

                For example:

                ----------embedded-jboss-beans.xml------



                org.hsqldb.jdbcDriver
                jdbc:hsqldb:test/conf/hsqldb/superduper
                sa

                java:/superduperDS
                0
                10
                1000
                100000












                -----------persistence.xml---------------------

                <persistence-unit name="superduper">
                <jta-data-source>java:/superduperDS</jta-data-source>




                </persistence-unit>



                If I call my datasource superduperDS then I need to make sure that bean name for the bootstrap is called superduperDSBootstrap and the bean name for the datasouce is called superduperDS. All this is case sensitive. So make sure your names are consistent and good luck.

                • 5. Re: Embedded Alpha 5 can't find persistence.unit
                  dhinojosa

                  Ooops formatting. :(

                  I got mine to work..... My error was that my bean mappings in embedded-jboss-beans.xml did not match those in my persistence.xml

                  For example:

                  ----------embedded-jboss-beans.xml------

                  <bean name="superduperDSBootstrap" class="org.jboss.resource.adapter.jdbc.local.LocalTxDataSource">
                   <property name="driverClass">org.hsqldb.jdbcDriver</property>
                   <property name="connectionURL">jdbc:hsqldb:test/conf/hsqldb/superduper</property>
                   <property name="userName">sa</property>
                  
                   <property name="jndiName">java:/superduperDS</property>
                   <property name="minSize">0</property>
                   <property name="maxSize">10</property>
                   <property name="blockingTimeout">1000</property>
                   <property name="idleTimeout">100000</property>
                   <property name="transactionManager"><inject bean="TransactionManager"/></property>
                   <property name="cachedConnectionManager"><inject bean="CachedConnectionManager"/></property>
                   <property name="initialContextProperties"><inject bean="InitialContextProperties"/></property>
                   </bean>
                  
                   <bean name="superduperDS" class="java.lang.Object">
                   <constructor factoryMethod="getDatasource">
                   <factory bean="superduperDSBootstrap"/>
                   </constructor>
                   </bean>
                  


                  -----------persistence.xml---------------------
                  <persistence>
                   <persistence-unit name="superduper">
                   <jta-data-source>java:/superduperDS</jta-data-source>
                   <properties>
                   <property name="hibernate.hbm2ddl.auto" value="update"/>
                   <property name="jboss.entity.manager.jndi.name" value="java:/superduper"/>
                   </properties>
                   </persistence-unit>
                  </persistence>
                  


                  If I call my datasource superduperDS then I need to make sure that bean name for the bootstrap is called superduperDSBootstrap and the bean name for the datasouce is called superduperDS. All this is case sensitive. So make sure your names are consistent and good luck.

                  • 6. Re: Embedded Alpha 5 can't find persistence.unit
                    lucluc

                    Thanks very much, dhinojosa.

                    Mine was a classpath problem. It seems that file persistence.xml inside tutorial.jar can never be found & read.

                    I think this is a silly problem, because it's better to deploy persistence.xml along with .jar that contains the beans. I still haven't found the solution.

                    regards
                    F

                    • 7. Re: Embedded Alpha 5 can't find persistence.unit
                      dhinojosa

                      Well about the persistence.xml it does have to be in a META-INF folder. So, as far as your classpath goes make sure that within that classpath there is your META-INF folder with the persistence.xml within it.

                      • 8. Re: Embedded Alpha 5 can't find persistence.unit
                        lucluc

                        Thanks again, dhinojosa.
                        Persistence.xml was correctly placed in meta-inf inside Tutorial.jar.
                        It was the .jar that was not place on classpath.
                        now it works very well.
                        bye
                        F

                        • 9. Re: Embedded Alpha 5 can't find persistence.unit
                          fabiorusso

                          That absolutely solved my problem! Got firebird working. Now I can easily and quickly unit test my ejb3 classes locally

                          :-) Thank you so much!