tomcat的server.xml配置如下:
<Resource name="jdbc/uopact1ds" auth="Container" type="javax.sql.DataSource" factory="org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory" driverClassName="oracle.jdbc.driver.OracleDriver" url="jdbc:oracle:thin:@30.51.9.26:1521:ngacct_s1" username="uop_act1" password="eb_1234" maxActive="60" maxIdle="20" maxWait="10000" removeAbandoned="true" removeAbandonedTimeout="60" logAbandoned="true"/>報錯信息如下:
java.sql.SQLException: Io exception: Connection refused(DESCRIPTION=(TMP=)(VSNNUM=169870592)(ERR=12505)(ERROR_STACK=(ERROR=(CODE=12505)(EMFI=4)))) org.apache.tapestry.ApplicationRuntimeException org.apache.tapestry.ApplicationRuntimeException: Unable to invoke method dataImportByTxt on com.company.sale.view.realuser.report.effectevaluation.DataImportList$Enhance_0@7e907e90[effectevaluation.DataImport]: null component: com.company.sale.view.realuser.report.effectevaluation.DataImportList$Enhance_0@7e907e90[effectevaluation.DataImport] location: context:/realuser/report/effectevaluation/DataImport.page, line 7, column 99 java.lang.RuntimeException org.apache.tapestry.ApplicationRuntimeException: Unable to invoke method dataImportByTxt on com.company.sale.view.realuser.report.effectevaluation.DataImportList$Enhance_0@7e907e90[effectevaluation.DataImport]: null Stack Trace: org.apache.tapestry.listener.ListenerMap$SyntheticListener.actionTriggered(ListenerMap.java:121) org.apache.tapestry.form.Submit.renderComponent(Submit.java:80) org.apache.tapestry.AbstractComponent.render(AbstractComponent.java:859) org.apache.tapestry.AbstractComponent.renderBody(AbstractComponent.java:626) org.apache.tapestry.form.Form.renderComponent(Form.java:366) org.apache.tapestry.AbstractComponent.render(AbstractComponent.java:859) org.apache.tapestry.form.Form.rewind(Form.java:601) org.apache.tapestry.engine.RequestCycle.rewindForm(RequestCycle.java:432) org.apache.tapestry.form.Form.trigger(Form.java:615) org.apache.tapestry.engine.DirectService.service(DirectService.java:169) org.apache.tapestry.engine.AbstractEngine.service(AbstractEngine.java:890) org.apache.tapestry.ApplicationServlet.doService(ApplicationServlet.java:200) org.apache.tapestry.ApplicationServlet.doPost(ApplicationServlet.java:329) javax.servlet.http.HttpServlet.service(HttpServlet.java:646) javax.servlet.http.HttpServlet.service(HttpServlet.java:727) org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303) org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220) org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122) org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:503) org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170) org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103) org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950) org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116) org.apache.catalina.ha.tcp.ReplicationValve.invoke(ReplicationValve.java:333) org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:421) org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1070) org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611) org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316) java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:897) java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:919) org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) java.lang.Thread.run(Thread.java:736) Caused by: org.apache.tapestry.ApplicationRuntimeException: Unable to invoke method dataImportByTxt on com.company.sale.view.realuser.report.effectevaluation.DataImportList$Enhance_0@7e907e90[effectevaluation.DataImport]: null org.apache.tapestry.listener.ListenerMap.invokeTargetMethod(ListenerMap.java:304) org.apache.tapestry.listener.ListenerMap.access$1(ListenerMap.java:269) org.apache.tapestry.listener.ListenerMap$SyntheticListener.invoke(ListenerMap.java:103) org.apache.tapestry.listener.ListenerMap$SyntheticListener.actionTriggered(ListenerMap.java:110) ... 32 more Caused by: java.lang.reflect.InvocationTargetException sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60) sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37) java.lang.reflect.Method.invoke(Method.java:611) org.apache.tapestry.listener.ListenerMap.invokeTargetMethod(ListenerMap.java:278) ... 35 more Caused by: org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Io exception: Connection refused(DESCRIPTION=(TMP=)(VSNNUM=169870592)(ERR=12505)(ERROR_STACK=(ERROR=(CODE=12505)(EMFI=4))))) org.apache.tomcat.dbcp.dbcp.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:1549) org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1388) org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:1044) com.company.dbframework.jdbc.ConnectionManager.getConnection(ConnectionManager.java:172) com.company.webframework.tapestry.BaseData.getDBConn(BaseData.java:365) com.company.dbframework.BaseEntity.<init>(BaseEntity.java:39) com.company.component.AppEntity.<init>(AppEntity.java:32) com.company.sale.bean.realuser.report.effectevaluation.DataNumberListDAO.<init>(DataNumberListDAO.java:18) com.company.sale.bean.realuser.report.effectevaluation.DataImportBean.importSerialnumber(DataImportBean.java:105) com.company.sale.view.realuser.report.effectevaluation.DataImportList.dataImportByTxt(DataImportList.java:126) ... 40 more Caused by: java.sql.SQLException: Io exception: Connection refused(DESCRIPTION=(TMP=)(VSNNUM=169870592)(ERR=12505)(ERROR_STACK=(ERROR=(CODE=12505)(EMFI=4)))) oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134) oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179) oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:333) oracle.jdbc.driver.OracleConnection.<init>(OracleConnection.java:404) oracle.jdbc.driver.OracleDriver.getConnectionInstance(OracleDriver.java:468) oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:314) org.apache.tomcat.dbcp.dbcp.DriverConnectionFactory.createConnection(DriverConnectionFactory.java:38) org.apache.tomcat.dbcp.dbcp.PoolableConnectionFactory.makeObject(PoolableConnectionFactory.java:582) org.apache.tomcat.dbcp.dbcp.BasicDataSource.validateConnectionFactory(BasicDataSource.java:1556) org.apache.tomcat.dbcp.dbcp.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:1545) ... 49 more
猜測是sid寫錯了,查詢一下,果然:
select INSTANCE_NAME from v$instance;把ngacct_s1改為ngacct1即可。