2 Replies Latest reply on Apr 28, 2015 6:37 AM by Fakaruddin Ali Branched from an earlier discussion.

    JBoss AS 7.1.1 - Naming context is read-only while binding Hibernate session factory

    Fakaruddin Ali Newbie

      Hi Jaikiran,

      Thanks for your help. Now the ear got deployed .

      I am using hibernate 4.3.5 final jar , during creating session factory

       

      sessionFactory = new Configuration().configure("/configFIle.cfg.xml")

       

       

      getting the following exception

       

      java.lang.UnsupportedOperationException: JBAS011859: Naming context is read-only

       

       

      the below is the .cfg .xml

       

      <session-factory name="java:comp/env/hibernate/SessionFactory">

       

      <property name="JndiName">java:/hibernate/HibernateFactory</property>

       

         <property name="connection.datasource">java:/myDS</property>

       

         <property name="dialect">org.hibernate.dialect.Oracle10gDialect</property>

       

         <property name="transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</property>

       

         <property name="transaction.manager_lookup_class">org.hibernate.transaction.JBossTransactionManagerLookup</property>

       

         <property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>

       

         <property name="hibernate.show_sql">false</property>

       

         <property name="hibernate.max_fetch_depth">3</property>

       

         <!-- Framework mapping files -->

       

         <!-- Auditing -->

       

         <mapping resource="AuditInfoImpl.hbm.xml"/>

       

        • 1. Re: JBoss AS 7.1.1 - Naming context is read-only while binding Hibernate session factory
          jaikiran pai Master

          Please post the entire exception stacktrace and the relevant code where you are binding the session factory. What kind of a class/component is it, which binds the session factory?

          • 2. Re: JBoss AS 7.1.1 - Naming context is read-only while binding Hibernate session factory
            Fakaruddin Ali Newbie

            Hi,

            Please find the stack trace:

             

            15:56:15,050 ERROR [stderr] (default task-3) java.lang.UnsupportedOperationException: JBAS011859: Naming context is read-only

             

            15:56:15,050 ERROR [stderr] (default task-3) at org.jboss.as.naming.NamingContext.createSubcontext(NamingContext.java:392)

             

            15:56:15,051 ERROR [stderr] (default task-3) at org.jboss.as.naming.NamingContext.createSubcontext(NamingContext.java:398)

             

            15:56:15,051 ERROR [stderr] (default task-3) at org.hibernate.engine.jndi.internal.JndiServiceImpl.bind(JndiServiceImpl.java:202)

             

            15:56:15,051 ERROR [stderr] (default task-3) at org.hibernate.engine.jndi.internal.JndiServiceImpl.bind(JndiServiceImpl.java:159)

             

            15:56:15,052 ERROR [stderr] (default task-3) at org.hibernate.internal.SessionFactoryRegistry.addSessionFactory(SessionFactoryRegistry.java:103)

             

            15:56:15,052 ERROR [stderr] (default task-3) at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:497)

             

            15:56:15,052 ERROR [stderr] (default task-3) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1857)

             

            15:56:15,052 ERROR [stderr] (default task-3) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1928)

             

            15:56:15,052 ERROR [stderr] (default task-3) at com.ingenix.transact.framework.util.hibernate.HibernateUtil.<clinit>(HibernateUtil.java:76)


            I have written one class HibernetUtil.java ....here only I am binding the session factory in static block. The same is working in jboss 7.1.1


             

            private static SessionFactory sessionFactory = null;

             

            static {

            try {

              sessionFactory = new Configuration().configure("/t360.cfg.xml")

             

            } catch (Exception ex) {

             

            }

             

             

             

            }