Announcement Announcement Module
Collapse
No announcement yet.
it Hangs Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • it Hangs

    Hello,
    i have Hibernate Configuration as follows:






    if i call function
    getPersonById(Long id){ //it fetches obj of person from DB
    System.out.println("retrive by id called");
    return (EntityType) getHibernateTemplate().get(getPersistentClass(), id);
    }

    Here Generics is used and HibernateDAO is used these function is called form Spring Bean all thing are configured right....

    all works fine...for 3 calls when i call the same function 4th time it hangs the server(Glassfish V3)
    and when i stop the server it gives me following exception

  • #2
    Exception

    INFO: DBCP borrowObject failed: null
    SEVERE: java.lang.NullPointerException
    javax.faces.el.EvaluationException: java.lang.NullPointerException
    at javax.faces.component.MethodBindingMethodExpressio nAdapter.invoke(MethodBindingMethodExpressionAdapt er.java:102)
    at com.sun.faces.application.ActionListenerImpl.proce ssAction(ActionListenerImpl.java:102)
    at javax.faces.component.UICommand.broadcast(UIComman d.java:387)
    at org.ajax4jsf.component.AjaxViewRoot.processEvents( AjaxViewRoot.java:321)
    at org.ajax4jsf.component.AjaxViewRoot.broadcastEvent s(AjaxViewRoot.java:296)
    at org.ajax4jsf.component.AjaxViewRoot.processPhase(A jaxViewRoot.java:253)
    at org.ajax4jsf.component.AjaxViewRoot.processApplica tion(AjaxViewRoot.java:466)
    at com.sun.faces.lifecycle.InvokeApplicationPhase.exe cute(InvokeApplicationPhase.java:82)
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:1 00)
    at com.sun.faces.lifecycle.LifecycleImpl.execute(Life cycleImpl.java:118)
    at javax.faces.webapp.FacesServlet.service(FacesServl et.java:265)
    at org.apache.catalina.core.ApplicationFilterChain.se rvletService(ApplicationFilterChain.java:431)
    at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:337)
    at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:218)
    at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(Base XMLFilter.java:178)
    at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseF ilter.java:290)
    at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHa ndleRequest(BaseFilter.java:390)
    at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter .java:517)
    at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:250)
    at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:218)
    at org.apache.catalina.core.StandardWrapperValve.preI nvoke(StandardWrapperValve.java:460)
    at org.apache.catalina.core.StandardWrapperValve.invo ke(StandardWrapperValve.java:139)
    at org.apache.catalina.core.StandardContextValve.invo ke(StandardContextValve.java:186)
    at org.apache.catalina.core.StandardPipeline.doInvoke (StandardPipeline.java:719)
    at org.apache.catalina.core.StandardPipeline.doInvoke (StandardPipeline.java:657)
    at com.sun.enterprise.web.WebPipeline.invoke(WebPipel ine.java:96)
    at com.sun.enterprise.web.PESessionLockingStandardPip eline.invoke(PESessionLockingStandardPipeline.java :98)
    at org.apache.catalina.core.StandardHostValve.invoke( StandardHostValve.java:187)
    at org.apache.catalina.core.StandardPipeline.doInvoke (StandardPipeline.java:719)
    at org.apache.catalina.core.StandardPipeline.doInvoke (StandardPipeline.java:657)
    at org.apache.catalina.core.StandardPipeline.invoke(S tandardPipeline.java:651)
    at org.apache.catalina.core.ContainerBase.invoke(Cont ainerBase.java:1030)
    at org.apache.catalina.core.StandardEngineValve.invok e(StandardEngineValve.java:142)
    at org.apache.catalina.core.StandardPipeline.doInvoke (StandardPipeline.java:719)
    at org.apache.catalina.core.StandardPipeline.doInvoke (StandardPipeline.java:657)
    at org.apache.catalina.core.StandardPipeline.invoke(S tandardPipeline.java:651)
    at org.apache.catalina.core.ContainerBase.invoke(Cont ainerBase.java:1030)
    at org.apache.catalina.connector.CoyoteAdapter.doServ ice(CoyoteAdapter.java:325)
    at org.apache.catalina.connector.CoyoteAdapter.servic e(CoyoteAdapter.java:242)
    at com.sun.enterprise.v3.services.impl.ContainerMappe r.service(ContainerMapper.java:180)
    at com.sun.grizzly.http.DefaultProcessorTask.invokeAd apter(DefaultProcessorTask.java:633)
    at com.sun.grizzly.http.DefaultProcessorTask.doProces s(DefaultProcessorTask.java:570)
    at com.sun.grizzly.http.DefaultProcessorTask.process( DefaultProcessorTask.java:827)
    at com.sun.grizzly.http.DefaultProtocolFilter.execute (DefaultProtocolFilter.java:152)
    at com.sun.enterprise.v3.services.impl.GlassfishProto colChain.executeProtocolFilter(GlassfishProtocolCh ain.java:71)
    at com.sun.grizzly.DefaultProtocolChain.execute(Defau ltProtocolChain.java:103)
    at com.sun.grizzly.DefaultProtocolChain.execute(Defau ltProtocolChain.java:89)
    at com.sun.grizzly.http.HttpProtocolChain.execute(Htt pProtocolChain.java:76)
    at com.sun.grizzly.ProtocolChainContextTask.doCall(Pr otocolChainContextTask.java:67)
    at com.sun.grizzly.SelectionKeyContextTask.call(Selec tionKeyContextTask.java:56)
    at com.sun.grizzly.util.WorkerThreadImpl.processTask( WorkerThreadImpl.java:325)
    at com.sun.grizzly.util.WorkerThreadImpl.run(WorkerTh readImpl.java:184)
    Caused by: java.lang.NullPointerException
    at org.apache.commons.pool.impl.GenericObjectPool.bor rowObject(GenericObjectPool.java:788)
    at org.apache.commons.dbcp.AbandonedObjectPool.borrow Object(AbandonedObjectPool.java:117)
    at org.apache.commons.dbcp.PoolingDataSource.getConne ction(PoolingDataSource.java:110)
    at org.apache.commons.dbcp.BasicDataSource.getConnect ion(BasicDataSource.java:312)
    at

    Comment


    • #3
      conf

      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
      <hibernate-configuration>
      <session-factory>
      <property name="hibernate.dialect">org.hibernate.dialect.Ora cleDialect</property>
      <property name="hibernate.connection.driver_class">oracle.jd bc.driver.OracleDriver</property>
      <property name="hibernate.connection.url">___</property>
      <property name="hibernate.connection.username">___</property>
      <property name="hibernate.connection.password">___</property>
      <property name="current_session_context_class">thread</property>
      <property name="hibernate.connection.pool_size">1</property>
      <property name="hibernate.c3p0.max_size">50</property>
      <property name="hibernate.c3p0.min_size">2</property>
      <property name="hibernate.c3p0.timeout">5000</property>
      <property name="hibernate.c3p0.max_statements">100</property>
      <property name="hibernate.c3p0.idle_test_period">3000</property>
      <property name="hibernate.c3p0.acquire_increment">2</property>
      <property name="hibernate.c3p0.validate">false</property>
      <mapping class="xxx.PaditJiModel.City"/>
      <mapping class="xxx.PaditJiModel.Country"/>
      <mapping class="xxx.PaditJiModel.Person"/>
      <mapping class="xxx.PaditJiModel.State"/>
      </session-factory>
      </hibernate-configuration>


      and Context.xml file

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


      <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context"
      xmlns:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx"
      xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schem...-beans-2.5.xsd
      http://www.springframework.org/schema/context http://www.springframework.org/schem...ontext-2.5.xsd
      http://www.springframework.org/schema/jee http://www.springframework.org/schem...ng-jee-2.5.xsd
      http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">

      <bean class="org.apache.commons.dbcp.BasicDataSource" id="dataSource">
      <property name="driverClassName">
      <value>oracle.jdbc.driver.OracleDriver</value>
      </property>
      <property name="url">
      <value>___</value>
      </property>
      <property name="username">
      <value>___</value>
      </property>
      <property name="password">
      <value>___</value>
      </property>

      </bean>
      <bean
      class="org.springframework.orm.hibernate3.annotati on.AnnotationSessionFactoryBean" id="sessionFactory">
      <property name="dataSource">
      <ref bean="dataSource"/>
      </property>
      <property name="configLocation">

      <value>classpath:/hibernate.cfg.xml</value>

      </property>

      <property name="annotatedClasses">
      <list>
      <value>
      xxx.PaditJiModel.Country
      </value>
      <value>
      xxx.PaditJiModel.State
      </value>
      <value>
      xxx.PaditJiModel.City
      </value>
      <value>
      xxx.PaditJiModel.Person
      </value>
      </list>

      </property>


      </bean>
      <bean class="org.springframework.orm.hibernate3.Hibernat eTemplate" id="hibernateTemplate">
      <property name="sessionFactory">
      <ref bean="sessionFactory"/>
      </property>
      </bean>
      <bean id="CountryImpl" class="xxx.panditJiDAO.hibernate.CountryImpl">
      <property name="sessionFactory" ref="sessionFactory" />
      </bean>

      <bean id="CityImpl" class="xxx.hibernate.CityImpl">
      <property name="sessionFactory" ref="sessionFactory" />
      </bean>

      <bean id="StateImpl" class="xxx.hibernate.StateImpl">
      <property name="sessionFactory" ref="sessionFactory" />
      </bean>

      <bean id="PersonImpl" class="xxx.hibernate.PersonImpl">
      <property name="sessionFactory" ref="sessionFactory" />
      </bean>



      </beans>
      Last edited by void_void; Apr 14th, 2009, 01:45 AM.

      Comment


      • #4
        When posting code use [ code][/code ] tags! That way it remains readable.

        1) I don't see transaction management (so no way to determine when a connection is released)
        2) Don't use 'thread' as the current session mechanism, this overrides the spring one and screws up proper transaction management
        3) Don't (re)configure your datasource inside the hibernate properties, you already have a datasource configured in your spring configuration.

        Comment


        • #5
          ok... but

          and also i want to know that how can i refer to my hibernate configuration file to configure datasource...
          Last edited by void_void; Apr 13th, 2009, 07:31 AM.

          Comment


          • #6
            ok.....

            i ave added following code in my context.xml file
            Code:
            <tx:annotation-driven transaction-manager="transactionManager" />
            
            <bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.Hibernat eTemplate">
            <constructor-arg>
            <ref bean="sessionFactory"/>
            </constructor-arg>
            </bean>
            
            <!-- Transaction manager for a single Hibernate SessionFactory (alternative to JTA) -->
            <bean id="transactionManager" class="org.springframework.orm.hibernate3.Hibernat eTransactionManager" p:sessionFactory-ref="sessionFactory">
            then also it doesnt work properly...

            Comment


            • #7
              I suggest you read my whole post ONLY adding a transaction manager isn't enough you will also have to change your hibernate configuration.

              Comment


              • #8
                ?

                what should i add into my hibernate configuration file?

                Comment


                • #9
                  You shouldn't ADD anything you must REMOVE something.

                  Originally posted by Marten Deinum
                  2) Don't use 'thread' as the current session mechanism, this overrides the spring one and screws up proper transaction management
                  3) Don't (re)configure your datasource inside the hibernate properties, you already have a datasource configured in your spring configuration.

                  Comment


                  • #10
                    ..!~

                    ok sir,,
                    now will you pls tell me what should i remove from conf.??
                    i am newbie @ hibernate..

                    Comment


                    • #11
                      I already told you 2 times...

                      Originally posted by mdeinum
                      2) Don't use 'thread' as the current session mechanism, this overrides the spring one and screws up proper transaction management
                      3) Don't (re)configure your datasource inside the hibernate properties, you already have a datasource configured in your spring configuration.

                      Code:
                      <?xml version="1.0" encoding="UTF-8"?>
                      <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
                      <hibernate-configuration>
                      <session-factory>
                      	<property name="hibernate.dialect">org.hibernate.dialect.Ora cleDialect</property>
                      	<property name="hibernate.connection.driver_class">oracle.jd bc.driver.OracleDriver</property>
                      	<property name="hibernate.connection.url">___</property>
                      	<property name="hibernate.connection.username">___</property>
                      	<property name="hibernate.connection.password">___</property>
                      	<property name="current_session_context_class">thread</property>
                      	<property name="hibernate.connection.pool_size">1</property>
                      	<property name="hibernate.c3p0.max_size">50</property>
                      	<property name="hibernate.c3p0.min_size">2</property>
                      	<property name="hibernate.c3p0.timeout">5000</property>
                      	<property name="hibernate.c3p0.max_statements">100</property>
                      	<property name="hibernate.c3p0.idle_test_period">3000</property>
                      	<property name="hibernate.c3p0.acquire_increment">2</property>
                      	<property name="hibernate.c3p0.validate">false</property>
                      	<mapping class="xxx.PaditJiModel.City"/>
                      	<mapping class="xxx.PaditJiModel.Country"/>
                      	<mapping class="xxx.PaditJiModel.Person"/>
                      	<mapping class="xxx.PaditJiModel.State"/>
                      </session-factory>
                      </hibernate-configuration>
                      Remove everything red and blue.

                      Comment


                      • #12
                        if i remove then following exception comes

                        Caused by: org.hibernate.HibernateException: No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here
                        at org.springframework.orm.hibernate3.SpringSessionCo ntext.currentSession(SpringSessionContext.java:63)
                        at org.hibernate.impl.SessionFactoryImpl.getCurrentSe ssion(SessionFactoryImpl.java:544)
                        at org.argus.webpanditji.panditJiDAO.hibernate.BaseAb stractDao.get(BaseAbstractDao.java:72)
                        at org.argus.webpanditji.panditJiDAO.hibernate.CityIm pl.getAllCities(CityImpl.java:27)
                        at org.argus.panditji.PanditjiServices.Services.getAl lCities(Services.java:78)
                        at org.argus.webpanditji.beans.CityBean.getListCity(C ityBean.java:96)
                        at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
                        at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
                        at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
                        at java.lang.reflect.Method.invoke(Method.java:597)
                        at javax.el.BeanELResolver.getValue(BeanELResolver.ja va:261)
                        at javax.el.CompositeELResolver.getValue(CompositeELR esolver.java:143)
                        at com.sun.faces.el.FacesCompositeELResolver.getValue (FacesCompositeELResolver.java:72)
                        at com.sun.el.parser.AstValue.getValue(AstValue.java: 138)
                        at com.sun.el.ValueExpressionImpl.getValue(ValueExpre ssionImpl.java:206)
                        at com.sun.facelets.el.TagValueExpression.getValue(Ta gValueExpression.java:71)
                        ... 70 more

                        Comment


                        • #13
                          Which means your transaction configuration is wrong.

                          Comment


                          • #14
                            this is DAOContext.xml file...


                            Code:
                            <?xml version="1.0" encoding="UTF-8"?>
                             
                            
                            <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                                   xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context"
                                   xmlns:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx"
                                   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
                                   http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
                                   http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd
                            http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
                            
                            
                                <bean class="org.apache.commons.dbcp.BasicDataSource" id="dataSource" destroy-method="close" >
                                    <property name="driverClassName">
                                        <value>oracle.jdbc.driver.OracleDriver</value>
                                    </property>
                                   
                                    <property name="url">
                                        <value>---</value>
                                    </property>
                                    <property name="username">
                                        <value>---</value>
                                    </property>
                                   
                                    <property name="password">
                                        <value>---</value>
                                    </property>
                                    <property name="maxActive" value="100"/>
                                    <property name="maxWait" value="30000"/>
                                   
                             
                                   
                                    
                                </bean>
                            
                            
                              
                            
                                <bean id="lobHandler" class="org.springframework.jdbc.support.lob.OracleLobHandler" />
                            
                                <bean
                            class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean" id="sessionFactory">
                                    <property name="dataSource">
                                        <ref bean="dataSource"/>
                                    </property>
                                    <property name="lobHandler">
                                        <ref bean="lobHandler"/>
                                    </property>
                                    <property name="configLocation">
                            
                                        <value>classpath:/hibernate.cfg.xml</value>
                            
                                    </property>
                            
                                    <property name="annotatedClasses">
                                        <list>
                                            <value>
                                                  xx.PaditJiModel.Country
                                            </value>
                                            <value>
                                                  xx.PaditJiModel.State
                                            </value>
                                            <value>
                                                  xx.PaditJiModel.City
                                            </value>
                                            <value>
                                                  xx.PaditJiModel.Person
                                            </value>
                                        </list>
                            
                                    </property>
                            
                            
                                </bean>
                                <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager" p:sessionFactory-ref="sessionFactory" />
                            
                                <bean  class="org.springframework.orm.hibernate3.HibernateTemplate" id="hibernateTemplate">
                                    <property name="sessionFactory">
                                        <ref bean="sessionFactory"/>
                                    </property>
                            
                             
                                </bean>
                            
                               <!-- <bean id="transactionInterceptor" class="org.springframework.transaction.interceptor.TransactionInterceptor">
                                    <property name="transactionManager">
                                        <ref bean="transactionManager" />
                                    </property>
                                    <property name="transactionAttributeSource">
                                        <value>  xx.panditJiDAO.hibernate.*=PROPAGATION_REQUIRED</value>
                                    </property>
                                </bean> -->
                            
                                <bean id="hibernateInterceptor" class="org.springframework.orm.hibernate3.HibernateInterceptor">
                                    <property name="sessionFactory" ref="sessionFactory" />
                                </bean>
                            
                                <bean id="CountryImpl"  class="  xx.panditJiDAO.hibernate.CountryImpl">
                                    <property name="sessionFactory" ref="sessionFactory" />
                                </bean>
                            
                                <bean id="CityImpl"  class="  xx.panditJiDAO.hibernate.CityImpl">
                                    <property name="sessionFactory" ref="sessionFactory" />
                                </bean>
                            
                                <bean id="StateImpl"  class="  xx.panditJiDAO.hibernate.StateImpl">
                                    <property name="sessionFactory" ref="sessionFactory" />
                                </bean>
                            
                                <bean id="PersonImpl"  class="  xx.panditJiDAO.hibernate.PersonImpl">
                                    <property name="sessionFactory" ref="sessionFactory" />
                            
                                </bean>
                             
                             
                             
                            </beans>
                            Last edited by void_void; Apr 14th, 2009, 03:44 AM.

                            Comment


                            • #15
                              hibernate conf. file

                              Code:
                              <?xml version="1.0" encoding="UTF-8"?>
                              <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
                              <hibernate-configuration>
                                  <session-factory>
                                      <property name="hibernate.dialect">org.hibernate.dialect.OracleDialect</property>
                                
                                      <mapping class=xxx.PaditJiModel.City"/>
                                      <mapping class="xxx.PaditJiModel.Country"/>
                                      <mapping class="xxx.PaditJiModel.Person"/>
                                      <mapping class="xxx.PaditJiModel.State"/>
                               
                                      
                                  </session-factory>
                              </hibernate-configuration>

                              Comment

                              Working...
                              X