3 Replies Latest reply on Oct 26, 2007 12:18 PM by Antonio Parolini

    javax.naming.NamingException: Context is read only

    Jonas Tegman Newbie

      I'm trying to create a PojoCache under Tomcat and I get "ERROR main org.jboss.cache.transaction.DummyTransactionManager - binding of DummyTransactionManager failed
      javax.naming.NamingException: Context is read only" when I start my server. See trace, code, config below.

      I'm on a development environment running XP64 and JDK5.0 and Tomcat 5.5

      Have anyone had and solved this problem?


      -----------------------------------------

      INFO main org.jboss.cache.PropertyConfigurator - Found existing property editor for org.w3c.dom.Element: org.jboss.util.propertyeditor.ElementEditor@5c2a25
      INFO main org.jboss.cache.PropertyConfigurator - attribute size: 14
      INFO main org.jboss.cache.PropertyConfigurator - attribute size: 14
      ERROR main org.jboss.cache.transaction.DummyTransactionManager - binding of DummyTransactionManager failed
      javax.naming.NamingException: Context is read only
      at org.apache.naming.NamingContext.checkWritable(NamingContext.java:902)
      at org.apache.naming.NamingContext.bind(NamingContext.java:830)
      at org.apache.naming.NamingContext.bind(NamingContext.java:170)
      at org.apache.naming.NamingContext.bind(NamingContext.java:186)
      at org.apache.naming.SelectorContext.bind(SelectorContext.java:170)
      at javax.naming.InitialContext.bind(Unknown Source)
      at org.jboss.cache.transaction.DummyTransactionManager.getInstance(DummyTransactionManager.java:33)
      at org.jboss.cache.DummyTransactionManagerLookup.getTransactionManager(DummyTransactionManagerLookup.java:17)
      at org.jboss.cache.TreeCache._createService(TreeCache.java:1314)
      at org.jboss.cache.TreeCache.createService(TreeCache.java:1300)
      at org.jboss.system.ServiceMBeanSupport.jbossInternalCreate(ServiceMBeanSupport.java:245)
      at org.jboss.system.ServiceMBeanSupport.create(ServiceMBeanSupport.java:173)
      at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:265)
      at org.jboss.system.ServiceMBeanSupport.start(ServiceMBeanSupport.java:181)
      at com.deucemedia.common.session.SessionHolder.initPojoCache(SessionHolder.java:78)
      at com.deucemedia.common.session.SessionHolder.readConfig(SessionHolder.java:127)
      at com.deucemedia.common.init.Initialize.readConfigurable(Initialize.java:200)
      at com.deucemedia.common.init.Initialize.readAllConfig(Initialize.java:154)
      at com.deucemedia.common.init.Initialize.(Initialize.java:125)
      at com.deucemedia.common.init.Initialize.(Initialize.java:70)
      at init.InitServlet.initialize(InitServlet.java:66)
      at init.InitServlet.(InitServlet.java:23)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
      at java.lang.reflect.Constructor.newInstance(Unknown Source)
      at java.lang.Class.newInstance0(Unknown Source)
      at java.lang.Class.newInstance(Unknown Source)
      at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1055)
      at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:932)
      at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3917)
      at org.apache.catalina.core.StandardContext.start(StandardContext.java:4201)
      at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1013)
      at org.apache.catalina.core.StandardHost.start(StandardHost.java:718)
      at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1013)
      at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:442)
      at org.apache.catalina.core.StandardService.start(StandardService.java:450)
      at org.apache.catalina.core.StandardServer.start(StandardServer.java:709)
      at org.apache.catalina.startup.Catalina.start(Catalina.java:551)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      at java.lang.reflect.Method.invoke(Unknown Source)
      at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:294)
      at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:432)
      ERROR main org.jboss.cache.transaction.DummyTransactionManager - binding of DummyTransactionManager failed
      javax.naming.NamingException: Context is read only
      at org.apache.naming.NamingContext.checkWritable(NamingContext.java:902)
      at org.apache.naming.NamingContext.bind(NamingContext.java:830)
      at org.apache.naming.NamingContext.bind(NamingContext.java:170)
      at org.apache.naming.NamingContext.bind(NamingContext.java:186)
      at org.apache.naming.SelectorContext.bind(SelectorContext.java:170)
      at javax.naming.InitialContext.bind(Unknown Source)
      at org.jboss.cache.transaction.DummyTransactionManager.getInstance(DummyTransactionManager.java:33)
      at org.jboss.cache.DummyTransactionManagerLookup.getTransactionManager(DummyTransactionManagerLookup.java:17)
      at org.jboss.cache.TreeCache._createService(TreeCache.java:1314)
      at org.jboss.cache.TreeCache.createService(TreeCache.java:1300)
      at org.jboss.system.ServiceMBeanSupport.jbossInternalCreate(ServiceMBeanSupport.java:245)
      at org.jboss.system.ServiceMBeanSupport.create(ServiceMBeanSupport.java:173)
      at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:265)
      at org.jboss.system.ServiceMBeanSupport.start(ServiceMBeanSupport.java:181)
      at com.deucemedia.common.session.SessionHolder.initPojoCache(SessionHolder.java:78)
      at com.deucemedia.common.session.SessionHolder.readConfig(SessionHolder.java:127)
      at com.deucemedia.common.init.Initialize.readConfigurable(Initialize.java:200)
      at com.deucemedia.common.init.Initialize.readAllConfig(Initialize.java:154)
      at com.deucemedia.common.init.Initialize.(Initialize.java:125)
      at com.deucemedia.common.init.Initialize.(Initialize.java:70)
      at init.InitServlet.initialize(InitServlet.java:66)
      at init.InitServlet.(InitServlet.java:23)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
      at java.lang.reflect.Constructor.newInstance(Unknown Source)
      at java.lang.Class.newInstance0(Unknown Source)
      at java.lang.Class.newInstance(Unknown Source)
      at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1055)
      at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:932)
      at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3917)
      at org.apache.catalina.core.StandardContext.start(StandardContext.java:4201)
      at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1013)
      at org.apache.catalina.core.StandardHost.start(StandardHost.java:718)
      at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1013)
      at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:442)
      at org.apache.catalina.core.StandardService.start(StandardService.java:450)
      at org.apache.catalina.core.StandardServer.start(StandardServer.java:709)
      at org.apache.catalina.startup.Catalina.start(Catalina.java:551)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      at java.lang.reflect.Method.invoke(Unknown Source)
      at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:294)
      at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:432)

      -----------------------------------------

      private static PojoCache pc;

      ...

      pc=new PojoCache();
      PropertyConfigurator config=new PropertyConfigurator();
      config.configure(pc,Initialize.getConfigPath()+"jboss-pojocache-service.xml");
      pc.start();

      --------------------------------

      <?xml version="1.0" encoding="UTF-8"?>

      <!-- ===================================================================== -->
      <!-- -->
      <!-- Sample TreeCache Service Configuration -->
      <!-- -->
      <!-- ===================================================================== -->






      <!-- ==================================================================== -->
      <!-- Defines TreeCache configuration -->
      <!-- ==================================================================== -->



      jboss:service=Naming
      jboss:service=TransactionManager

      <!--
      Configure the TransactionManager
      -->
      org.jboss.cache.DummyTransactionManagerLookup

      <!--
      Isolation level : SERIALIZABLE
      REPEATABLE_READ (default)
      READ_COMMITTED
      READ_UNCOMMITTED
      NONE
      -->
      REPEATABLE_READ

      <!--
      Valid modes are LOCAL
      REPL_ASYNC
      REPL_SYNC
      INVALIDATION_ASYNC
      INVALIDATION_SYNC
      -->
      REPL_SYNC

      <!--
      Just used for async repl: use a replication queue
      -->
      false

      <!--
      Replication interval for replication queue (in ms)
      -->
      0

      <!--
      Max number of elements which trigger replication
      -->
      0

      <!-- Name of cluster. Needs to be the same for all clusters, in order
      to find each other
      -->
      TreeCache-Cluster

      <!-- JGroups protocol stack properties. Can also be a URL,
      e.g. file:/home/bela/default.xml

      -->



      <!-- UDP: if you have a multihomed machine,
      set the bind_addr attribute to the appropriate NIC IP address, e.g bind_addr="192.168.0.2"
      -->
      <!-- UDP: On Windows machines, because of the media sense feature
      being broken with multicast (even after disabling media sense)
      set the loopback attribute to true -->
      <UDP mcast_addr="228.1.2.3" mcast_port="48866"
      ip_ttl="64" ip_mcast="true"
      mcast_send_buf_size="150000" mcast_recv_buf_size="80000"
      ucast_send_buf_size="150000" ucast_recv_buf_size="80000"
      loopback="true"/>
      <PING timeout="2000" num_initial_members="3"
      up_thread="false" down_thread="false"/>
      <MERGE2 min_interval="10000" max_interval="20000"/>
      <!-- <FD shun="true" up_thread="true" down_thread="true" />-->
      <FD_SOCK/>
      <VERIFY_SUSPECT timeout="1500"
      up_thread="false" down_thread="false"/>
      <pbcast.NAKACK gc_lag="50" retransmit_timeout="600,1200,2400,4800"
      max_xmit_size="8192" up_thread="false" down_thread="false"/>
      <UNICAST timeout="600,1200,2400" window_size="100" min_threshold="10"
      down_thread="false"/>
      <pbcast.STABLE desired_avg_gossip="20000"
      up_thread="false" down_thread="false"/>
      <FRAG frag_size="8192"
      down_thread="false" up_thread="false"/>
      <pbcast.GMS join_timeout="5000" join_retry_timeout="2000"
      shun="true" print_local_addr="true"/>
      <pbcast.STATE_TRANSFER up_thread="true" down_thread="true"/>




      <!--
      Whether or not to fetch state on joining a cluster
      NOTE this used to be called FetchStateOnStartup and has been renamed to be more descriptive.
      -->
      true

      <!--
      The max amount of time (in milliseconds) we wait until the
      initial state (ie. the contents of the cache) are retrieved from
      existing members in a clustered environment
      -->
      15000

      <!--
      Number of milliseconds to wait until all responses for a
      synchronous call have been received.
      -->
      15000

      <!-- Max number of milliseconds to wait for a lock acquisition -->
      10000

      <!-- Name of the eviction policy class. -->


      <!--
      Indicate whether to use region based marshalling or not. Set this to true if you are running under a scoped
      class loader, e.g., inside an application server. Default is "false".
      -->
      true



      <!-- Uncomment to get a graphical view of the TreeCache MBean above -->
      <!-- -->
      <!-- jboss.cache:service=TreeCache-->
      <!-- jboss.cache:service=TreeCache-->
      <!-- -->




        • 1. Re: javax.naming.NamingException: Context is read only
          Lior Neumann Newbie

          Hi tegman,

          We're experiencing the exact same problem (Tomcat's JNDI service is read-only)

          Did you solve it eventually ?

          Thanks !!
          Lior Neuman
          R&D Team
          MailVision LTD

          • 2. Re: javax.naming.NamingException: Context is read only
            Brian Stansberry Master

            A few alternatives come to mind:

            1) Does the cache really need a transaction manager? Is code external to the cache trying to start/commit transactions using DummyTransactionManager? If not, just remove the TransactionManagerLookupClass element.

            2) Configure a real transaction manager in Tomcat and choose a TransactionManagerLookup that will find it. The first bit isn't trivial to do; I did it a couple years back after some research and experimentation, but don't remember the steps involved. But, if the purpose of the TransactionManager is anything at all beyond grouping together operations on the cache into a unit of work that can be committed/rolled back, you need to use a real TransactionManager.

            3) You don't need a real TransactionManager and this TransactionManager you are using is only used by this cache and code that has access to this cache. In this case, you may not need the TransactionManager bound in JNDI. Instead, write a class like this:

            package com.foo;
            
            public class FooTransactionManagerLookup implements TransactionManagerLookup
            {
             public TransactionManager getTransactionManager() throws Exception
             {
             // Don't call BatchModeTransactionManager.getInstance(), which tries
             // to bind a singleton in JNDI -- just create one for our use
             return new BatchModeTransactionManager();
             }
            }
            
            


            Configure TransactionManagerLookupClass to use com.foo.FooTransactionManagerLookup.

            Code that needs to start transactions gets the TransactionManager from the cache by calling TreeCache.getTransactionManager().

            • 3. Re: javax.naming.NamingException: Context is read only
              Antonio Parolini Newbie

              Great post Brian!

              I hade the same issue.

              I implemented 3) and it's working like a charme.

              Cheers,

              toni.