6 Replies Latest reply on Apr 20, 2012 7:40 AM by b69

    JBAS011440: Can't find a persistence unit named null in deployment

    b69

      Within my RequirementBeanTest I have the following deployment declaration:

       

      @Deployment

          public static JavaArchive createDeployment() {

              JavaArchive arch = ShrinkWrap.create(JavaArchive.class, "MonteRosaEJBtest.jar");

              Package pAspect = Facets.class.getPackage();

              Package pReports = DocumentKind.class.getPackage();

              Package pEjb = Requirements.class.getPackage();

              Package pEnt = Project.class.getPackage();

              arch.addPackages(true, pEjb);

              arch.addPackages(true, pEnt);

              arch.addAsResource("ldap.properties");

              arch.addPackage(pAspect);

              arch.addPackage(pReports);

              arch.addAsResource("enumKeyWords.properties");

      //        arch.addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");

              arch.addAsManifestResource("Meta-INF/persistence.xml");

              return arch;

          }

       

      which cause me the deployment errors as shown in the attachment.

      The persistence.xml can't be found! It was a hard work, to assemble all the above, because the gap from the hello Earthling example to the real world is very big for a starter.

      Please give me a hint, how to declare properly. Its an EJB module of a larger application. The Packages pAspect and pReports are from a further module, normally in a jar, but as far as I could see, packaged properly into the arch.

      Thanks.

        • 1. Re: JBAS011440: Can't find a persistence unit named null in deployment
          david.salter

          Try changing to:

           

          arch.addAsResource("META-INF/persistence.xml", "META-INF/persistence.xml:);

           

          instead of your current line that adds the persistence.xml file assuming that you have a META-INF/persistence.xml file within your test/resources folder of your project.

          • 2. Re: JBAS011440: Can't find a persistence unit named null in deployment
            b69

            Ok, thanks! Now its running!

            Conclusion:

            With regards to ShrinkWrap, overall descriptions are missing. From javadoc it's possible to deduce, what could work. But it's a stony, very time consuming trial and error way!

             

            It works, but I still don't know why! Why it is src/test/resources Folder? Why it must be mentioned twice? What is the difference between the solution where you mention it only once and the used one, where the same information is given twice?

            What exactly does the "beans.xml" declaration?

             

            It would be nice if such background information is given somewhere in a tutorial, or any other documentation.

            • 3. Re: JBAS011440: Can't find a persistence unit named null in deployment
              david.salter

              Hi. I'm glad it's working now.

               

              The src/test/resources folder is the standard path for test resources for Maven so all resources go in there or subfolders.

               

              The first parameter to .addAsResource() specifies the file to add to the archive. You want to add the persistence.xml file which is in the META-INF folder.  The second parameter specifies where this file goes in the archive.  So it looks like the info is given twice, but this is not the case.

               

              Beans.xml is needed to allow CDI beans. If you aren't using those I don't think it's not needed.

              1 of 1 people found this helpful
              • 4. Re: JBAS011440: Can't find a persistence unit named null in deployment
                b69

                Thanks for the clarifications. However I would prefer to see all of this in a general documentation. I don't feel good, when I just know, “how it works”. I need to know, “why it works”. Only the latter gives me the freedom to choose the most adequate solution.

                Example beans.xml and CDI.

                I’m using EJB (JSR-318) not CDI (JSR-299). So beans.xml goes with CDI. Does EJB require another MetaData configuration with ShrinkWrap? You see the kind of questions, which I would like to have answered in a document giving me the whole overview.

                • 5. Re: JBAS011440: Can't find a persistence unit named null in deployment
                  david.salter

                  Hi,

                   

                  I'd recommend looking at the Arquillian Guides - that should answer most of your questions.

                   

                  http://arquillian.org/guides/

                  1 of 1 people found this helpful
                  • 6. Re: JBAS011440: Can't find a persistence unit named null in deployment
                    b69

                    Aah! looks not bad. I was just not able to find it!

                     

                    I'm reading through. I'll tell you the outcome.