tomcat exception
Cannot load JDBC driver class 'oracle.jdbc.driver.OracleDriver'
因为用到了tomcat窗口本身的链接池,此时在server启动前就需要提前加载jdbc.jar的驱动jar包,以让链接池生效,但此时必须要在tomcatHomt/common/lib/ojdbc5.jar提前放置该jar包,
如果不在tomcat目录放,就算在项目本身存在WEB-INF/lib/ojdbc5.jar也是没有用的.因为引用的先后不一样了.
org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot load JDBC driver class 'oracle.jdbc.driver.OracleDriver'
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1136)
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:880)
at com.testdemo.iaeap.op.dbschema.JdbcLogin.createExteralDataSource(JdbcLogin.java:326)
at com.testdemo.iaeap.op.dbschema.JdbcLogin.newConnectionFactory(JdbcLogin.java:55)
at com.testdemo.iaeap.op.datasource.OPPoolManagerImpl.initConnectionFactories(OPPoolManagerImpl.java:150)
at com.testdemo.iaeap.op.OPSysManager.start(OPSysManager.java:132)
at com.testdemo.iaeap.plugin.EAPConfig.initOP(EAPConfig.java:481)
at com.testdemo.iaeap.plugin.EAPConfig.init(EAPConfig.java:303)
at org.apache.struts.action.ActionServlet.initModulePlugIns(ActionServlet.java:839)
at org.apache.struts.action.ActionServlet.init(ActionServlet.java:332)
at javax.servlet.GenericServlet.init(GenericServlet.java:212)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1139)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:966)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3956)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4230)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:736)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:448)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:700)
at org.apache.catalina.startup.Catalina.start(Catalina.java:552)
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.catalina.startup.Bootstrap.start(Bootstrap.java:295)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:433)
Caused by: java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1130)
... 27 more
tomcat运行一段时间后报Software caused connection abort: recv failed,之后一直报Software caused connection abort: socket write error.
错误分析: 如果是oracle报的错,那么肯定会抛一个错误id,可见是软件与oracle交互过程中服务器自身报的异常.
而该异常在每次重启服务器后,又正常了,需要过一段时间才会重现,所以初步定位还是程序本身问题.
进而百度一番后,有说法是更换oracle的jar包,因为我用的是一个老项目,使用了jdk1.5, tomcat5.5,所以找了一个ojdbc5.jar的包替换了原本的ojdbc14.jar. 再也没报错了.
java.sql.SQLException: Io 异常: Software caused connection abort: recv failed
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:333)
at oracle.jdbc.driver.OracleStatement.<init>(OracleStatement.java:389)
at oracle.jdbc.driver.OracleStatement.<init>(OracleStatement.java:413)
at oracle.jdbc.driver.OraclePreparedStatement.<init>(OraclePreparedStatement.java:119)
at oracle.jdbc.driver.OraclePreparedStatement.<init>(OraclePreparedStatement.java:92)
at oracle.jdbc.driver.OracleConnection.privatePrepareStatement(OracleConnection.java:950)
at oracle.jdbc.driver.OracleConnection.prepareStatement(OracleConnection.java:802)
at org.apache.tomcat.dbcp.dbcp.DelegatingConnection.prepareStatement(DelegatingConnection.java:248)
at org.apache.tomcat.dbcp.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.prepareStatement(PoolingDataSource.java:302)
at com.testdemo.iaeap.op.ConnQuery.executeQuery(ConnQuery.java:141)
at com.testdemo.iaeap.op.impl.DBPersistenceManagerImpl.executeQuery(DBPersistenceManagerImpl.java:296)
at com.testdemo.iaeap.org.deal.dao.AbstractOrgDAO.getQuerySet(AbstractOrgDAO.java:112)
at com.testdemo.iaeap.org.deal.dao.UserDAO.loadAllbyApp_name(UserDAO.java:93)
at com.testdemo.iaeap.org.AbstractOrgLoader.loadUser(AbstractOrgLoader.java:134)
at com.testdemo.iaeap.org.AbstractOrgLoader.loadLevelObject(AbstractOrgLoader.java:118)
at com.testdemo.iaeap.org.action.LoginAction.login(LoginAction.java:105)
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:276)
at org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:196)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:421)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:226)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1164)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:415)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at com.testdemo.zfmi.filter.ZfmiFilter.doFilter(ZfmiFilter.java:99)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at com.testdemo.iaeap.web.filter.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:80)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:874)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
at java.lang.Thread.run(Unknown Source)
2017-07-20 05:44:31,277 >> WARN >> org.apache.struts.action.RequestProcessor.processException(RequestProcessor.java:509) >> Unhandled Exception thrown: class com.testdemo.iaeap.org.OrgException
2017-07-20 05:44:31,277 >> INFO >> org.apache.catalina.core.ApplicationContext.log(ApplicationContext.java:647) >> Io 异常: Software caused connection abort: recv failed
2017-07-20 05:44:32,349 >> ERROR >> com.testdemo.iaeap.op.ConnQuery.executeQuery(ConnQuery.java:103) >> ----ConnQuery.executeQuery ERROR!
java.sql.SQLException: Io 异常: Software caused connection abort: socket write error
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:333)
at oracle.jdbc.driver.OracleStatement.<init>(OracleStatement.java:389)
at oracle.jdbc.driver.OracleStatement.<init>(OracleStatement.java:413)
at oracle.jdbc.driver.OraclePreparedStatement.<init>(OraclePreparedStatement.java:119)
at oracle.jdbc.driver.OraclePreparedStatement.<init>(OraclePreparedStatement.java:92)
at oracle.jdbc.driver.OracleConnection.privatePrepareStatement(OracleConnection.java:950)
at oracle.jdbc.driver.OracleConnection.prepareStatement(OracleConnection.java:802)
at org.apache.tomcat.dbcp.dbcp.DelegatingConnection.prepareStatement(DelegatingConnection.java:248)
at org.apache.tomcat.dbcp.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.prepareStatement(PoolingDataSource.java:302)
at com.testdemo.iaeap.op.ConnQuery.executeQuery(ConnQuery.java:68)
at com.testdemo.iaeap.op.impl.DBPersistenceManagerImpl.executeQuery(DBPersistenceManagerImpl.java:248)
at com.testdemo.zfmi.boc.Claim.HumpinvestBoc.preQuery(HumpinvestBoc.java:3866)
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 com.testdemo.iaeap.action.CommonBOControllerAction.execute(CommonBOControllerAction.java:80)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:421)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:226)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1164)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:415)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at com.testdemo.zfmi.filter.ZfmiFilter.doFilter(ZfmiFilter.java:99)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at com.testdemo.iaeap.web.filter.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:80)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:874)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
at java.lang.Thread.run(Unknown Source)
com.testdemo.iaeap.op.OPException: Io 异常: Software caused connection abort: socket write error
at com.testdemo.iaeap.op.ConnQuery.executeQuery(ConnQuery.java:105)
at com.testdemo.iaeap.op.impl.DBPersistenceManagerImpl.executeQuery(DBPersistenceManagerImpl.java:248)
at com.testdemo.zfmi.boc.Claim.HumpinvestBoc.preQuery(HumpinvestBoc.java:3866)
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 com.testdemo.iaeap.action.CommonBOControllerAction.execute(CommonBOControllerAction.java:80)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:421)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:226)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1164)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:415)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at com.testdemo.zfmi.filter.ZfmiFilter.doFilter(ZfmiFilter.java:99)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at com.testdemo.iaeap.web.filter.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:80)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:874)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
at java.lang.Thread.run(Unknown Source)
java.sql.SQLException: Already closed.
主要参考:
$$$ tomcat dbcp 基于jndi配置时出现java.sql.SQLException: Already closed
原因: You're probably running into the fact that mysql closes connections which have been open "too long". Probably if you make the request to the server again, you'll find that it works because the connection is reopened.
解决方法: One way to deal with this is to add the following to your context.xml Resource:
validationQuery="select 1" (基于mysql)
validationQuery="select 1 from dual" (基于Oracle)
配置参考如下(附中文释意):
<Host appBase="webapps" autoDeploy="true" name="localhost" unpackWARs="true" xmlNamespaceAware="false" xmlValidation="false">
<Context docBase="D:\application\myserver\WebContent" path="/fileupload" reloadable="false">
<Resource
name="jdbc/TestDB" JNDI数据源的name,查找时用:java:comp/env/jdbc/TestDB
type="javax.sql.DataSource" 数据源类型
factory="org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory" 数据源工场
driverClassName="com.mysql.jdbc.Driver" JDBC驱动类
url="jdbc:mysql://localhost:3306/test?
characterEncoding=UTF-8&autoReconnectForPools=true&rewriteBatchedStatements=true&useCursorFetch=true&defaultFetchSize=20" 数据库URL地址
username="xxx" 访问数据库用户名
password="xxx" 访问数据库的密码
maxWait="3000" 从池中取连接的最大等待时间,单位ms.
initialSize="10" 初始化连接
maxIdle="60" 最大空闲连接
minIdle="10" 最小空闲连接
maxActive="80" 最大活动连接
validationQuery = "SELECT 1 FROM DUAL" 验证使用的SQL语句
testWhileIdle = "true" 指明连接是否被空闲连接回收器(如果有)进行检验.如果检测失败,则连接将被从池中去除.
testOnBorrow = "false" 借出连接时不要测试,否则很影响性能
timeBetweenEvictionRunsMillis = "30000" 每30秒运行一次空闲连接回收器
minEvictableIdleTimeMillis = "1800000" 池中的连接空闲30分钟后被回收
numTestsPerEvictionRun="10" 在每次空闲连接回收器线程(如果有)运行时检查的连接数量
removeAbandoned="true" 连接泄漏回收参数,当可用连接数少于3个时才执行
removeAbandonedTimeout="180" 连接泄漏回收参数,180秒,泄露的连接可以被删除的超时值
logAbandoned="true" 连接泄漏回收日志记录
/>
</Context>
</Host>
上面链接提到其实weblogic也有类似一个这样配置查询语句的地方,原来有实际意义的,此时我也回想起来确实有这个配置.
代价: This causes a very cheap test query to always be run first; if the connection has been closed, this gets the failure, and then a new connection is opened
其它参考:
DBCP错误:java.sql.SQLException: Already closed.
今天线上系统碰到个怪问题DBCP数据连接异常,java.sql.SQLException: Already closed.
配置参考:
Caused by: java.net.SocketException: Software caused connection abort: recv failed
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(Unknown Source)
at oracle.net.ns.Packet.receive(Packet.java:282)
at oracle.net.ns.DataPacket.receive(DataPacket.java:103)
at oracle.net.ns.NetInputStream.getNextPacket(NetInputStream.java:230)
at oracle.net.ns.NetInputStream.read(NetInputStream.java:175)
at oracle.net.ns.NetInputStream.read(NetInputStream.java:100)
at oracle.net.ns.NetInputStream.read(NetInputStream.java:85)
at oracle.jdbc.driver.T4CSocketInputStreamWrapper.readNextPacket(T4CSocketInputStreamWrapper.java:122)
at oracle.jdbc.driver.T4CSocketInputStreamWrapper.read(T4CSocketInputStreamWrapper.java:78)
at oracle.jdbc.driver.T4CMAREngine.unmarshalUB1(T4CMAREngine.java:1179)
at oracle.jdbc.driver.T4CMAREngine.unmarshalSB1(T4CMAREngine.java:1155)
at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:279)
at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:186)
at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:521)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:205)
at oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:861)
... 36 more
java.sql.SQLException: Already closed.
at org.apache.tomcat.dbcp.dbcp.PoolableConnection.close(PoolableConnection.java:84)
at org.apache.tomcat.dbcp.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.close(PoolingDataSource.java:181)
at com.testdemo.iaeap.op.impl.DBPersistenceManagerImpl.freeConnection(DBPersistenceManagerImpl.java:451)
at com.testdemo.iaeap.op.impl.DBPersistenceManagerImpl.postState(DBPersistenceManagerImpl.java:602)
at com.testdemo.iaeap.op.impl.DBPersistenceManagerImpl.executeQuery(DBPersistenceManagerImpl.java:162)
at com.testdemo.zfmi.util.EmpUtil.getEmpById(EmpUtil.java:38)
at com.testdemo.zfmi.ibatis.service.claim.PictureManage.execute(PictureManage.java:31)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:421)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:226)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1164)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:397)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at com.testdemo.zfmi.filter.ZfmiFilter.doFilter(ZfmiFilter.java:108)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at com.testdemo.iaeap.web.filter.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:80)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:874)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
at java.lang.Thread.run(Unknown Source)
The Network Adapter could not establish the connection
我遇到的场景是,刚到友情公司支持, ping oracleIP可以通,但是telnet oracleIP 1521 不能通,说明网络在某个地方端口被屏蔽了,原来是主任没有开启我的ip访问该端口的权限.
Caused by: java.sql.SQLException: Io 异常: The Network Adapter could not establish the connection
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:333)
at oracle.jdbc.driver.OracleConnection.<init>(OracleConnection.java:404)
at oracle.jdbc.driver.OracleDriver.getConnectionInstance(OracleDriver.java:468)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:314)
at org.apache.tomcat.dbcp.dbcp.DriverConnectionFactory.createConnection(DriverConnectionFactory.java:38)
at org.apache.tomcat.dbcp.dbcp.PoolableConnectionFactory.makeObject(PoolableConnectionFactory.java:582)
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.validateConnectionFactory(BasicDataSource.java:1556)
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:1545)
Invalid character found in method name. HTTP method names must be tokens
网上流传的说法是tomcat,默认head缓冲区大小太小导致的, 配置maxHttpHeaderSize,默认是4096,调大一倍成8192即可
<Connector URIEncoding="UTF-8" port="8080" protocol="org.apache.coyote.http11.Http11NioProtocol"
useBodyEncodingForURI="false"
enableLookups="false"
connectionTimeout="20000"
redirectPort="8443" maxHttpHeaderSize="8192"/>
其它链接
处理 Java Tomcat 的“Cannot allocate memory”错误
编辑 /etc/sysctl.conf,修改参数 vm.overcommit_memory = 1,重启服务器或者用户重新登录
overcommit_memory有什么作用?
overcommit_memory取值又三种分别为0, 1, 2
overcommit_memory=0, 表示内核将检查是否有足够的可用内存供应用进程使用;如果有足够的可用内存,内存申请允许;否则,内存申请失败,并把错误返回给应用进程。
overcommit_memory=1, 表示内核允许分配所有的物理内存,而不管当前的内存状态如何。
overcommit_memory=2, 表示内核允许分配超过所有物理内存和交换空间总和的内存