问题描述
typeExceptionreportmessagedescriptionTheserverencounteredaninternalerror()thatpreventeditfromfulfillingthisrequest.exceptionjavax.servlet.ServletException:java.lang.NullPointerExceptionorg.apache.struts.action.RequestProcessor.processException(RequestProcessor.java:545)org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:486)org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)javax.servlet.http.HttpServlet.service(HttpServlet.java:710)javax.servlet.http.HttpServlet.service(HttpServlet.java:803)com.struts.filter.MyFilter.doFilter(MyFilter.java:24)rootcausejava.lang.NullPointerExceptioncom.Hibernate.util.HibernateUtil.findUser(HibernateUtil.java:41)com.struts.action.FindUserAction.finUser(FindUserAction.java:24)sun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethod)sun.reflect.NativeMethodAccessorImpl.invoke(UnknownSource)sun.reflect.DelegatingMethodAccessorImpl.invoke(UnknownSource)java.lang.reflect.Method.invoke(UnknownSource)org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:280)org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:216)org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)javax.servlet.http.HttpServlet.service(HttpServlet.java:710)javax.servlet.http.HttpServlet.service(HttpServlet.java:803)com.struts.filter.MyFilter.doFilter(MyFilter.java:24)noteThefullstacktraceoftherootcauseisavailableintheApacheTomcat/6.0.13logs.
解决方案
解决方案二:
控制台输出的信息如下:18:55:20,609WARNSettingsFactory:103-Couldnotobtainconnectionmetadatajava.sql.SQLException:NetworkerrorIOException:Connectionrefused:connectatnet.sourceforge.jtds.jdbc.ConnectionJDBC2.<init>(ConnectionJDBC2.java:372)atnet.sourceforge.jtds.jdbc.ConnectionJDBC3.<init>(ConnectionJDBC3.java:50)atnet.sourceforge.jtds.jdbc.Driver.connect(Driver.java:178)atjava.sql.DriverManager.getConnection(UnknownSource)atjava.sql.DriverManager.getConnection(UnknownSource)atorg.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:110)atorg.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:72)atorg.hibernate.cfg.Configuration.buildSettings(Configuration.java:1881)atorg.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1174)atcom.Hibernate.util.GetHibernate.<clinit>(GetHibernate.java:37)atcom.Hibernate.util.HibernateUtil.<clinit>(HibernateUtil.java:24)atcom.struts.action.FindUserAction.finUser(FindUserAction.java:24)atsun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethod)atsun.reflect.NativeMethodAccessorImpl.invoke(UnknownSource)atsun.reflect.DelegatingMethodAccessorImpl.invoke(UnknownSource)atjava.lang.reflect.Method.invoke(UnknownSource)atorg.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:280)atorg.apache.struts.actions.DispatchAction.execute(DispatchAction.java:216)atorg.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)atorg.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)atorg.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)atorg.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)atjavax.servlet.http.HttpServlet.service(HttpServlet.java:710)atjavax.servlet.http.HttpServlet.service(HttpServlet.java:803)atorg.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)atorg.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)atcom.struts.filter.MyFilter.doFilter(MyFilter.java:24)atorg.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)atorg.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)atorg.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)atorg.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)atorg.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)atorg.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)atorg.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)atorg.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:261)atorg.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)atorg.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:581)atorg.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)atjava.lang.Thread.run(UnknownSource)Causedby:java.net.ConnectException:Connectionrefused:connectatjava.net.PlainSocketImpl.socketConnect(NativeMethod)atjava.net.PlainSocketImpl.doConnect(UnknownSource)atjava.net.PlainSocketImpl.connectToAddress(UnknownSource)atjava.net.PlainSocketImpl.connect(UnknownSource)atjava.net.SocksSocketImpl.connect(UnknownSource)atjava.net.Socket.connect(UnknownSource)atsun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethod)atsun.reflect.NativeMethodAccessorImpl.invoke(UnknownSource)atsun.reflect.DelegatingMethodAccessorImpl.invoke(UnknownSource)atjava.lang.reflect.Method.invoke(UnknownSource)atnet.sourceforge.jtds.jdbc.SharedSocket.createSocketForJDBC3(SharedSocket.java:289)atnet.sourceforge.jtds.jdbc.SharedSocket.<init>(SharedSocket.java:250)atnet.sourceforge.jtds.jdbc.ConnectionJDBC2.<init>(ConnectionJDBC2.java:297)...38more
解决方案三:
18:55:20,796WARNConfigurator:126-Noconfigurationfound.Configuringehcachefromehcache-failsafe.xmlfoundintheclasspath:jar:file:/D:/Workspaces/MyEclipse%207.0/.metadata/.me_tcat/webapps/zrg/WEB-INF/lib/ehcache-1.1.jar!/ehcache-failsafe.xml18:55:22,609WARNJDBCExceptionReporter:71-SQLError:0,SQLState:08S0118:55:22,609ERRORJDBCExceptionReporter:72-NetworkerrorIOException:Connectionrefused:connectorg.hibernate.exception.JDBCConnectionException:Cannotopenconnectionatorg.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:74)atorg.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)atorg.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:29)atorg.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:420)atorg.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:144)atorg.hibernate.jdbc.JDBCContext.connection(JDBCContext.java:129)atorg.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:57)atorg.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1290)atcom.Hibernate.util.HibernateUtil.findUser(HibernateUtil.java:32)atcom.struts.action.FindUserAction.finUser(FindUserAction.java:24)atsun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethod)atsun.reflect.NativeMethodAccessorImpl.invoke(UnknownSource)atsun.reflect.DelegatingMethodAccessorImpl.invoke(UnknownSource)atjava.lang.reflect.Method.invoke(UnknownSource)atorg.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:280)atorg.apache.struts.actions.DispatchAction.execute(DispatchAction.java:216)atorg.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)atorg.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)atorg.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)atorg.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)atjavax.servlet.http.HttpServlet.service(HttpServlet.java:710)atjavax.servlet.http.HttpServlet.service(HttpServlet.java:803)atorg.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)atorg.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)atcom.struts.filter.MyFilter.doFilter(MyFilter.java:24)atorg.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)atorg.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)atorg.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)atorg.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)atorg.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)atorg.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)atorg.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)atorg.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:261)atorg.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)atorg.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:581)atorg.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)atjava.lang.Thread.run(UnknownSource)Causedby:java.sql.SQLException:NetworkerrorIOException:Connectionrefused:connectatnet.sourceforge.jtds.jdbc.ConnectionJDBC2.<init>(ConnectionJDBC2.java:372)atnet.sourceforge.jtds.jdbc.ConnectionJDBC3.<init>(ConnectionJDBC3.java:50)atnet.sourceforge.jtds.jdbc.Driver.connect(Driver.java:178)atjava.sql.DriverManager.getConnection(UnknownSource)atjava.sql.DriverManager.getConnection(UnknownSource)atorg.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:110)atorg.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:417)...33moreCausedby:java.net.ConnectException:Connectionrefused:connectatjava.net.PlainSocketImpl.socketConnect(NativeMethod)atjava.net.PlainSocketImpl.doConnect(UnknownSource)atjava.net.PlainSocketImpl.connectToAddress(UnknownSource)atjava.net.PlainSocketImpl.connect(UnknownSource)atjava.net.SocksSocketImpl.connect(UnknownSource)atjava.net.Socket.connect(UnknownSource)atsun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethod)atsun.reflect.NativeMethodAccessorImpl.invoke(UnknownSource)atsun.reflect.DelegatingMethodAccessorImpl.invoke(UnknownSource)atjava.lang.reflect.Method.invoke(UnknownSource)atnet.sourceforge.jtds.jdbc.SharedSocket.createSocketForJDBC3(SharedSocket.java:289)atnet.sourceforge.jtds.jdbc.SharedSocket.<init>(SharedSocket.java:250)atnet.sourceforge.jtds.jdbc.ConnectionJDBC2.<init>(ConnectionJDBC2.java:297)...39more18:55:22,625WARNRequestProcessor:538-UnhandledExceptionthrown:classjava.lang.NullPointerException2009-5-1718:55:22org.apache.catalina.core.StandardWrapperValveinvoke严重:Servlet.service()forservletactionthrewexceptionjava.lang.NullPointerExceptionatcom.Hibernate.util.HibernateUtil.findUser(HibernateUtil.java:41)atcom.struts.action.FindUserAction.finUser(FindUserAction.java:24)atsun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethod)atsun.reflect.NativeMethodAccessorImpl.invoke(UnknownSource)atsun.reflect.DelegatingMethodAccessorImpl.invoke(UnknownSource)atjava.lang.reflect.Method.invoke(UnknownSource)atorg.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:280)atorg.apache.struts.actions.DispatchAction.execute(DispatchAction.java:216)atorg.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)atorg.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)atorg.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)atorg.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)atjavax.servlet.http.HttpServlet.service(HttpServlet.java:710)atjavax.servlet.http.HttpServlet.service(HttpServlet.java:803)atorg.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)atorg.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)atcom.struts.filter.MyFilter.doFilter(MyFilter.java:24)atorg.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)atorg.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)atorg.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)atorg.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)atorg.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)atorg.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)atorg.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)atorg.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:261)atorg.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)atorg.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:581)atorg.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)atjava.lang.Thread.run(UnknownSource)
解决方案四:
org.hibernate.exception.JDBCConnectionException:CannotopenconnectionJDBC连接打不开,你的配置正确吗?
解决方案五:
数据库连接问题!检查一下用户名和密码是否正确!!
解决方案六:
rootcausejava.lang.NullPointerException空指针异常呀,java.sql.SQLException:NetworkerrorIOException:Connectionrefused:connect数据库连接的相关配置有问题,确定所连接数据库的用户有权限进行相关操作~~
解决方案七:
小弟的配置没错,我用的数据库是sqlserver2000装的时候设置的用户名是:sa密码为空可是连接数据库的时候好像都没有提示输入用户名和密码啊!sql的用户名和密码是在你哪用的啊?请求高手给解决下!小弟先谢谢啦!
解决方案八:
来源http://yanchao90.blog.163.com/blog/static/1794602520092202461501/首先从sun的官方网站下载一个jdbc的jar包。注意:我使用的是1.4的版本,各个版本的jdbc在加载驱动的时候,字符串可能是不一样的。首先将这个jar包添加到eclipse工程的构建路径中,具体步骤:右键单击项目->构建路径(BuildPath)->添加外部归档...(AddExternalArchives...)然后选择下载好的jar包。接下来就可以写代码了try{Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");Connectioncon=DriverManager.getConnection("jdbc:sqlserver://localhost:1433;DatabaseName=;user=sa;password=");}catch(ClassNotFoundExceptione){System.out.println("驱动加载失败");}catch(SQLExceptione){e.printStackTrace();}这里我用的链接字符串是getConnection方法的一个重载,省略了getConnection方法的后两个参数,其实是把这两个参数放到了链接字符串里。localhost是指本机1433是使用的端口,sql2000需要安装SP4补丁,网上下载一个。
解决方案九:
楼上的说的很正确啊,就是getConnection()这个地方出错了,DriverManager.getConnection("jdbc:sqlserver://localhost:1433;DatabaseName=;user=sa;password=");看看括号里面的东西对不对,然后确认你的包是不是都有,连接sql2000需要三个包,msbase.jar,mssqlserver.jar,mautil.jar。再看看补丁打了没有
解决方案十:
引用8楼haolisdk1的回复:
楼上的说的很正确啊,就是getConnection()这个地方出错了,DriverManager.getConnection("jdbc:sqlserver://localhost:1433;DatabaseName=;user=sa;password=");看看括号里面的东西对不对,然后确认你的包是不是都有,连接sql2000需要三个包,msbase.jar,mssqlserver.jar,mautil.jar。再看看补丁打了没有
楼上的说的很对,我想是你密码处写错了
解决方案十一:
该回复于2009-05-20 13:43:18被版主删除
解决方案十二:
你使用的是Hibernate吧?看哈配置文件里*.cfg.xml面有没有问题~~查询的时候配置文件有没有错,hibernate一般式不会出错的,配置出错很多~~
解决方案十三:
引用7楼witlili的回复:
来源http://yanchao90.blog.163.com/blog/static/1794602520092202461501/首先从sun的官方网站下载一个jdbc的jar包。注意:我使用的是1.4的版本,各个版本的jdbc在加载驱动的时候,字符串可能是不一样的。首先将这个jar包添加到eclipse工程的构建路径中,具体步骤:右键单击项目->构建路径(BuildPath)->添加外部归档...(AddExternalArchives...)然后选择下载好的jar包。接下来就可以写代码了try{…
谢谢大侠,问题已经解决。我下载了一个SP4补丁。
解决方案十四:
谢谢你们这些热心人,小弟再次表示感谢!