5 Replies Latest reply on Oct 27, 2008 8:46 PM by deanhiller2000

    Can't find a persistence unit named 'null'

    deanhiller2000

      Anyone have any idea how to go about debugging this....



      vfszip:/D:/BBROOT/jboss-5.0.0.CR2/server/default/deploy/webrates.ear -> java.lan
      g.IllegalArgumentException: Can't find a persistence unit named 'null' in Abstra
      ctVFSDeploymentContext@16475596{vfszip:/D:/BBROOT/jboss-5.0.0.CR2/server/default
      /deploy/webrates.ear}



      I have been trying to get my ear working for 2 days(it is a port from using seam on tomcat).  I have a directory structure of an ear like so


      webrates.ear
         - lib
             - entities.jar //my entity beans are here to be shared
             - commons-beanutils.jar
             - etc. etc.(same as booking example here)
         - META-INF
             - application.xml
             - jboss-app.xml
         - jboss-seam.jar
         - webrates.jar //no entities, just EJB3 stateless or stateful beans
         - webrates.war
      



      My persistence.xml file is in entities.jar/META-INF directory.  I have an ejb-jar.xml file in my webrates.jar/META-INF directory and am not sure if I need that similar file in entities.jar at all????


      I converted all my Seam beans and their injeted EntityManager from @In to @PersistenceContext(unitName="oracleDatabase"), and I had to add some interfaces for the EJB beans(this is annoying that I need all these extra interfaces where I did not in tomcat!!!!!).  Anyways, does anyone know I can continue to debug this.  I am becoming stumped and keep just trying stupid things now where I would prefer a way to look into the problem deeper and see what is going on.
      thanks,
      Dean


        • 1. Re: Can't find a persistence unit named 'null'
          pisce.gabriel.goic.gmail.com

          @In should work for injecting your entityManager... but don't put @PersistenceContext for anything else than entityManager.
          I think you have some entityManager that has no persistence unit name in its @PersistenceContext and does not know where to find it. You don't normally have to give the persistence unit name every time you inject an entityManager.


          My advice would be to put your persistence.xml in your ear's jar in a META-INF directory, and make it reference your jar that contains entity beans like this:



          <persistence-unit name="xxx_pu" transaction-type="JTA">
                  <provider>org.hibernate.ejb.HibernatePersistence (or else)</provider>
                  <jta-data-source>anyDS</jta-data-source>
                  <jar-file>../lib/yourjar.jar</jar-file>
          (...)




          Hope this helps if you don't get a better answer

          • 2. Re: Can't find a persistence unit named 'null'
            deanhiller2000

            well, I got a step further.  Inside, the entities.jar, there was on EntityManager with @PersistenceContext being used.  When I changed the unitName, it then could not find the unitName(instead of null), then when I deleted it, it all worked fine.  I am not sure why someone in the jar trying to get EntityManager injected into it would fail since all the entity beans and the PU is in that same file.


            Now, I get to the point where it can't find the NamedQueries, so I will try your solution and see if that works.
            thanks,
            Dean

            • 3. Re: Can't find a persistence unit named 'null'
              deanhiller2000

              nope, that did not seem to work :(.  I have this now



              webrates.ear
                 - lib
                     - entities.jar //still has persistence.xml file in it(should I delete it?)
                     - commons-beanutils.jar
                     - etc. etc.(same as booking example here)
                 - META-INF
                     - new persistence.xml file
                     - application.xml
                     - jboss-app.xml
                 - jboss-seam.jar
                 - webrates.jar //no entities, just EJB3 stateless or stateful beans
                 - webrates.war


              • 4. Re: Can't find a persistence unit named 'null'
                deanhiller2000

                oh, I missed an exception.  It is looking for the jar on the filesystem instead of in the ear so it does not work....



                13:20:35,593 WARN  [InputStreamZippedJarVisitor] Unable to find file (ignored):
                vfszip:/D:/BBROOT/jboss-5.0.0.CR2/server/default/lib/xcore3.jar
                java.io.IOException: Child not found xcore3.jar for FileHandler@7069248[path= co
                ntext=file:/D:/BBROOT/jboss-5.0.0.CR2/server/default/lib/ real=file:/D:/BBROOT/j
                boss-5.0.0.CR2/server/default/lib/]



                • 5. Re: Can't find a persistence unit named 'null'
                  deanhiller2000

                  interesting, so I ended up putting entities.jar on the
                  filesystem and not in the ear and with your change, it worked, but
                  now, it loads the EJB3 layer for every ear that uses it which
                  is not what I want either as I want them all to share that layer
                  and share the cache. 


                  Is there any way to put the entities.jar in the classpath of
                  all my ear files so they can share this layer?


                  thanks,
                  Dean