-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Null Pointer Exception in Hibernate Template
PostPosted: Sat Oct 23, 2010 8:33 am 
Newbie

Joined: Sat Oct 23, 2010 8:15 am
Posts: 1
I am working on application which contains Struts and hibernate and i am trying to use HibernateTemplate
Getting exception which is given below

17:35:56,341 DEBUG ExceptionCatcher:141 - Attempting to handle a thrown exception
17:35:56,341 DEBUG ActionCommandBase:49 - Executing org.apache.struts.chain.commands.servlet.ExceptionHandler
17:35:56,341 DEBUG AbstractExceptionHandler:77 - See if actionConfig ActionConfig[cancellable=false,path=/searchc
mmand,validate=true,input=/jsp/search.jsp,name=SearchForm,scope=session,type=org.ird.ivl.presentation.SearchCo
mand has an exceptionConfig for java.lang.NullPointerException
17:35:56,341 DEBUG ActionConfig:940 - findException: look locally for java.lang.NullPointerException
17:35:56,341 DEBUG ActionConfig:948 - findException: look globally for java.lang.NullPointerException
17:35:56,341 DEBUG ActionConfig:940 - findException: look locally for java.lang.RuntimeException
17:35:56,341 DEBUG ActionConfig:948 - findException: look globally for java.lang.RuntimeException
17:35:56,341 DEBUG ActionConfig:940 - findException: look locally for java.lang.Exception
17:35:56,351 DEBUG ActionConfig:948 - findException: look globally for java.lang.Exception
17:35:56,351 DEBUG ActionConfig:940 - findException: look locally for java.lang.Throwable
17:35:56,351 DEBUG ActionConfig:948 - findException: look globally for java.lang.Throwable
17:35:56,351 DEBUG ActionConfig:940 - findException: look locally for java.lang.Object
17:35:56,351 DEBUG ActionConfig:948 - findException: look globally for java.lang.Object
17:35:56,351 WARN AbstractExceptionHandler:95 - Unhandled exception
java.lang.NullPointerException
at org.ird.ivl.persistence.BugsDaoImpl.findBugs(BugsDaoImpl.java:40)
at org.ird.ivl.presentation.SearchCommand.execute(SearchCommand.java:37)
at org.apache.struts.chain.commands.servlet.ExecuteAction.execute(ExecuteAction.java:58)
at org.apache.struts.chain.commands.AbstractExecuteAction.execute(AbstractExecuteAction.java:67)
at org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:51)
at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:191)
at org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:305)
at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:191)
at org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:283)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:619)


In the action page i am using
ublic class BugsDaoImpl{

private HibernateTemplate hibernateTemplate;

public void setSessionFactory(SessionFactory sessionFactory) {
this.hibernateTemplate = new HibernateTemplate(sessionFactory);
}
String query = "FROM Bugs WHERE bug_id=:bug_id";

return this.hibernateTemplate.findByNamedParam(query, "bug_id", 2000);
}

and xml file contains


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"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/b ... -beans.xsd">

<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver" p:prefix="/WEB-INF/jsp/" p:suffix=".jsp" />

<bean id="myDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
<!--<property name="driverClassName" value="com.p6spy.engine.spy.P6SpyDriver"/> -->
<property name="url" value="jdbc:mysql://localhost:3306/spring"/>
<property name="username" value="root"/>
<property name="password" value="password"/>


</bean>

<bean id="mySessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="myDataSource" />
<property name="annotatedClasses">
<list>

<value>org.ird.ivl.entity.Bugs</value>

</list>

</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.show_sql">true</prop>
<!--<prop key="hibernate.hbm2ddl.auto">create</prop>-->
</props>
</property>
</bean>

<bean id="myBugsDAO" class="org.ird.ivl.persistence.BugsDaoImpl">
<property name="sessionFactory" ref="mySessionFactory"/>
</bean>

</beans>


Can any one please help me to find a solution


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.