我在weblogic应用程序上传文件时遇到问题。
文件上传器完成保存文件后,会出现以下异常:
java.sql.SQLException: Conexión cerrada
at oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:70)
at oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:133)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:199)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:263)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:271)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:445)
at oracle.sql.BLOB.getDBAccess(BLOB.java:882)
at oracle.sql.BLOB.freeTemporary(BLOB.java:584)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.jdbc.support.lob.OracleLobHandler$OracleLobCreator.close(OracleLobHandler.java:412)
at org.springframework.jdbc.support.lob.SpringLobCreatorSynchronization.afterCompletion(SpringLobCreatorSynchronization.java:76)
at org.springframework.transaction.support.TransactionSynchronizationUtils.invokeAfterCompletion(TransactionSynchronizationUtils.java:133)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.invokeAfterCompletion(AbstractPlatformTransactionManager.java:951)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.triggerAfterCompletion(AbstractPlatformTransactionManager.java:926)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:754)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:678)
at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:319)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:116)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy74.guardarFichero(Unknown Source)
在其他环境中,这个问题并没有出现,所以我认为它必须是JDBC驱动程序的一些配置,但我不确定我必须修改它。
调用struts
private void adjuntarFichero()throws Exception {
logger.debug("uploadFileName = "+uploadFileName);
if (uploadFileName!=null && !uploadFileName.equals("")) {
HttpSession session = request.getSession();
HashMap<Long,String> ficheros = (HashMap<Long,String>)session.getAttribute("ficheros");
if (ficheros == null) ficheros = new HashMap<Long,String>();
Fichero file = new FicheroImpl();
file.setNombre(uploadFileName);
file.setFichero(getBytesFromFile(upload));
file = gestorFichero.guardarFichero(file);
ficheros.put(file.getId(), uploadFileName);
session.setAttribute("ficheros", ficheros);
}
}
错误发生在&#34; guardarFichero&#34;方法,调用DAO类来处理保存
公共抽象类gestorFichero 扩展org.springframework.orm.hibernate3.support.HibernateDaoSupport {
public Fichero guardarFichero (Fichero fichero){
Debug.prec(fichero, "El fichero no puede ser nulo");
return (Fichero)create(TRANSFORM_NONE, fichero);
}
public java.lang.Object create(final int transform, final com.aena.sgc.Fichero fichero)
{
if (fichero == null){
throw new IllegalArgumentException("Fichero.create - 'fichero' can not be null");
}
this.getHibernateTemplate().save(fichero);
return this.transformEntity(transform, fichero);
}
答案 0 :(得分:0)
最后我发现这是问题。
它与驱动程序类有关。最初我们将数据源配置为使用XA驱动程序 oracle.jdbc.xa.client.OracleXADataSource ,每当我们完成上传文件时,都会抛出异常。
一旦我将驱动程序更改为 oracle.jdbc.OracleDriver ,这些错误就会消失。