3 Replies Latest reply on Feb 17, 2012 7:12 AM by Scott Marlow

    SessionFactory in Jboss AS7

    Bashir Wichka Newbie

      I starting migrating my application from Jboss 5 to Jboss 7 and I am facing lot of issues due to lack of documentation. I am only relying on posts and discussions.

       

      My applications is using Statelss Session Beans and Hibernate, The Stateless Session beans depend on Session Factory in JNDI and look it up as java:/hibernate/SessionFactory but in AS7 this session factory is not found in JNDI at all.  Could you please suggest how the sessionfactory can be created and put in JNDI so that EJBs can find it.

       

      Thank you very much.

      Bashir

        • 1. Re: SessionFactory in Jboss AS7
          Scott Marlow Master

          What does your persistence.xml look like?  You probably need to change the JNDI name as the rules have changed since JBoss 5.  Here is an unit test link that uses the feature (works on AS 7.1 but not 7.0.x).  The linked Arquillian test contains the persistence.xml.

           

          Scott

          • 2. Re: SessionFactory in Jboss AS7
            jaikiran pai Master

            I just updated the https://docs.jboss.org/author/display/AS71/JPA+Reference+Guide to include the "Binding EntityManagerFactory to JNDI" section. Take a look at that.

            • 3. Re: SessionFactory in Jboss AS7
              Scott Marlow Master

              Also, make sure you change the JNDI name.  "java:jboss/SessionFactory" should work but not "java:/hibernate/SessionFactory".

               

              Some naming rules from an earlier dev list email:

               

              1) Unqualified relative names like "DefaultDS" or "jdbc/DefaultDS"

              should be qualified relative to "java:comp/env", "java:module/env", or

              "java:jboss/env", depending on the context.

               

              2) Unqualified "absolute" names like "/jdbc/DefaultDS" should be

              qualified relative to a "java:jboss/root" name.

               

              3) Qualified "absolute" names like "java:/jdbc/DefaultDS" should be

              qualified the same way as #2.

               

              4) The special "java:jboss" namespace is shared across the entire AS

              server instance.

               

              5) Any "relative" name with a "java:" lead-in must be in one of the five namespaces: "comp", "module", "app", "global", or our proprietary "jboss".   Any name starting with "java:xxx" where "xxx" is a name which

              is not equal to one of the above five would result in an invalid name error.

               

              This allows us to have predictable and consistent rules for every name

              bound in the AS.  It also lets us define additional namespaces as specs

              evolve without running into compatibility problems.

               

               

              Scott