2 Replies Latest reply on Jul 7, 2008 12:39 AM by guy bashan

    JNDI problect

    guy bashan Apprentice

      Hi All,


      I am using Seam with Tomcat and Hibernate. I do not use Datasource. I use c3p0 configured in my hibernate.cfg.xml.
      I keep getting this exception when server is loaded:


      18:31:41,096 INFO  [NamingHelper] JNDI InitialContext properties:{}
      18:31:41,098 WARN  [SessionFactoryObjectFactory] Could not bind factory to JNDI
      javax.naming.NamingException: Context is read only
           at org.apache.naming.NamingContext.checkWritable(NamingContext.java:903)
           at org.apache.naming.NamingContext.bind(NamingContext.java:831)
           at org.apache.naming.NamingContext.rebind(NamingContext.java:208)
           at org.hibernate.util.NamingHelper.bind(NamingHelper.java:74)
           at org.hibernate.impl.SessionFactoryObjectFactory.addInstance(SessionFactoryObjectFactory.java:90)
           at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:306)
           at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1294)
           at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:915)
           at org.jboss.seam.persistence.HibernateSessionFactory.createSessionFactory(HibernateSessionFactory.java:165)
           at org.jboss.seam.persistence.HibernateSessionFactory.startup(HibernateSessionFactory.java:79)
           at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
           at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
           at java.lang.reflect.Method.invoke(Method.java:597)
           at org.jboss.seam.util.Reflections.invoke(Reflections.java:21)
           at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:125)
           at org.jboss.seam.Component.callComponentMethod(Component.java:2092)
           at org.jboss.seam.Component.callCreateMethod(Component.java:2015)
           at org.jboss.seam.Component.newInstance(Component.java:1976)
           at org.jboss.seam.contexts.Contexts.startup(Contexts.java:304)
           at org.jboss.seam.contexts.Contexts.startup(Contexts.java:278)
           at org.jboss.seam.contexts.ServletLifecycle.endInitialization(ServletLifecycle.java:95)
           at org.jboss.seam.init.Initialization.init(Initialization.java:596)
           at org.jboss.seam.servlet.SeamListener.contextInitialized(SeamListener.java:34)
           at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3843)
           at org.apache.catalina.core.StandardContext.start(StandardContext.java:4350)
           at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
           at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
           at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
           at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:626)
           at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:553)
           at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:488)
           at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1147)
           at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
           at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
           at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
           at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
           at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
           at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
           at org.apache.catalina.core.StandardService.start(StandardService.java:516)
           at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
           at org.apache.catalina.startup.Catalina.start(Catalina.java:578)
           at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
           at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
           at java.lang.reflect.Method.invoke(Method.java:597)
           at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
           at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)



      The server loads ok, and things seems to be working. Can anyone shade some light about this exception?


      Thanks,
      Guy.

        • 1. Re: JNDI problect
          Daniel Hinojosa Master

          How are you configuring C3P0?


          If I remember correctly you cannot bind a JNDI resource dynamically to Tomcat.

          • 2. Re: JNDI problect
            guy bashan Apprentice

            This is an example of my hibernate configuration file:



            <hibernate-configuration>
            
              <session-factory name="java:/testSessionFactory">
            
                <!-- Database connection settings -->
                <property name="connection.driver_class">com.mysql.jdbc.Driver</property>
                <property name="connection.url"><![CDATA[jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf-8]]></property>
                <property name="connection.username">root</property>
                <property name="connection.password">root</property>
            
                <!-- SQL dialect -->
                <property name="dialect">org.hibernate.dialect.MySQLDialect</property>
                    
                <!-- configuration pool via c3p0--> 
                <property name="c3p0.acquire_increment">1</property> 
                <property name="c3p0.idle_test_period">100</property>
                <property name="c3p0.min_size">5</property> 
                <property name="c3p0.max_size">5</property> 
                <property name="c3p0.max_statements">100</property>     
                <property name="c3p0.timeout">100</property>
            
                <!-- Echo all executed SQL to stdout -->
                <property name="show_sql">false</property>
            
                <property name="transaction.flush_before_completion">true</property>
                <property name="connection.release_mode">after_statement</property>
               
                <mapping class="com.nikonians.ui.model.bo.User"/>
                <mapping class="com.nikonians.ui.model.bo.Video"/>
                <mapping class="com.nikonians.ui.model.bo.Category"/>
            
              </session-factory>
            
            </hibernate-configuration>