3 Replies Latest reply on May 31, 2012 8:48 AM by smarlow
      • 1. Re: Migrating Hibernate from JBoss 5 to JBoss 7
        smarlow

        AS7 is strict about JNDI names and has room for improvement when invalid JNDI names are referenced (patches are always welcome!)

         

        You could choose a JNDI name to bind the Hibernate session factory to that will work on AS7.  Or you could stop looking up the session factory in JNDI.  If your application is JPA based, you could switch to the @PersistenceContext + @PersistenceUnit annotations which get the EntityManager or EntityManagerFactory respectively.  You can also get the Hibernate SessionFactory from a @PersistenceUnit or @PersistenceContext as well.

         

        A quick summary of the different JNDI options:

        • in the java:comp namespace, for use by a single component;

        • in the java:module namespace, for use by all components in a module;

        • in the java:app namespace, for use by all components in an application;

        • in the java:global namespace, for use by all applications.

         

        JNDI names that start with "java:jboss", are also global. 

         

        The following is an example of what you could set the session factory to.

        <property name="hibernate.session_factory_name" value="java:jboss/sessionfactory/YourSessionFactory" />

         

        Scott

        • 2. Re: Migrating Hibernate from JBoss 5 to JBoss 7
          sergiu_pienar

          Hi Scott,

           

          Thanks for your reply. Basically I am trying to migrate the 3.9.4. JMX deployment section from JBoss 5.1.0 to Jboss 7 (without any luck so far) because when the MBean starts it complains on the read-only JNDI context (using JBoss 7.2.0 Alpha).

          • 3. Re: Migrating Hibernate from JBoss 5 to JBoss 7
            smarlow

            Although, If you are not using JPA, you could run into difficulties with the deployment of your application as this other thread is experiencing.

             

            Let us know whether this works or not for you.

             

            Scott