Page 1 of 2 12 LastLast
Results 1 to 10 of 19

Thread: it Hangs

  1. #1

    Default 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. #2

    Default 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

  3. #3

    Default 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 at 01:45 AM.

  4. #4
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,625

    Default

    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.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  5. #5

    Default 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 at 07:31 AM.

  6. #6

    Default 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...

  7. #7
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,625

    Default

    I suggest you read my whole post ONLY adding a transaction manager isn't enough you will also have to change your hibernate configuration.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  8. #8

    Default ?

    what should i add into my hibernate configuration file?

  9. #9
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,625

    Default

    You shouldn't ADD anything you must REMOVE something.

    Quote 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.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  10. #10

    Default ..!~

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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •