使用tomcat服务器连接mySql数据库时出错



我正在做一个基于struts的web应用程序,使用tomcat服务器,使用jdbc连接DB,使用mySql和sql server DB,并添加了相关的jar,但是有这个例外如何解决问题。

com.mind.fw.lang.MindFWRuntimeException: Error while doing JNDI lookup
    at com.mind.fw.core.dao.util.DBUtil.getJndiDS(DBUtil.java:186)
    at com.mind.fw.core.dao.util.DBUtil.initializeDS(DBUtil.java:157)
    at com.mind.fw.core.dao.util.DBUtil.getDataSource(DBUtil.java:132)
    at com.mind.common.util.MySqlConnection.getMySqlConnection(MySqlConnection.java:21)
    at com.mind.dao.PVS.Pvsdao.getSearchpartnerdetailsWithStatus(Pvsdao.java:1901)
    at com.mind.actions.PVS.Partner_SearchAction.search(Partner_SearchAction.java:371)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:280)
    at org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:216)
    at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
    at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
    at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
    at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at com.mind.common.CharsetEncoding.doFilter(CharsetEncoding.java:36)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:225)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
    at com.googlecode.psiprobe.Tomcat60AgentValve.invoke(Tomcat60AgentValve.java:30)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
    at org.apache.catalina.authenticator.SingleSignOn.invoke(SingleSignOn.java:336)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1001)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1653)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
Caused by: javax.naming.NameNotFoundException: Name [contingentDB] is not bound in this Context. Unable to find [contingentDB].
    at org.apache.naming.NamingContext.lookup(NamingContext.java:820)
    at org.apache.naming.NamingContext.lookup(NamingContext.java:154)
    at org.apache.naming.NamingContext.lookup(NamingContext.java:831)
    at org.apache.naming.NamingContext.lookup(NamingContext.java:154)
    at org.apache.naming.NamingContext.lookup(NamingContext.java:831)
    at org.apache.naming.NamingContext.lookup(NamingContext.java:154)
    at org.apache.naming.NamingContext.lookup(NamingContext.java:831)
    at org.apache.naming.NamingContext.lookup(NamingContext.java:168)
    at org.apache.naming.SelectorContext.lookup(SelectorContext.java:158)
    at javax.naming.InitialContext.lookup(Unknown Source)
    at com.mind.fw.core.dao.util.DBUtil.getJndiDS(DBUtil.java:181)
    ... 38 more
14 May 2014 06:16:31,625 DEBUG [http-nio-8080-exec-4] util.MySqlConnection:27 - getMySqlConnection(String) - Error in establishing connection to mySQL.
14 May 2014 06:16:31,625 ERROR [http-nio-8080-exec-4] PVS.Pvsdao:2225 -  -------------------------------------------- jdbc:mysql://ServerIP:3306/DBNaame,UserNAme,password -------------------------------------------- 
14 May 2014 06:16:31,625 ERROR [http-nio-8080-exec-4] PVS.Pvsdao:2228 - getSearchpartnerdetails(String, String, String, String, String, String, String, String, String, String[], String, String[], String, String, String, String, DataSource)
java.lang.NullPointerException
    at com.mind.dao.PVS.Pvsdao.getSearchpartnerdetailsWithStatus(Pvsdao.java:1937)
    at com.mind.actions.PVS.Partner_SearchAction.search(Partner_SearchAction.java:371)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:280)
    at org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:216)
    at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
    at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
    at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
    at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at com.mind.common.CharsetEncoding.doFilter(CharsetEncoding.java:36)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:225)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
    at com.googlecode.psiprobe.Tomcat60AgentValve.invoke(Tomcat60AgentValve.java:30)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
    at org.apache.catalina.authenticator.SingleSignOn.invoke(SingleSignOn.java:336)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1001)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1653)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
14 May 2014 06:16:31,626 DEBUG [http-nio-8080-exec-4] PVS.Pvsdao:2233 - getSearchpartnerdetails(String, String, String, String, String, String, String, String, String, String[], String, String[], String, String, String, String, DataSource) - Error occured during searchingjava.lang.NullPointerException
14 May 2014 06:16:31,626 ERROR [http-nio-8080-exec-4] PVS.Pvsdao:2240 -  -------------------------------------------- jdbc:mysql://ServerIP:3306/DBNaame,UserNAme,password -------------------------------------------- 

我有办法了。

实际上这是最初的问题:

javax.naming.NameNotFoundException: Name [contingentDB] is not bound in this Context. Unable to find [contingentDB].

,我注意到

<ResourceLink global="jdbc/contingentDB" name="jdbc/contingentDB"/>
本地上下文文件i-e 中缺少

tomcatInstances/verification/conf/Catalina/localhost/ProjectName.xml

希望对大家有所帮助

相关内容

  • 没有找到相关文章

最新更新