4 Replies Latest reply on Oct 10, 2011 1:27 AM by Jaikiran Pai

    What does "Naming context is read-only" mean?

    amadablam Newbie

      I'd like to run a simple web application with Hibernate4 on a JBoss AS7.

      But I have an error below.


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


      I wrote hibernate.cfg.xml (snippet),


      <session-factory name="">

        <property name="connection.datasource">java:jboss/datasources/MySQL</property>

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



      and source code:


      Configuration config = new Configuration().configure();

      SessionFactory sessionFactory = config.buildSessionFactory(); // It might be causes the error.


      I can connect datasouce "java:jboss/datasources/MySQL" use below code.


      InitialContext context = new InitialContext();

      ds = (DataSource)context.lookup("java:jboss/datasources/MySQL");

      conn = ds.getConnection();


      Does anyone know the reason for this?

      Sorry for my english is poor.