[
http://jira.jboss.com/jira/browse/JBAS-3258?page=comments#action_12341344 ]
Ravi K commented on JBAS-3258:
------------------------------
Temporary Fix while we wait for 404SP1
If you are comfortable with enabling aspects here's a touch-free solution to the
"Already closed" exceptions in 4.0.4. This works with JDK 5.0.
Put this class anywhere you like in your source:
---------------------------------------
package mypackage;
import java.sql.SQLException;
import org.jboss.aop.Bind;
import org.jboss.aop.InterceptorDef;
import org.jboss.aop.advice.Interceptor;
import org.jboss.aop.joinpoint.Invocation;
/**
* Temporary fix to JBoss's connection pool which throws an exception
* every time a JDBC resource is closed twice. This violates the
* JDBC API contract.
*
* In this aspect the close call is being wrapped and the false
* exception is being ignored.
*
* @author ravi
*/
@InterceptorDef
@Bind (pointcut="execution(*
org.jboss.resource.adapter.jdbc.WrappedStatement->close())")
@Bind (pointcut="execution(*
org.jboss.resource.adapter.jdbc.WrappedResultSet->close())")
public class JBossConnectionAspect implements Interceptor
{
public String getName()
{
return "JBossConnectionAspect";
}
public Object invoke(Invocation invocation) throws Throwable
{
try
{
return invocation.invokeNext();
}
catch(SQLException sqle)
{
/* Ignore false exceptions throw due to a JBoss bug */
if(sqle.getMessage().equals("Already closed"))
{
System.out.println("Aspectized wrapper: JBoss said resource already
closed.");
return null;
}
else
{
throw sqle;
}
}
}
}
---------------------------------------
You might want to turn off the System.out if it gets too verbose.
Assuming you followed the standard instructions and JBoss is running the
jboss-aof-jdk50.deployer just change base-aop.xml under
..\server\<servername>\deploy\jboss-aop-jdk50.deployer\
<aop>
<aspect class="mypackage.JBossConnectionAspect"/>
<bind pointcut="execution(public void
org.jboss.resource.adapter.jdbc.WrappedStatement->close(..))">
<interceptor class="mypackage.JBossConnectionAspect"/>
</bind>
</aop>
ravi(a)pobox.com
JDBC artificats should throw SQLException when already closed
-------------------------------------------------------------
Key: JBAS-3258
URL:
http://jira.jboss.com/jira/browse/JBAS-3258
Project: JBoss Application Server
Issue Type: Bug
Security Level: Public(Everyone can see)
Components: JCA service
Affects Versions: JBossAS-4.0.4.GA
Reporter: Adrian Brock
Assigned To: Weston Price
Fix For: JBossAS-4.0.4.SP1
In the change to fix JBAS-2741 I mistakenly made the JDBC wrappers throw an SQL
exception if the artifact is already closed. They should just return with an exception.
From the Javadoc:
"Calling the method close on a Statement object that is already closed has no
effect."
e.g. In WrappedStatement
public void close() throws SQLException
{
synchronized (lock)
{
if (closed)
throw new SQLException("Already closed");
closed = true;
}
lc.unregisterStatement(this);
internalClose();
}
this should be:
public void close() throws SQLException
{
synchronized (lock)
{
if (closed)
return;
closed = true;
}
lc.unregisterStatement(this);
internalClose();
}
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira