12 Replies Latest reply on Jan 16, 2009 4:06 PM by alrubinger

    There is no default persistence unit in this deployment - Il

    davestar

      I get the following exception when my JBoss server starts up.
      java.lang.RuntimeException: Illegal @PersistenceUnit on private javax.persistence.EntityManager gov.usbr.data.cdw.BurdenRateHome.entityManager :There is no default persistence unit in this deployment.
      at org.jboss.injection.PersistenceContextHandler.handleFieldAnnotations(PersistenceContextHandler.java:182)

      Here's my persistence.xml file. Is there any idea what I'm missing?

      <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="integrations">
      <jta-data-source>java:/cdwDB</jta-data-source>




      </persistence-unit>


        • 1. Re: There is no default persistence unit in this deployment
          davestar

          Here's my persistence.xml
          <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="integrations">
          <jta-data-source>java:/cdwDB</jta-data-source>




          </persistence-unit>

          • 2. Re: There is no default persistence unit in this deployment
            davestar

            I also have the below two properties set but they dont seem to display in this forum when I copy paste the persistence.xml

            "hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/>
            "hibernate.hbm2ddl.auto" value="create-drop"/>

            • 3. Re: There is no default persistence unit in this deployment
              peterj

              When posting XML text, please use the "code" tag. You can do this by selecting the text and clicking the Code button that appears above the editor window. Also, use the Preview button to ensure the formatting before clicking Submit.

              As for your question, how are your entity beans packaged, and where is the persistence.xml file located? Be specific!

              • 4. Re: There is no default persistence unit in this deployment
                davestar

                I reverse engineered and generated hibernate pojos and Session EJB dao code. They are packaged in my ear. My persistence.xml is in the MET-INF folder in the ear file.

                Here's my persistence.xml

                <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="integrations">
                 <jta-data-source>java:/cdwDB</jta-data-source>
                 <properties>
                 <property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/>
                 <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
                 </properties>
                 </persistence-unit>
                </persistence>


                • 5. Re: There is no default persistence unit in this deployment
                  alrubinger

                  JBossAS Version?

                  "davestar" wrote:
                  My persistence.xml is in the MET-INF folder in the ear file.


                  I assume you mean "META-INF"?

                  For reference:

                  "EJB 3.0 Persistence Specification 6.2.2" wrote:
                  When referencing a persistence unit using the unitName annotation element or persis-
                  tence-unit-name deployment descriptor element, the visibility scope of the persistence unit is determined by its point of definition. A persistence unit that is defined at the level of an EJB-JAR, WAR, or application client jar is scoped to that EJB-JAR, WAR, or application jar respectively and is visible to
                  the components defined in that jar or war. A persistence unit that is defined at the level of the EAR is generally visible to all components in the application.


                  And what about the packaging within your EAR? Are the modules all listed in the manifest META-INF/application.xml?

                  jar -tvf nameOfYourEar.ear


                  If you can provide an isolated (failing) test case w/ this issue, we can open a JIRA and attach the EAR.

                  S,
                  ALR

                  • 6. Re: There is no default persistence unit in this deployment
                    davestar

                    JBoss version - 4.2.2, Yes I meant META-INF

                    Here's my application.xml

                    <?xml version="1.0" encoding="ASCII"?>
                    <application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:application="http://java.sun.com/xml/ns/javaee/application_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_5.xsd" version="5">
                     <display-name>MXIntegrationEAR</display-name>
                     <module>
                     <ejb>MXIntegrationEJB.jar</ejb>
                     </module>
                     <module>
                     <web>
                     <web-uri>MXIntegrationWEB.war</web-uri>
                     <context-root>MXIntegrationWEB</context-root>
                     </web>
                     </module>
                    </application>


                    C:\jboss-4.2.2.GA\server\default\deploy>jar tvf MXIntegrationEAR.ear
                     25 Thu Jan 15 14:50:58 MST 2009 META-INF/MANIFEST.MF
                     53 Wed Jan 07 16:21:26 MST 2009 .svn/prop-base/commons-discovery-0.2.jar.svn
                    -base
                     53 Wed Jan 07 16:21:26 MST 2009 .svn/prop-base/wsdl4j-1.5.1.jar.svn-base
                     0 Thu Jan 15 14:49:06 MST 2009 .svn/text-base/
                     0 Thu Jan 15 14:49:06 MST 2009 .svn/
                     0 Wed Jan 07 16:21:26 MST 2009 META-INF/.svn/props/
                     0 Wed Jan 07 16:21:26 MST 2009 META-INF/.svn/tmp/prop-base/
                     18979 Wed Jan 07 16:21:26 MST 2009 .svn/text-base/saaj.jar.svn-base
                     31191 Wed Jan 07 16:21:26 MST 2009 .svn/text-base/jaxrpc.jar.svn-base
                     0 Wed Jan 07 17:01:58 MST 2009 .svn/tmp/
                     603 Wed Jan 07 16:21:26 MST 2009 META-INF/.svn/text-base/application.xml.svn-
                    base
                     53 Wed Jan 07 16:21:26 MST 2009 .svn/prop-base/saaj.jar.svn-base
                    126771 Wed Jan 07 16:21:26 MST 2009 .svn/text-base/wsdl4j-1.5.1.jar.svn-base
                     0 Wed Jan 07 17:01:58 MST 2009 META-INF/.svn/tmp/
                     33202 Wed Jan 07 16:21:26 MST 2009 .svn/text-base/axis-ant.jar.svn-base
                     283 Wed Jan 07 16:21:26 MST 2009 META-INF/.svn/all-wcprops
                     1133 Wed Jan 07 16:21:26 MST 2009 .svn/all-wcprops
                     2 Wed Jan 07 16:21:26 MST 2009 .svn/format
                     53 Wed Jan 07 16:21:26 MST 2009 .svn/prop-base/axis-ant.jar.svn-base
                     0 Wed Jan 07 16:21:26 MST 2009 META-INF/.svn/tmp/props/
                     0 Wed Jan 07 16:21:26 MST 2009 META-INF/.svn/prop-base/
                     53 Wed Jan 07 16:21:26 MST 2009 .svn/prop-base/axis.jar.svn-base
                     603 Wed Jan 07 16:21:26 MST 2009 META-INF/application.xml
                     33202 Thu Jan 15 14:50:58 MST 2009 axis-ant.jar
                    367444 Thu Jan 15 14:50:58 MST 2009 log4j-1.2.14.jar
                     0 Wed Jan 07 16:21:26 MST 2009 .svn/tmp/text-base/
                     2 Wed Jan 07 16:21:26 MST 2009 META-INF/.svn/format
                     18979 Thu Jan 15 14:50:58 MST 2009 saaj.jar
                     0 Thu Jan 15 14:49:06 MST 2009 .svn/prop-base/
                     0 Thu Jan 15 14:49:06 MST 2009 META-INF/
                     71442 Wed Jan 07 16:21:26 MST 2009 .svn/text-base/commons-discovery-0.2.jar.svn
                    -base
                     53 Wed Jan 07 16:21:26 MST 2009 .svn/prop-base/jaxrpc.jar.svn-base
                    363004 Thu Jan 15 14:50:58 MST 2009 MXIntegrationEJB.jar
                     0 Wed Jan 07 16:21:26 MST 2009 .svn/tmp/props/
                     429 Wed Jan 07 17:01:58 MST 2009 META-INF/.svn/entries
                     598 Wed Jan 14 13:20:20 MST 2009 META-INF/persistence.xml
                     71442 Thu Jan 15 14:50:58 MST 2009 commons-discovery-0.2.jar
                     0 Wed Jan 07 16:21:26 MST 2009 .svn/props/
                    1599570 Wed Jan 07 16:21:26 MST 2009 .svn/text-base/axis.jar.svn-base
                    126771 Thu Jan 15 14:50:58 MST 2009 wsdl4j-1.5.1.jar
                     1400 Wed Jan 07 17:01:58 MST 2009 .svn/entries
                     31191 Thu Jan 15 14:50:58 MST 2009 jaxrpc.jar
                     53 Wed Jan 07 16:21:26 MST 2009 .svn/prop-base/log4j-1.2.14.jar.svn-base
                     0 Thu Jan 15 14:49:06 MST 2009 META-INF/.svn/
                    1599570 Thu Jan 15 14:50:58 MST 2009 axis.jar
                    367444 Wed Jan 07 16:21:26 MST 2009 .svn/text-base/log4j-1.2.14.jar.svn-base
                     0 Thu Jan 15 14:49:06 MST 2009 META-INF/.svn/text-base/
                     0 Wed Jan 07 16:21:26 MST 2009 META-INF/.svn/tmp/text-base/
                     0 Wed Jan 07 16:21:26 MST 2009 .svn/tmp/prop-base/
                     30955 Thu Jan 15 14:51:00 MST 2009 MXIntegrationWEB.war


                    • 7. Re: There is no default persistence unit in this deployment
                      alrubinger

                      Might wanna change your packaging as to not bring in your SVN meta into the EAR. ;)

                      Sure, let's open a JIRA and attach your EAR. I'll have a look to see if it's something I'm missing from this post, or a real issue.

                      EJBTHREE project, component "jpa-deployers".

                      S,
                      ALR

                      • 8. Re: There is no default persistence unit in this deployment
                        davestar

                        JIRA ticket: EJBTHREE-1687

                        • 9. Re: There is no default persistence unit in this deployment
                          jaikiran

                          In the meantime, move the persistence.xml to the META-INF folder of your EJB jar instead of keeping it in the META-INF of the EAR. http://docs.jboss.org/ejb3/app-server/reference/build/reference/en/html/entityconfig.html

                          • 10. Re: There is no default persistence unit in this deployment
                            davestar

                            Thanks Everyone.
                            Thanks jaikiran! it worked when i moved the persistence.xml to the META-INF within the EJB jar.

                            I also found with my existing file structure with the persistence.xml at the top level META-INF in the ear file. It works if I add the unitName to the
                            @PersistenceContext annotation.
                            eg:
                            @PersistenceContext(unitName=UNIT_NAME)

                            • 11. Re: There is no default persistence unit in this deployment
                              davestar

                              Thanks Everyone, the JIRA ticket can be closed.
                              Thanks jaikiran! that worked when I moved the persistence.xml to the META-INF within the EJB jar.

                              I also found that with my current structure of having persistence.xml at the top level META-INF within the ear, it works when I have the unitName for the @PersistenceContext annotation.

                              Eg:
                              @PersistenceContext(unitName=PERSISTENCE_UNIT_NAME)

                              • 12. Re: There is no default persistence unit in this deployment
                                alrubinger

                                 

                                "davestar" wrote:
                                Thanks Everyone, the JIRA ticket can be closed.


                                It can't be closed if all we've done is identified a workaround. ;)

                                First we need a test for @PersistenceContent w/ no unitName placed at the root of an EAR, checking that the default PU can be resolved.

                                S,
                                ALR