ssh框架中,getHibernateTemplate().find(sqlyou)报了空指针,图中红圈报空指针

打断点输出到控制台,上面都是没有问题的,唯独到了红框这一句就报空指针,yuding.dao这里也没有报空指针,实在不知道是怎么回事了,求大神帮帮忙

图片说明

1个回答

sqlyou上面输出是有值的,对吧。那么就是yudingdao是null,或者con是null,你调试下看看
如果是前者,检查yudingdao在哪里初始化的,如果是通过spring,检查spring
后者的话,检查数据库的配置、连接用的用户名密码、数据库的驱动、还有conn本身的初始化的代码

u011732393
若水三千丈 数据库的配置没有问题,因为我在别的action同样的语句能调用不报错,到了这里宝空指针,还有yudingdao没报空。通过打断点输出到控制台中,sqlyou,和con都输出有值。实现不懂为什么了
4 个月之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
getHibernateTemplate().find()空指针问题
这个问题很怪.我在Junit下测试我的代码时,getHibernateTemplate().find()没有一点问题.当我把它放到Struts1.2的action下就报空指针异常.rn异常如下:rnexception rnjava.lang.NullPointerExceptionrn org.hibernate.tuple.AbstractEntityTuplizer.createProxy(AbstractEntityTuplizer.java:372)rn org.hibernate.persister.entity.AbstractEntityPersister.createProxy(AbstractEntityPersister.java:3121)rn org.hibernate.event.def.DefaultLoadEventListener.createProxyIfNecessary(DefaultLoadEventListener.java:232)rn org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:173)rn org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:87)rn org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:862)rn org.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:830)rn org.hibernate.type.EntityType.resolveIdentifier(EntityType.java:266)rn org.hibernate.type.EntityType.resolve(EntityType.java:303)rn org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:116)rn org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:842)rn org.hibernate.loader.Loader.doQuery(Loader.java:717)rn org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)rn org.hibernate.loader.Loader.doList(Loader.java:2145)rn org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2029)rn org.hibernate.loader.Loader.list(Loader.java:2024)rn org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:375)rn org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:308)rn org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:153)rn org.hibernate.impl.SessionImpl.list(SessionImpl.java:1106)rn org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)rn org.springframework.orm.hibernate3.HibernateTemplate$29.doInHibernate(HibernateTemplate.java:849)rn org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:372)rn org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:840)rn org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:836)rn com.ace.core.dao.impl.PersonDaoBean.getTPersonByName(PersonDaoBean.java:110)rn sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)rn sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)rn sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)rn java.lang.reflect.Method.invoke(Unknown Source)rn org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:304)rn org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:172)rn org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:139)rn org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:107)rn org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:161)rn org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)rn $Proxy7.getTPersonByName(Unknown Source)rn com.ace.core.business.impl.PersonManagerBean.login(PersonManagerBean.java:110)rn com.ace.core.struts.action.LoginAction.execute(LoginAction.java:53)rn org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)rn org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)rn org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)rn org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)rn javax.servlet.http.HttpServlet.service(HttpServlet.java:710)rn javax.servlet.http.HttpServlet.service(HttpServlet.java:803)rnrn这是我的applicationContext.xml:rnrnrnrnrn rn hibernate.cfg.xmlrn rnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrn rn rn rn rn rn rn rn rn rn PROPAGATION_REQUIREDrn PROPAGATION_REQUIREDrn PROPAGATION_REQUIREDrn PROPAGATION_REQUIREDrn PROPAGATION_REQUIRED,readOnlyrn rn rnrnrn rn rn rn rn rn rn rn rn rn PROPAGATION_REQUIREDrn PROPAGATION_REQUIREDrn PROPAGATION_REQUIREDrn PROPAGATION_REQUIREDrn PROPAGATION_REQUIRED,readOnlyrn rn rnrnrnrn rn rn rn rn rn rnrnrnPerManagerBean的Login方法:rn public Person login(String name, String password) rn TPerson tPerson = personDao.getTPersonByName(name);rn String md5Password = "";rn try rn md5Password = MD5HashUtil.hashCode(password);rn if(!(tPerson.getPassword().equals(md5Password)))rn return null;rn rn TRole tRole = tPerson.getTRole();rn if(tRole.getId() == 2)rn AdminBean admin = getAdminResouce();rn admin.setTPerson(tPerson);rn return admin;rn else if(tRole.getId() == 3)rn UserBean user = getUserResouce();rn user.setTPerson(tPerson);rn return user;rn else if(tRole.getId() == 1)rn SuperAdminBean superAdmin = getSuperAdminResouce();rn superAdmin.setTPerson(tPerson);rn return superAdmin;rn rn catch (NoSuchAlgorithmException e) rn // TODO Auto-generated catch blockrn e.printStackTrace();rn rn return null;rn rnPersonDaoBean的getTPersonByName方法:rn public TPerson getTPersonByName(String name)rn HibernateTemplate ht = getHibernateTemplate();rn List list = ht.find("from TPerson tp where tp.name=?",name);rn if(list.size() != 0)rn TPerson tPerson = (TPerson) list.get(0);rn return tPerson;rn elsern return null;rn
怪异的getHibernateTemplate().find()空指针问题
这个问题很怪.我在Junit下测试我的代码时,getHibernateTemplate().find()没有一点问题.当我把它放到Struts1.2的action下就报空指针异常.后来我改用Hibernate的session, 在query的时候还是出现同样的问题.关键只是在action中才出现,自己的测试代码中不出现.希望大家帮我看看. rn异常如下: rnexception rnjava.lang.NullPointerException rnorg.hibernate.tuple.AbstractEntityTuplizer.createProxy(AbstractEntityTuplizer.java:372) rnorg.hibernate.persister.entity.AbstractEntityPersister.createProxy(AbstractEntityPersister.java:3121) rnorg.hibernate.event.def.DefaultLoadEventListener.createProxyIfNecessary(DefaultLoadEventListener.java:232) rnorg.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:173) rnorg.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:87) rnorg.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:862) rnorg.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:830) rnorg.hibernate.type.EntityType.resolveIdentifier(EntityType.java:266) rnorg.hibernate.type.EntityType.resolve(EntityType.java:303) rnorg.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:116) rnorg.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:842) rnorg.hibernate.loader.Loader.doQuery(Loader.java:717) rnorg.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224) rnorg.hibernate.loader.Loader.doList(Loader.java:2145) rnorg.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2029) rnorg.hibernate.loader.Loader.list(Loader.java:2024) rnorg.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:375) rnorg.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:308) rnorg.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:153) rnorg.hibernate.impl.SessionImpl.list(SessionImpl.java:1106) rnorg.hibernate.impl.QueryImpl.list(QueryImpl.java:79) rnorg.springframework.orm.hibernate3.HibernateTemplate$29.doInHibernate(HibernateTemplate.java:849) rnorg.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:372) rnorg.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:840) rnorg.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:836) rncom.ace.core.dao.impl.PersonDaoBean.getTPersonByName(PersonDaoBean.java:110) rnsun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) rnsun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) rnsun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) rnjava.lang.reflect.Method.invoke(Unknown Source) rnorg.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:304) rnorg.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:172) rnorg.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:139) rnorg.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:107) rnorg.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:161) rnorg.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204) rn$Proxy7.getTPersonByName(Unknown Source) rncom.ace.core.business.impl.PersonManagerBean.login(PersonManagerBean.java:110) rncom.ace.core.struts.action.LoginAction.execute(LoginAction.java:53) rnorg.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431) rnorg.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236) rnorg.apache.struts.action.ActionServlet.process(ActionServlet.java:1196) rnorg.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432) rnjavax.servlet.http.HttpServlet.service(HttpServlet.java:710) rnjavax.servlet.http.HttpServlet.service(HttpServlet.java:803) rnrn这是我的applicationContext.xml: rn[code="xml"]rn rn rnrn rn rnhibernate.cfg.xml rn rn rnrn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rnPROPAGATION_REQUIRED rnPROPAGATION_REQUIRED rnPROPAGATION_REQUIRED rnPROPAGATION_REQUIRED rnPROPAGATION_REQUIRED,readOnly rn rn rn rn rn rn rn rn rn rn rn rn rn rnPROPAGATION_REQUIRED rnPROPAGATION_REQUIRED rnPROPAGATION_REQUIRED rnPROPAGATION_REQUIRED rnPROPAGATION_REQUIRED,readOnly rn rn rn rn rn rn rn rn rn rn rn rn rn rn[/code]rnrnPerManagerBean的Login方法: rn[code="java"]rnpublic Person login(String name, String password) rnTPerson tPerson = personDao.getTPersonByName(name); rnString md5Password = ""; rntry rnmd5Password = MD5HashUtil.hashCode(password); rnif(!(tPerson.getPassword().equals(md5Password))) rnreturn null; rn rnTRole tRole = tPerson.getTRole(); rnif(tRole.getId() == 2) rnAdminBean admin = getAdminResouce(); rnadmin.setTPerson(tPerson); rnreturn admin; rnelse if(tRole.getId() == 3) rnUserBean user = getUserResouce(); rnuser.setTPerson(tPerson); rnreturn user; rnelse if(tRole.getId() == 1) rnSuperAdminBean superAdmin = getSuperAdminResouce(); rnsuperAdmin.setTPerson(tPerson); rnreturn superAdmin; rn rn catch (NoSuchAlgorithmException e) rn// TODO Auto-generated catch block rne.printStackTrace(); rn rnreturn null; rn rn[/code]rnrnPersonDaoBean的getTPersonByName方法: rn[code="java"]rnpublic TPerson getTPersonByName(String name) rnList list = getHibernateTemplate().find("from TPerson tp where tp.name=?",name); rnif(list.size() != 0) rnTPerson tPerson = (TPerson) list.get(0); rnreturn tPerson; rnelse rnreturn null; rnrn[/code]rn
getHibernateTemplate().find(hql, username);空指针
各位大神,出现这个问题困扰我一天了,小弟实在无力,逛遍所有贴吧,无人能答,寄希望于此了。rnrn[img=https://img-bbs.csdn.net/upload/201509/01/1441101462_534542.jpg][/img]rn[img=https://img-bbs.csdn.net/upload/201509/01/1441101509_133933.jpg][/img]rn[img=https://img-bbs.csdn.net/upload/201509/01/1441101485_322078.jpg][/img]rnspring配置rn[code=html]rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn [/code]rn
SSH编程报了个空指针
严重: Servlet.service() for servlet action threw exceptionrnjava.lang.NullPointerExceptionrn at com.dianxun.action.SendTieziAction.execute(SendTieziAction.java:54)rn at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:425)rn at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:228)rn at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)rn at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462)rn at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)rn at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)rn at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)rn at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)rn at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:96)rn at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)rn at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)rn at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)rn at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)rn at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)rn at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)rn at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)rn at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)rn at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)rn at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849)rn at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)rn at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454)rn at java.lang.Thread.run(Thread.java:619)rnrnrnAction里的代码:public ActionForward execute(ActionMapping mapping, ActionForm form,rn HttpServletRequest request, HttpServletResponse response) rn // TODO Auto-generated method stubrn SendTieziForm sendForm = (SendTieziForm) form;rn rn int id =Integer.parseInt(sendForm.getXid());rn String contxtString = sendForm.getTxtCon();rn String username = sendForm.getUname();rn System.out.println(id+","+contxtString+","+username);rn ArrayList list= personService.getTopicDate("from Topic where id = "+id);//这里报空指针了rn Topic topic2 = new Topic();rn topic2.setParented(id);rn topic2.setFroumid(list.get(0).getFroumid());rn topic2.setUsername(username);rn topic2.setTzcontent(contxtString);rn Timestamp t = new Timestamp(new Date().getTime());rn topic2.setFtimes(t);rn personService.save(topic2);rn return null;rn rnrnrngetTopicDate方法:rnpublic ArrayList getTopicDate(String sqlString)rn rn ArrayList list = new ArrayList();rn Query query = sessionFactory.getCurrentSession().createQuery(sqlString);rn List list2 = query.list();rn for( int i=0;i
ssh 框架整合 报空指针
rnrnrn大哥们!帮我看看啊 rn我整合后怎么老报这个错误,经测试struts-spring整合是没错,加上hibernate就有错误了rn.lang.NullPointerExceptionrn hibernate.LoginDAO.save(LoginDAO.java:30)rn com.struts.action.LoginAction.execute(LoginAction.java:56)rn org.springframework.web.struts.DelegatingActionProxy.execute(DelegatingActionProxy.java:106)rn org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)rn org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)rn org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)rnrn其实就是getHibernateTemplate().save(transientInstance); 这里getHibernateTemplate()得到的是null.rn下面是我spring的配置文件:rnrnrnrnrn rn oracle.jdbc.driver.OracleDriverrn rn rn jdbcracle:thin:@192.168.0.51:1521:nnmmrn rn rn yarn rn rn yarn rnrnrn rn rn rn rn rn rn org.hibernate.dialect.Oracle9Dialectrn rn rn rn rn rn hibernate/Login.hbm.xmlrn rn rnrn rn rn rnrn rnrnrn我new了个LoginDAO,是不是不能new?rn是不是一定要这样?rnFileSystemXmlApplicationContext ctx = new FileSystemXmlApplicationContext(fileName);rnLoginDAOu=(LoginDAO)ctx.getBean("LoginDAO");rn
SSH插入数据,报空指针???
SSH做了一个小例子,save的时候报空指针,主要是hibernate封装jdbc时报空指针,代码如下:rn[color=#FF0000]ACTION:[/color]UserService userService = new UserService();rn UserDao userDao = new UserDao();rn User user = new User();rn user.setName(name);rn user.setPassword(password);rn user.setEmail(email);rn user.setPhone(phone);rn user.setCompany(company);rn user.setAddress(address);rn user.setCreateTime(new Date());rn user.setModificationTime(new Date());rn[color=#FF6600]37行------------- userDao.save(user)[/color]-------------------------------------------rn暂时没调用service,[color=#FF0000]dao[/color]的代码:rn@Repositoryrnpublic class UserDao extends HibernateDao rnrn-------------------------------------------rn[color=#FF0000]HibernateDao[/color]里面的save部分代码:rnpublic void save(T o) rn getHibernateTemplate().saveOrUpdate(o);rn rn--------------------------------------------rn[color=#FF0000]spring.xml:[/color]rnrn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn org.hibernate.dialect.MySQLDialectrn truern update rn threadrn rn falsern truern truern truern 50rn 50rn true rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn--------------------------------------------------------------------------rn报错的代码就是空指针,没头绪啊:rnjava.lang.NullPointerException rn com.shop.dao.base.HibernateDao.save(HibernateDao.java:672)rn com.shop.action.RegisterAction.execute(RegisterAction.java:37)rnrnrn[color=#FF0000]前辈们帮帮忙看看。。。愁死我了[/color]
SSH框架getHibernateTemplate().find()报异常。
rnpackage Dao;rnrnimport java.util.List;rnimport org.hibernate.SQLQuery;rnimport org.hibernate.Session;rnimport org.hibernate.Transaction;rnimport org.springframework.orm.hibernate3.support.HibernateDaoSupport;rnrnpublic class BaseDao extends HibernateDaoSupport implements IBaseDaornrn public Object findById(Class cls, String id) rn return getHibernateTemplate().get(cls, id);rn rnrn public List select(String sql) rn /* rn Session ss=getHibernateTemplate().getSessionFactory().getCurrentSession();rn Transaction transaction =null;rn ss.beginTransaction();rn SQLQuery result=null;rn try rn result = ss.createSQLQuery(sql);rn System.out.println(sql);rn return result.list();rn catch (Exception e) rn e.printStackTrace();rn return null;rn finally rn transaction.commit();rn rn */rn return getHibernateTemplate().find(sql);rn rn rn public static void main(String[] args) rn new BaseDao().select("from AssetsTb");rn rnrnrn异常:rnException in thread "main" java.lang.NullPointerExceptionrn at Dao.BaseDao.select(BaseDao.java:30)rn at Dao.BaseDao.main(BaseDao.java:35)rnrnrnrnrnrnrn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rnrnrnrnrnrnrnrn rn rn rn rn rn rn rn rn rn rn rn rn rn rn org.hibernate.dialect.Oracle9Dialectrn rn rn rn rn vo/AssetsTb.hbm.xmlrn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rnrn
getHibernateTemplate().find(queryString) 返回空指针 求解!
public List findByIsbn(Integer i)rn log.debug("finding all Book instances");rn try rn /*Session session = this.getHibernateTemplate().getSessionFactory().openSession();rn Query q = session.createQuery("from Book where isbn = "+i+"");rn List list =q.list();rn session.close();rn return list;*/rn rn String queryString = "from Book c where c.isbn = "+i+" ";rn System.out.println("dadada:"+getHibernateTemplate().find(queryString));rn return getHibernateTemplate().find(queryString);rnrnrndao方法 换了几种写法 总是报空指针 郁闷啊! 求各位帮忙~谢谢 通过hibernate反向工程的 所以肯定是有hbm文件
SSH项目报空指针错误
[color=#FF0000]错误提示:java.lang.NullPointerException[/color]rn org.hr.action.UserAction.login(UserAction.java:33)rn sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)rn sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)rn sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)rn java.lang.reflect.Method.invoke(Method.java:597)rn com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:441)rn com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:280)rn com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:243)rn com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:165)rn com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)rn com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)rn com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:252)rn org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)rn com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)rn com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)rn com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:122)rn com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)rn com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195)rn com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)rn com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)rn com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195)rn com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)rn com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)rn com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:179)rn com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)rn org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:75)rn com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)rn org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:94)rn com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)rn org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:235)rn com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)rn com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:89)rn com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)rn com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:130)rn com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)rn org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:267)rn com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)rn com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:126)rn com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)rn com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:138)rn com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)rn com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)rn com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:165)rn com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)rn org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)rn com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)rn com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:179)rn com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)rn com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:176)rn com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)rn org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:52)rn org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:488)rn org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)rn org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91)rnrn[color=#FF0000]登录的jsp:login.jsp[/color]rn<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>rn<%@ taglib prefix="s" uri="/struts-tags" %>rnrnrn rn 人事管理-系统登录rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn /login.jsprn rn rn /index.jsprn /login.jsprn rn rnrn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn 系统登录rn rn rn rn rn rn rn rn rn 用户名:rn rn rn rn rn rn rn rn 密码:rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rnrn[color=#FF0000]UserAction报错的地方:[/color]rn public String login() throws Exceptionrn rn System.out.println("test");rn [color=#FF0000]Users user=userservice.check(users.getUserName(),users.getUserPwd());[/color]rn if(users!=null)rn rn Map session=(Map)ActionContext.getContext().getSession();rn session.put("user",user);rn this.users=null;rn return SUCCESS;rn elsern rn return ERROR;rn rn rn[color=#FF0000]struts的配置:[/color]rnrnrn rn[color=#FF0000]applicationContext的相关配置:[/color]rn rn rn rn并且struts-spring-plugin插件也放进去了。求各位大佬知道
ssh 开发,报空指针错误!!!
我点击删除,已经获得了ID的值,可是好像编译到 getHibernateTemplate().delete(getMessage(id));报错rnServlet.service() for servlet action threw exceptionrnjava.lang.NullPointerExceptionrn at org.hibernate.tuple.AbstractEntityTuplizer.createProxy(AbstractEntityTuplizer.java:372)rn at org.hibernate.persister.entity.AbstractEntityPersister.createProxy(AbstractEntityPersister.java:3121)rn at org.hibernate.event.def.DefaultLoadEventListener.createProxyIfNecessary(DefaultLoadEventListener.java:232)rn at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:173)rn at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:87)rn at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:862)rn at org.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:830)rn at org.hibernate.type.EntityType.resolveIdentifier(EntityType.java:266)rn at org.hibernate.type.EntityType.resolve(EntityType.java:303)rn at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:116)rn at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:842)rn at org.hibernate.loader.Loader.doQuery(Loader.java:717)rn at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)rn at org.hibernate.loader.Loader.loadEntity(Loader.java:1785)rn at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:47)rn at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:41)rn at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:2730)rn at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:365)rn at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:346)rn at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:123)rn at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:177)rn at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:87)rn at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:862)rn at org.hibernate.impl.SessionImpl.get(SessionImpl.java:799)rn at org.hibernate.impl.SessionImpl.get(SessionImpl.java:792)rn at org.springframework.orm.hibernate3.HibernateTemplate$1.doInHibernate(HibernateTemplate.java:470)rn at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:372)rn at org.springframework.orm.hibernate3.HibernateTemplate.get(HibernateTemplate.java:464)rn at org.springframework.orm.hibernate3.HibernateTemplate.get(HibernateTemplate.java:458)rn at com.hibernate.blog.hibernate.dao.topicmessageHibernateDao.getMessage(topicmessageHibernateDao.java:20)rn at com.hibernate.blog.hibernate.dao.topicmessageHibernateDao.deleteMessage(topicmessageHibernateDao.java:15)rn at com.hibernate.blog.server.topicmessageServer.deleteMessage(topicmessageServer.java:18)rn at com.hibernate.struts.action.TopicAction.deletetopic(TopicAction.java:125)rn at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)rn at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)rn at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)rn at java.lang.reflect.Method.invoke(Unknown Source)rn at org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:269)rn at org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:170)rn at org.springframework.web.struts.DelegatingActionProxy.execute(DelegatingActionProxy.java:110)rn at org.apache.struts.chain.commands.servlet.ExecuteAction.execute(ExecuteAction.java:58)rn at org.apache.struts.chain.commands.AbstractExecuteAction.execute(AbstractExecuteAction.java:67)rn at org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:51)rn at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)rn at org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:304)rn at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)rn at org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:283)rn at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)rn at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:449)rn at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)rn at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)rn at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)rn at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)rn at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:96)rn at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:75)rn at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)rn at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)rn at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198)rn at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:75)rn at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)rn at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)rn at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)rn at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)rn at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)rn at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)rn at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)rn at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:261)rn at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)rn at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:581)rn at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)rn at java.lang.Thread.run(Unknown Source)
ssh action类报空指针
rnrnrnrn rn rn rn rn rn rn rn rn rnrn rn rn rn rn rn rn org.hibernate.dialect.MySQLDialectrn rn rn rn rn rn com/jinshuo/entity/Admin.hbm.xmlrn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rnrnaction类执行的时候报空指针。rnrnpackage com.jinshuo.action;rnrnimport javax.servlet.http.HttpSession;rnrnimport org.apache.struts2.ServletActionContext;rnimport org.springframework.context.ApplicationContext;rnimport org.springframework.context.support.ClassPathXmlApplicationContext;rnrnimport com.jinshuo.entity.Admin;rnimport com.jinshuo.service.impl.AdminServiceImpl;rnimport com.jinshuo.service.inter.AdminService;rnimport com.opensymphony.xwork2.ActionSupport;rnrnpublic class AdminAction extends ActionSupportrn private AdminService adminService;rnrn public AdminService getAdminService() rn return adminService;rn rnrn public void setAdminService(AdminService adminService) rn this.adminService = adminService;rn rn public Admin admin;rnrn public Admin getAdmin() rn return admin;rn rnrn public void setAdmin(Admin admin) rn this.admin = admin;rn rn public String login() rn System.out.println("00");rn System.out.println(admin.getName());rn System.out.println(admin.getPassword());rn rn /* ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");rn System.out.println("0");rn AdminServiceImpl adminServiceImpl = (AdminServiceImpl) ctx.getBean("adminservice");*/rn System.out.println("save-begin");rn [color=#FF0000][/color]adminService.addAdmin(admin);//这里报空指针。。rn System.out.println("save-end");rn rn Admin adm = adminService.login(admin);rn System.out.println("02");rn rn HttpSession session=ServletActionContext.getRequest().getSession();rn System.out.println("03");rn if (adm != null)rn session.setAttribute("admin_info", adm);rn return "loginsuccess";rn rn return INPUT; rn rn public String execute()rn System.out.println("123");rn return null;rn rnrnrn
ssh2框架,报空指针错误.
loginAction中的验证用户名的方法:rnrnpublic String loginValid(String name, String pass)rn System.out.print(name+"oo");rn String returninfo = "yes";rn List listuser = null;rn try rn listuser = service.findByUsername(name[color=#FF0000]);//错误显示在这里报空指针错误.[/color] catch (Exception e) rn e.printStackTrace();rn rn System.out.print(listuser.size()+"uuuuuuuu");rn if(listuser == null) rn returninfo = "nouname";return returninfo;rn rn try rn listuser = service.validateUser(name, pass);rn catch (Exception e) rn System.out.print(e.getMessage());rn rn if(listuser == null) rn returninfo = "nopass";return returninfo;rn rn return returninfo;rn rnrn这个方法我调试过了,service.findByUsername()没有执行.
SSH 空指针
2010-02-18 15:04:56,453 [WARN ] Unhandled Exception thrown: class java.lang.NullPointerExceptionrn2010-2-18 15:04:56 org.apache.catalina.core.StandardWrapperValve invokern严重: Servlet.service() for servlet action threw exceptionrnjava.lang.NullPointerExceptionrn at com.johe.service.impl.JsxxManagerImpl.getJsList(JsxxManagerImpl.java:26)rn at com.johe.service.impl.JsxxManagerImpl.getJsList(JsxxManagerImpl.java:38)rn at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)rn at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)rn at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)rn at java.lang.reflect.Method.invoke(Unknown Source)rn at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:335)rn at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:181)rn at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:148)rn at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)rn at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:170)rn at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:176)rn at $Proxy20.getJsList(Unknown Source)rn at com.johe.struts.action.JsxxAction.search(JsxxAction.java:146)rn at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)rn at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)rn at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)rn at java.lang.reflect.Method.invoke(Unknown Source)rn at org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:274)rn at com.johe.struts.action.BaseAction.execute(BaseAction.java:179)rn at org.springframework.web.struts.DelegatingActionProxy.execute(DelegatingActionProxy.java:106)rn at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)rn at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)rn at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)rn at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)rn at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)rn at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)rn at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)rn at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)rn at com.johe.util.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:68)rn at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)rn at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)rn at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)rn at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)rn at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)rn at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)rn at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)rn at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)rn at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)rn at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)rn at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)rn at java.lang.Thread.run(Unknown Source)rn[code=Java]package com.johe.service.impl;rnrnimport java.util.ArrayList;rnimport java.util.List;rnrnimport com.johe.dao.JsxxDAO;rnimport com.johe.model.Jsxx;rnimport com.johe.model.User;rnimport com.johe.page.Page;rnimport com.johe.page.PageConfig;rnimport com.johe.service.JsxxManager;rnrnpublic class JsxxManagerImpl extends BaseManager implements JsxxManager rnrn private JsxxDAO dao;rnrn public void setJsDAO(JsxxDAO DAO) rn dao = DAO;rn rnrn public Jsxx getJs(String PK) rn return dao.getJs(PK);rn rnrn public List getJsList(String sqls) rn//26行rn return dao.getJsList(sqls);rn rnrn public Page getJsList(String whereSQL, String orderSQL, int pageNumber,rn String currentId) rn if (whereSQL.equals("null"))rn whereSQL = "";rn elsern whereSQL = " where 1=1 " + whereSQL;rn int currentRowNumber = -1;rn ArrayList alist = new ArrayList();rn int i = 0;rn//38行rn alist = (ArrayList) getJsList(whereSQL);rn if (!currentId.equals("")) rn for (int size = 0; size < alist.size(); size++) rn Jsxx tempdd = (Jsxx) alist.get(size);rn if (currentId.equals(tempdd.getJsbh())) rn currentRowNumber = i;rn break;rn rn i = i + 1;rn rn rn Page pagetemp = getPageFromList(alist, pageNumber, currentRowNumber);rn return pagetemp;rn rnrn public void removeJs(String PK) rn dao.removeJs(PK);rn rnrn public void saveJs(Jsxx jsgl) rn dao.saveJs(jsgl);rn rnrn[/code]rnrn
SSH框架中在Action中调用DAO报空指针
在使用MyEclipse10中进行了SSH(Struts2)框架的整合,使用了MyEclipse10中Hibernate自动生成DAO的方法生成了相关配置和DAO,我也在Spring配置文件中配置了相关使用的Action类,然而当我在Action中使用DAO时却报空指针异常,但是当我使用了一个Service类来使用这个DAO却一切正常(配置文件配置正确)。求高人指点!!
SSH整合中页面报500,空指针
这是异常页面报的异常rn[code=java]java.lang.NullPointerExceptionrn com.cx.action.DriverDetailsAction.doDetails(DriverDetailsAction.java:38)rn sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)rn sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)rn sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)rn java.lang.reflect.Method.invoke(Method.java:606)[/code]rn这是action里面的代码,测试方法没错,debug中传入的值也都收到了rn[code=java]rnDriver driver = (Driver) session.getAttribute("driver");rndriverdetails.setDriver(driver);rndriverDetailsBiz.addDetail(driverdetails);rnDriverdetails driverdetails2 = driverDetailsBiz.findDetailByDriver(driver);rndriver.setDriverdetails(driverdetails2);rndriverBiz.updateDriver(driver);rn[/code]rn找了两天了,哪有错啊。求解求解
整合ssh使用hibernateTemplate的find方法报空指针?
这是entity类rn[code=Java]rnpackage com.tjw.mysql.model;rnimport javax.annotation.Generated;rnimport javax.persistence.Entity;rnimport javax.persistence.GeneratedValue;rnimport javax.persistence.Id;rnrnimport org.springframework.stereotype.Component;rnrn@Component("admin")rn@Entityrnpublic class Admin rn private int id ;rn private String name ;rn private String password ;rn private int grade ;rn rn rn @Idrnrn public int getId() rn return id;rn rn rn public void setId(int id) rn this.id = id;rn rn public String getName() rn return name;rn rn public void setName(String name) rn this.name = name;rn rn public String getPassword() rn return password;rn rn public void setPassword(String password) rn this.password = password;rn rn public int getGrade() rn return grade;rn rn public void setGrade(int grade) rn this.grade = grade;rn rnrnrn[/code]rnrn这是实现类rn[code=Java]rnpackage com.tjw.mysql.dao.impl;rnrnimport java.io.Serializable;rnimport java.util.HashSet;rnimport java.util.List;rnimport java.util.Set;rnrnimport javax.annotation.Resource;rnimport javax.jms.Session;rnrnimport org.hibernate.Query;rnimport org.springframework.orm.hibernate3.HibernateTemplate;rnimport org.springframework.stereotype.Component;rnrnrnimport com.tjw.mysql.dao.AdminDAO;rnimport com.tjw.mysql.model.Admin;rnrnrnrn@Component("adminDAO")rnpublic class AdminImpl implements AdminDAOrn private HibernateTemplate hibernateTemplate; rn public void doCreate(Admin admin) rn // TODO Auto-generated method stubrn hibernateTemplate.save(admin);rn rnrn public boolean doCreateOrdoUpdate(Admin admin) rn // TODO Auto-generated method stubrn return false;rn rnrn public void doDelete(Admin admin) rn rn this.hibernateTemplate.delete(admin);rnrn rnrn public void doUpdate(Admin admin) rn // TODO Auto-generated method stubrn this.hibernateTemplate.update(admin);rn rnrn public List findAll()rn // TODO Auto-generated method stubrn rnrn List list = (List)this. hibernateTemplate.find("from Admin");rn return list ; rn rnrn public Admin findById(int id) rn // TODO Auto-generated method stubrn return null;rn rnrn public int getCount() rn // TODO Auto-generated method stubrn return 0;rn rnrn public HibernateTemplate getHibernateTemplate() rn return hibernateTemplate;rn rn @Resourcern public void setHibernateTemplate(HibernateTemplate hibernateTemplate) rn this.hibernateTemplate = hibernateTemplate;rn rnrnrn[/code]rnrn这是配置文件rn[code=Java]rnrnrn rn rn rn rnrn rnrn rn rn classpath:jdbc.propertiesrn rn rnrn rn rn rn rn rn rnrn rn rn rn rn rn com.tjw.mysql.modelrn rn rn rn rn rn rn org.hibernate.dialect.MySQLDialectrn rn truern rn rn rn rnrn rn rn rnrn rn rn rn rnrn rn rn rn rn rn rnrn rn rn rnrnrnrn[/code]rnrn简单地这样调用rnAdminImpl adminImpl = new AdminImpl();rnadminImpl.findAll();rn报出异常rnjava.lang.NullPointerExceptionrn at com.tjw.mysql.dao.impl.AdminImpl.findAll(AdminImpl.java:52)rn at com.tjw.mysql.model.TestAdmin.testStudent(TestAdmin.java:101)rn at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)rn at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)rn at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)rn at java.lang.reflect.Method.invoke(Unknown Source)rn at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)rn at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)rn at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)rn at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)rn at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76)rn at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)rn at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)rn at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)rn at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)rn at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)rn at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)rn at org.junit.runners.ParentRunner.run(ParentRunner.java:236)rn at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38)rn at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)rn at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)rn at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)rn at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)rn at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)rnrn这是为什么呢?我在beans.xml配置文件里不是把sessionFactory和hibernateTemplate都注入了吗怎么还出现空指针的异常呢
ssh整合getHibernateTemplate().find()报空指针异常
[color=darkred][/color]rnapplicationContext.xml文件:rnrnrnrnrn rn rn rn rn rn rn rn rn rn rn rn rn rn rn org.hibernate.dialect.SQLServerDialectrn rn rn truern rn rn rn rn rn com/chen/model/TblFwlx.hbm.xmlrn com/chen/model/TblFwxx.hbm.xmlrn com/chen/model/TblJd.hbm.xmlrn com/chen/model/TblQx.hbm.xmlrn com/chen/model/TblUser.hbm.xmlrn rnrn rn rnrnrnrnrnapplicationcontext-aop.xml代码:rnrnrnrnrn rn rn rnrnrn rn rn rn rn rn rn rn rnrn rn rn rn rnrnrnrnFwxxAction代码:rnrnrnrnpublic class FwxxAction extends DispatchAction rn private FwxxDao fwxxDao; rn public FwxxDao getFwxxDao() rn return fwxxDao;rn rn public void setFwxxDao(FwxxDao fwxxDao) rn this.fwxxDao = fwxxDao;rn rn @Overridern protected ActionForward unspecified(ActionMapping mapping, ActionForm form,rn HttpServletRequest request, HttpServletResponse response)rn throws Exception rn return doList(mapping, form, request, response);rn rn public ActionForward doList(ActionMapping mapping, ActionForm form,rn HttpServletRequest request, HttpServletResponse response)rn throws Exception rn System.out.println("in..........doList");rn System.out.println("fwxxDao======="+fwxxDao);rn int index=1;rn int pageSize=5;rn tryrn String str=request.getParameter("index");rn index=Integer.parseInt(str);rn rn catch(Exception e)rn rn rn List list=fwxxDao.getAll();rn request.setAttribute("list", list);rn return mapping.findForward("fwxxList");rn rn rn rnrnrnrnDao代码:rnrnpackage com.cao.dao;rnrnimport java.util.List;rnrnimport com.cao.model.tblFwxx;rnrnpublic class FwxxDao extends BaseDao rnrn rn public FwxxDao() rn super.cls=tblFwxx.class;rn rnrn public List getFwxx()rn return super.getAll(); rn rn rnrnrnBaseDao代码:rnrnpublic class BaseDao extends HibernateDaoSupport rnrn protected Class cls;rnrn public List getAll()rn rn return getHibernateTemplate().findByExample(cls);rn rnrnrnrnstruts-config.xml:rnrnrnrnrnrn rn rn rnrn rnrn rn rn rn rn rn rnrn rn rn rn rnrnrnrnaction-servlet.xml代码:rnrnrnrn rn rnrnrnweb.xml代码:rnrnrnrnrnrn rn rn rn contextConfigLocationrn classpath:applicationContext-*.xmlrn rn rn rn rn rn encodingFilterrn org.springframework.web.filter.CharacterEncodingFilterrn rn encodingrn UTF-8rn rn rn rn rn rn hibernateFilterrn org.springframework.orm.hibernate3.support.OpenSessionInViewFilterrn rn rn rn encodingFilterrn *.dorn rnrn rn hibernateFilterrn *.dorn rn rn rn rn org.springframework.web.context.ContextLoaderListenerrn rn rn rn actionrn org.apache.struts.action.ActionServletrn rn configrn /WEB-INF/struts-config.xmlrn rn rn debugrn 3rn rn rn detailrn 3rn rn 0rn rn rn actionrn *.dorn rn rn index.jsprn rnrnrnrn最后运行,getHibernateTemplate()为空,调用它的find方法抛空指针异常rnrnrn用ApplicationContext con=new ClassPathXmlApplicationContext("applicationContext-*.xml");rncon.getBean("FwxxDao");rn可以得到对象并可以调它的方法
适配器getView 方法报了空指针
适配器getView 方法报了空指针 @Override public View getView(int position, View convertView, ViewGroup parent) { // TODO Auto-generated method stub ViewHolder holder=null; if (convertView==null) { convert
jsp中调用dao的getHibernateTemplate()时,报空指针
jsp中调用dao的getHibernateTemplate()时,报空指针
新手 Spring 中的 getHibernateTemplate() 空指针 疯了
这是我的DAOrnpublic class UserDaoImpl extends HibernateDaoSupport implements UserDAOrn public User findUserByName(String name) rn System.out.println(getHibernateTemplate()); //输出nullrn//空指针的地方 List list = this.getHibernateTemplate().find("from User as user where user.userName='admin'");rn if (list == null || list.size() == 0) rn return null;rn rn rnrnrn错误信息rnrnnullrn2008-9-9 23:06:04 org.apache.catalina.core.StandardWrapperValve invokern严重: Servlet.service() for servlet action threw exceptionrnjava.lang.NullPointerExceptionrn at com.allen.dao.hib.UserDaoImpl.findUserByName(UserDaoImpl.java:137)rn at com.allen.service.spring.LoginServiceImp.userLogin(LoginServiceImp.java:15)rn at com.allen.action.LoginAction.login(LoginAction.java:19)rn at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)rn at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)rn at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)rn at java.lang.reflect.Method.invoke(Unknown Source)rn at org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:270)rn at org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:187)rn at org.apache.struts.actions.MappingDispatchAction.execute(MappingDispatchAction.java:169)rn at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)rn at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)rn at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)rn at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)rn at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)rn at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)rn at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)rn at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)rn at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)rn at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)rn at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)rn at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)rn at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)rn at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)rn at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)rn at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)rn at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)rn at java.lang.Thread.run(Unknown Source)rnrnrnrn我的Spring配置文件rnrnrnrnrn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn org.hibernate.dialect.MySQLDialectrn rn rn rn rn rn com/allen/model/User.hbm.xmlrn rn rn rn rn rn rn rn rn rn rn rn rnrnrn本人新手刚学spring 问题崩溃两天 高手给看一下
AIDL中service报空指针
AIDL中service报空指针: 很可能是intent的隐式调用没有添加action配置文件 <service android:name=".MusicService" android:enabled="true" android:exported="true"> <intent-fi
skb中的mac_header报空指针
用netfilter编写内核模块,放在ARM开发板上,不过运行的时候因为报空指针内核崩溃。rn后来查明在钩子函数中的skb->mac_header地址为空,也就是0x00000000,但是skb的地址确为0xc0470620,不为空。rnskb->mac_header的地址不应该是skb的地址加上偏移量得到的嘛,为什么会为空呢?rn本人刚学习内核,有很多方面不懂,还请各位多多指教!
bug ——setContentView 报空指针
今天跳转 Activity 的时候莫名其动不了,编译没报错。查了好一会才发现是标签大小写混了。(估计是打太快enter了,智能提示没跟上,233) &amp;lt;view     android:layout_width=&quot;match_parent&quot;     android:background=&quot;@color/backgroundGray&quot;     android:layout_height=&quot;1d...
支付宝demo报空指针
配置好信息后,运行demo,在 sign = URLEncoder.encode(sign, "UTF-8"); 这一行报空指针。这是由于支付宝针对的版本不同所造成的, 解决办法:找到SignUtils类, //添加 “BC” KeyFactory keyf = KeyFactory.getInstance(ALGORITHM,"BC"); 再次运行,一切正常。
报空指针错
为什么在pid = Integer.parseInt(strPid);里报空指针错那?rnrnrn<%@ page language="java" contentType="text/html; charset=GBK"rn pageEncoding="GBK"%>rn<%@ page import="com.jnkaixin.shopping.*"%>rn<%@ include file="_sessioncheck.jsp"%> rnrnrn<% rnrequest.setCharacterEncoding("GBK");rnrnString strPid = request.getParameter("pid");rnint pid = 0;rnif(strPid == null || strPid.trim().equals(" "))rn pid = Integer.parseInt(strPid);rnrnString action = request.getParameter("action");rnif(action!=null && action.trim().equals("add"))rn String name = request.getParameter("name");rn String descr = request.getParameter("descr");rn if(pid == 0)rn Category.addTopCategory(name,descr);rn elsern Category.addChildCategory(pid, name, descr);rn rn out.println("恭喜您!添加成功!");rnrnrn%>rnrnrnrnrn rn Insert title herernrnrn 添加根类别rnrn rn rn rn rn rn 类别名称rn rn rn rn 类别描述rn rn rn rn rn rn rn rn rn rn rnrnrnrn
二维数组赋值报空指针
[code=java]rntable = new String[td.size()][]; rn for (int i=0;i td = new ArrayList();rn目的是将容器中的值 转化成二维数组,但是在从容器取值赋值给二维数组的时候报空指针错误 请问什么原因啊[img=https://forum.csdn.net/PointForum/ui/scripts/csdn/Plugin/001/face/35.gif][/img]rnrnrnException in thread "main" java.lang.NullPointerExceptionrn at bean.T_History.s_History(T_History.java:51)rn at bean.T_History.main(T_History.java:21)
hibernate load 报空指针
根据主键IDload的时候报空指针rnshow_sql=truern在load的时候也没打印hqlrnID确认在数据库中存在rn配置方面都没问题rn登录都可以用rn[code=java]rn严重: Servlet.service() for servlet action threw exceptionrnjava.lang.NullPointerExceptionrn at org.hibernate.tuple.AbstractEntityTuplizer.createProxy(AbstractEntityTuplizer.java:372)rn at org.hibernate.persister.entity.AbstractEntityPersister.createProxy(AbstractEntityPersister.java:3121)rn at org.hibernate.event.def.DefaultLoadEventListener.createProxyIfNecessary(DefaultLoadEventListener.java:232)rn at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:173)rn at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:87)rn at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:862)rn at org.hibernate.impl.SessionImpl.load(SessionImpl.java:781)rn at org.hibernate.impl.SessionImpl.load(SessionImpl.java:774)rn at org.springframework.orm.hibernate3.HibernateTemplate$3.doInHibernate(HibernateTemplate.java:508)rn at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:372)rn at org.springframework.orm.hibernate3.HibernateTemplate.load(HibernateTemplate.java:502)rn at org.springframework.orm.hibernate3.HibernateTemplate.load(HibernateTemplate.java:496)rn at com.shinythink.DbOperration.PackagMethod.querys(PackagMethod.java:53)rn at com.shinythink.Dao.Impl.UserListDaoImpl.loadUserListWhereId(UserListDaoImpl.java:31)rn at com.shinythink.Service.Impl.UserListServiceImpl.updatePassWord(UserListServiceImpl.java:51)rn at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)rn at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)rn at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)rn at java.lang.reflect.Method.invoke(Method.java:597)rn at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:304)rn at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)rn at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)rn at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)rn at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)rn at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)rn at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)rn at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)rn at $Proxy1.updatePassWord(Unknown Source)rn at com.shinythink.Action.UserListAction.UpdatePassWord(UserListAction.java:77)rn at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)rn at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)rn at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)rn at java.lang.reflect.Method.invoke(Method.java:597)rn at org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:270)rn at org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:187)rn at org.springframework.web.struts.DelegatingActionProxy.execute(DelegatingActionProxy.java:110)rn at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)rn at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)rn at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)rn at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)rn at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)rn at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)rn at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)rn at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)rn at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)rn at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)rn at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)rn at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)rn at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)rn at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)rn at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)rn at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)rn at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)rn at java.lang.Thread.run(Thread.java:662)rnrn[/code]rnrnrn谁帮忙看看是什么问题.rn谢谢了.
Xml解析报空指针
请教各位前辈,xml解析过程中空指针怎么破,我找了一天了也没找到解决办法rn[img=https://img-bbs.csdn.net/upload/201601/07/1452155445_737406.png][/img]rn日志上说蓝色那排空指针rn这是解析类:rnpackage com.hande.publichealth.util;rnrnimport java.io.File;rnimport java.io.FileInputStream;rnimport java.io.IOException;rnimport java.io.InputStream;rnimport java.util.ArrayList;rnimport java.util.HashMap;rnimport java.util.List;rnimport java.util.Map;rnrnimport org.xmlpull.v1.XmlPullParser;rnrnimport android.util.Log;rnimport android.util.Xml;rnrnimport com.hande.publichealth.global.Global;rnrn/**rn * 解析文件rn * rn * @author Adminrn *rn */rnpublic class ParsingUtil rn public static final String TAG = "ParsingUtil";rn /** 解析公共健康, format.xml文件 **/rn public static List>> parseHealthConsult() rn rn List>> list = null;rn File file = new File(Global.GGJK_XML_PATH);rn InputStream in = null;rn if (file.exists()) rn try rn in = new FileInputStream(file);rn XmlPullParser mXmlPullParser = Xml.newPullParser();rn mXmlPullParser.setInput(in, "UTF-8");rn int type = mXmlPullParser.getEventType();rn List> data = null;rn Map map = null;rn while (XmlPullParser.END_DOCUMENT != type) rn String name = mXmlPullParser.getName();// 标签名rn switch (type) rn case XmlPullParser.START_DOCUMENT:rn list = new ArrayList>>();rnrn break;rn case XmlPullParser.START_TAG:rn if ("arrayList".equals(name)) rn data = new ArrayList>();rn rn if ("Item".equals(name)) rn map = new HashMap();rn rn if ("Title".equals(name))rn map.put("title",mXmlPullParser.nextText());rn rn if ("Source".equals(name)) rn map.put("source", mXmlPullParser.nextText());rn rn if ("Number".equals(name)) rn map.put("number", mXmlPullParser.nextText());rn rn if ("Time".equals(name)) rn map.put("time", mXmlPullParser.nextText());rn rn if ("Imageurl".equals(name))rn map.put("img", mXmlPullParser.nextText()); rn rn if ("Htmlurl".equals(name))rn map.put(name, mXmlPullParser.nextText());rn rn break;rn case XmlPullParser.END_TAG:rn if ("Item".equals(name)) rn data.add(map);rn map = null;rn rn if ("arrayList".equals(name)) rn list.add(data);rn data = null;rn rn break;rn rn type = mXmlPullParser.next();rn rnrn catch (Exception e) rn e.printStackTrace();rn finallyrnrn if (in != null) rn try rn in.close();rn in = null;rn catch (IOException e) rn e.printStackTrace();rn rn rn rn rn else rn Log.e(TAG, "公共健康==>format.xml文件丢失!");rn rn return list;rn rnrn根据打印的日志文件,解析类就只执行了Log.e(TAG, "公共健康==>format.xml文件丢失!");这行,有人说可能是节点名字写错了,但我挨个复制节点名字后还是空指针,恳请各位前辈指点,感激不尽
spring注入报空指针
rn rn rn rn rn rn rnpublic class LoginAction extends ActionSupport rn private String username; // 用户名rn private String password; // 密码rn private UserService userService;rnpublic void setUserService(UserService userService) rn this.userService = userService;rn rnpublic String execute() throws Exception rn if (userService.login(username, password)) // 判断是否登录rn return "success"; // 返回成功字符串rn else rn return "fail"; // 返回失败字符串rn rn rnjava.lang.NullPointerExceptionrn com.gy.action.LoginAction.execute(LoginAction.java:32)rnrn省略部分测试代码,应该是spring注入问题,控制台直接读application.xml可以注入,但发布到tomcat userService就成空指针出错 ,请高手赐教!rn
fragment中 getActivity 报空指针
我的Activity中包含1个ViewPager-------viewPager中包含4个fragment--------有fragment包好一张图片-----------点击图片启动照相机或相册选择图片-------返回------getActivity()=null-----------------------------------有碰到这问题的么 。。。求解决方案。。。
ssh项目中关于sessionfactry报空指针
求助,ssh项目我用的是opensessioninviewfilter的,在调用baseimp里面的sessionfactry时报空指针,是不是session已经被断开的缘故啊,调了好久都调不出来。[img=https://img-bbs.csdn.net/upload/201405/28/1401286666_561213.jpg][/img][img=https://img-bbs.csdn.net/upload/201405/28/1401286690_507228.jpg][/img]
SSH开发 hibernate查询 报空指针
报错:rn2010-8-7 15:47:48 org.apache.catalina.core.StandardWrapperValve invokern严重: Servlet.service() for servlet action threw exceptionrnjava.lang.NullPointerExceptionrn at com.hexun.framework.base.BaseAction.checkLogin(BaseAction.java:162)rn at com.hexun.user.web.action.LoginAction.execute(LoginAction.java:43)rn at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)rn at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)rn at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)rn at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)rn at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)rn at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)rn at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)rn at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)rn at com.hexun.framework.filter.EncodingFilter.doFilter(EncodingFilter.java:29)rn at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)rn at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)rn at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)rn at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)rn at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)rn at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)rn at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)rn at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)rn at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)rn at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)rn at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)rn at java.lang.Thread.run(Thread.java:619)rnrn数据库查询语句:rnpublic User getUserByUserid(Long userId) rn rn try rn User user = null;rn user = (User) getSession().get("com.cms.model.User", userId);rn rn return user;rn catch (RuntimeException re) rn throw re;rn rn}rn*********************************************rn希望路过的高手帮助,
使用butterknife报空指针
一、首先你使用的是哪个版本的 若是8.0.1以前的直接在build.gradle中添加 compile 'com.jakewharton:butterknife:7.0.1' 就Ok了 但是你要直接将7.0.1替换成8.0.1以后的版本,编译不会报错,当你运行使用控件时会报空指针, 解决方法:1、在项目最外层的build.gradle中添加 classpath 'com.nee
CXF报空指针
最近用cxf开发,将hibernate\spring集成到一个web工程中,但在执行hql语句时,在一个action中,有的hql执行就没有问题,可有的就报rn2011-4-22 17:22:27 org.apache.cxf.phase.PhaseInterceptorChain doDefaultLoggingrn警告: Application http://impl.cxfService.com/PortServiceImplService#http://cxfService.com/portMessage has thrown exception, unwinding nowrnorg.apache.cxf.interceptor.FaultrnCaused by: java.lang.NullPointerExceptionrn很是郁闷,但是我可以肯定hibernateDAO绝对不为空!rn就是同一个hql语句,比如第一次参数值是‘A’,结果执行就不报错;若将值改成'B',就会报上面的错!rn并且将语句在数据库中执行,完全可以查到结果!rn希望高手不吝赐教!
报空指针错误
rn<%@ page contentType="text/html;charset=gb2312" language="java"%>rn<%@ page import="org.com.connection.Connectionabc"%>rn<%@ page import="org.com.caidan.peploe"%>rn<%@ page import="java.sql.*"%>rn rnrnrn rnrn 请选择rnrnrnrn <%=NName%>rn <%rn%>rn <% rn rn %>rn rn rn ==所有地区==rn rn rn rn 部门:rn rn rn rn rnrnrnrnrn很郁闷,我把其中的jsp代码复制到另外一个jsp页面中就能都出来,但为什么这个却报错误啊?
支付宝报空指针
这是我的第一篇博客,那就说说我在做支付宝的时候的一些见解吧,虽然支付宝和微信支付比起来坑要少的多但是也还是有一些需要注意的地方 1.对于一些支付参数来说,像appId和私钥来说这些参数最好不要放在客户端,因为这样不安全,我们这些参数最好放在服务端来生成,这两个参数很重要,因为支付宝会用它生成我们支付的sign,如果这两个参数有错误就会不能正常的调起支付,出现ALI40247系统繁忙的错误。 2.
bmob的自动升级报空指针
bmob自然是很好的东西,但是如果你遇到这个, 11-01 09:22:20.880: E/AndroidRuntime(8102): Caused by: java.lang.NullPointerException 11-01 09:22:20.880: E/AndroidRuntime(8102): at cn.bmob.v3.update.UpdateResponse.Code(Sou
获取文件路径报空指针
String filePath =request.getSession().getServletContext().getRealPath("/"); 提示这行代码报空指针。 总代码是这样的: //得到文件夹路径 String filePath1 = request.getSession().getServletContext().getRealPath("/"); String fi
程序执行到sqlMap.startTransaction();报空指针
我用的是spring+ibatis+strutsrn我在手动开启事务时报的错,程序执行到sqlMap.startTransaction();时报错,请问是什么原因?急急急!!!!rnrnjava代码:rntry rn String reource="sql-map-config.xml";rn rn reader =Resources.getResourceAsReader("sql-map-config.xml");rn rn sqlMap =SqlMapClientBuilder.buildSqlMapClient(reader);rn// sqlMap=XmlSqlMapBuilder.buildSqlMap(reader);rn rn rn sqlMap.startTransaction();rn Object obj1=save(params);rn System.out.println("obj1:"+obj1==null);rn Object obj=save(organ);rn System.out.println("obj:"+obj==null);rn if((obj!=null)&&(obj1!=null))rn flag=true;rn sqlMap.commitTransaction();rn rn elsern sqlMap.endTransaction();rn rnrnrnrnrnrnrnrnrn错误信息:rnrnjava.lang.NullPointerExceptionrn at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.startTransaction(SqlMapExecutorDelegate.java:732)rn at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.startTransaction(SqlMapSessionImpl.java:164)rn at com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.startTransaction(SqlMapClientImpl.java:141)rn at com.venus.common.service.OrganManager.saveAll(OrganManager.java:220)rn at com.venus.common.service.OrganManager$$FastClassByCGLIB$$ef3f2a1a.invoke()rn at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)rn at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:693)rn at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:139)rn at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:107)rn at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:161)rn at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:628)rn at com.venus.common.service.OrganManager$$EnhancerByCGLIB$$35119c7.saveAll()rn at com.venus.common.web.OrganAction.add(OrganAction.java:166)rn at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)rn at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)rn at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)rn at java.lang.reflect.Method.invoke(Method.java:597)rn at org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:270)rn at org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:187)rn at org.springframework.web.struts.DelegatingActionProxy.execute(DelegatingActionProxy.java:106)rn at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)rn at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)rn at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)rn at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)rn at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)rn at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)rn at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)rn at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)rn at com.venus.common.filter.SessionTimeOutFilter.doFilter(SessionTimeOutFilter.java:40)rn at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)rn at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)rn at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:77)rn at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:77)rn at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)rn at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)rn at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:210)rn at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)rn at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)rn at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)rn at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)rn at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)rn at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:870)rn at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)rn at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)rn at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)rn at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:685)rn at java.lang.Thread.run(Thread.java:619)
加载properties文件报空指针
public class DB rn private Connection conn = null;rn private Properties prop = null;rn InputStream info = null; //InputStream 对象 ; //InputStream 对象 rn rn public Connection getConnection()rn String driverclass,dburl,user,password;rn prop = new Properties(); //构建properties对象rn //java.lang.Object.getClass(),将jdbc.properties文件内容赋予输入流对象 rn info = getClass().getResourceAsStream("conf/jdbc.properties");rnrn try rn prop.load(info); //加载输入流对象内容rn driverclass = prop.getProperty("driverclass");rn dburl = prop.getProperty("dburl");rn user = prop.getProperty("user");rn password = prop.getProperty("password");rn System.out.println(driverclass+dburl+user+password);rn rn Class.forName(driverclass);//加载驱动rn conn=DriverManager.getConnection(dburl,user,password);//创建数据库connection对象rn catch (IOException e) rn // TODO Auto-generated catch blockrn e.printStackTrace();rn catch (ClassNotFoundException e) rn // TODO Auto-generated catch blockrn e.printStackTrace();rn catch (SQLException e) rn // TODO Auto-generated catch blockrn e.printStackTrace();rn rn return conn;rn rn rn错误[code=java][/code]信息:rn严重: Servlet.service() for servlet AccountServlet threw exceptionrnjava.lang.NullPointerExceptionrn at java.util.Properties$LineReader.readLine(Properties.java:418)rn at java.util.Properties.load0(Properties.java:337)rn at java.util.Properties.load(Properties.java:325)rn at com.etop.topebus.common.DB.getConnection(DB.java:26)rn at com.etop.topebus.dao.AccountDao.accountInfo(AccountDao.java:40)rn at com.etop.topebus.control.AccountServlet.doPost(AccountServlet.java:57)rn at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)rn at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)rn at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)rn at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)rn at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)rn at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)rn at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)rn at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)rn at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)rn at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263)rn at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)rn at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:584)rn at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)rn at java.lang.Thread.run(Thread.java:619)rn
相关热词 c#检测非法字符 c#双屏截图 c#中怎么关闭线程 c# 显示服务器上的图片 api嵌入窗口 c# c# 控制网页 c# encrypt c#微信网页版登录 c# login 居中 c# 考试软件