quartz在web中時有罷工(轉)

chssheng2007發表於2011-03-10

quartz整合到tomcat採用是使用 ServletContextListener方案,參見http://www.blogjava.net/Unmi/archive/2008/05/01/197657.html

tomcat執行一段時間後,控制檯報以下錯誤
2009-03-06 09:38:21 [org.quartz.core.ErrorLogger]-[ERROR] An error occured while scanning for the next trigger to fire.
org.quartz.JobPersistenceException: Couldn't rollback jdbc connection. Io 異常: Connection reset by peer: socket write error [See nested exception: java.sql.SQLException: Io 異常: Connection reset by peer: socket write error]
at org.quartz.impl.jdbcjobstore.JobStoreSupport.rollbackConnection(JobStoreSupport.java:2319)
at org.quartz.impl.jdbcjobstore.JobStoreTX.acquireNextTrigger(JobStoreTX.java:1222)
at org.quartz.core.QuartzSchedulerThread.run(QuartzSchedulerThread.java:233)
* Nested Exception (Underlying Cause) ---------------
java.sql.SQLException: Io 異常: Connection reset by peer: 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.OracleConnection.rollback(OracleConnection.java:1380)
at org.apache.commons.dbcp.DelegatingConnection.rollback(DelegatingConnection.java:328)
at org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.rollback(PoolingDataSource.java:312)
at org.quartz.impl.jdbcjobstore.JobStoreSupport.rollbackConnection(JobStoreSupport.java:2317)
at org.quartz.impl.jdbcjobstore.JobStoreTX.acquireNextTrigger(JobStoreTX.java:1222)
at org.quartz.core.QuartzSchedulerThread.run(QuartzSchedulerThread.java:233)
2009-03-06 09:38:46 [org.quartz.impl.jdbcjobstore.JobStoreTX]-[ERROR] MisfireHandler: Error handling misfires: Couldn't rollback jdbc connection. Io 異常: Connection reset by peer: socket write error
org.quartz.JobPersistenceException: Couldn't rollback jdbc connection. Io 異常: Connection reset by peer: socket write error [See nested exception: java.sql.SQLException: Io 異常: Connection reset by peer: socket write error]
at org.quartz.impl.jdbcjobstore.JobStoreSupport.rollbackConnection(JobStoreSupport.java:2319)
at org.quartz.impl.jdbcjobstore.JobStoreTX.doRecoverMisfires(JobStoreTX.java:1361)
at org.quartz.impl.jdbcjobstore.JobStoreSupport$MisfireHandler.manage(JobStoreSupport.java:2449)
at org.quartz.impl.jdbcjobstore.JobStoreSupport$MisfireHandler.run(JobStoreSupport.java:2468)
* Nested Exception (Underlying Cause) ---------------
java.sql.SQLException: Io 異常: Connection reset by peer: 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.OracleConnection.rollback(OracleConnection.java:1380)
at org.apache.commons.dbcp.DelegatingConnection.rollback(DelegatingConnection.java:328)
at org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.rollback(PoolingDataSource.java:312)
at org.quartz.impl.jdbcjobstore.JobStoreSupport.rollbackConnection(JobStoreSupport.java:2317)
at org.quartz.impl.jdbcjobstore.JobStoreTX.doRecoverMisfires(JobStoreTX.java:1361)
at org.quartz.impl.jdbcjobstore.JobStoreSupport$MisfireHandler.manage(JobStoreSupport.java:2449)
at org.quartz.impl.jdbcjobstore.JobStoreSupport$MisfireHandler.run(JobStoreSupport.java:2468)

解決方法:

We searched google on the error and found the solution of overriding the getObjectFromBlob(ResultSet rs, String colName) method of

org.quartz.impl.jdbcjobstore.MSSQLDelegate class which is used in DotJobStore.java.

We implemented the solution as follows:
1.Coded a new class by name org.quartz.impl.jdbcjobstore.DotMSSQLDelegate.java which extends org.quartz.impl.jdbcjobstore.MSSQLDelegate

2.overridden the method getObjectFromBlob(ResultSet rs, String colName) which has below code:

      InputStream binaryInput = rs.getBinaryStream(colName);
if (binaryInput == null || binaryInput.available()== 0)
{
return null;
}
Object obj = null;
ObjectInputStream in =null;
try
{
in= new ObjectInputStream(binaryInput);
obj = in.readObject();
}catch(Exception e){
e.printStackTrace();
}
finally
{
if(in!=null)
in.close();
}

return obj;

3.We tested and it is working fine.

If it is ok for you We want to commit the code.

Are we moving in the right direction?

http://www.javauu.com/thread-16-1-1.html

相關文章