JBoss Community

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

created by Manabu Yoneyama in JNDI and Naming - View the full discussion

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>

</sessioin-factory>

 

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.

Reply to this message by going to Community

Start a new discussion in JNDI and Naming at Community