views:

169

answers:

1

Hello,

I am getting the following exception when I typo the SQL driver name or the database server is offline, basically any SQLException.

I can't determine where the UndeclaredThrowableException is coming from. Line 194 in SqlMapClientTemplate is this:

logger.debug("Obtained JDBC Connection [" + springCon + "] for iBATIS operation");

Here is the trace:

    java.lang.reflect.UndeclaredThrowableException
        $Proxy59.toString(Unknown Source)
    java.lang.String.valueOf(Unknown Source)
    java.lang.StringBuffer.append(Unknown Source)
    org.springframework.orm.ibatis.SqlMapClientTemplate.execute(SqlMapClientTemplate.java:194)
    org.springframework.orm.ibatis.SqlMapClientTemplate.executeWithListResult(SqlMapClientTemplate.java:249)
    org.springframework.orm.ibatis.SqlMapClientTemplate.queryForList(SqlMapClientTemplate.java:296)
    org.springframework.orm.ibatis.SqlMapClientTemplate.queryForList(SqlMapClientTemplate.java:290)

some of my reading points to some type of class loading problem? I can't figure out where the $Proxy is getting introduced?

+1  A: 

The $Proxy59 class must be the type of the springCon variable. It is a JDK proxy type, probably introduced by the Spring framework, as a wrapper for the real connection. I know of a pooled connection provider that returns connections which suppress the close() method via a proxy (because the connection is pooled, calling close is not the client's task).

Maybe the proxy's handler for the toString() method throws a checked exception, which is possible with the proxy mechanics, but not allowed.

The Java Documentation says:

  • "If a checked exception is thrown by invoke that is not assignable to any of the exception types declared in the throws clause of the interface method, then an UndeclaredThrowableException will be thrown by the method invocation on the proxy instance. The UndeclaredThrowableException will be constructed with the exception that was thrown by the invoke method."

Do you get any other exception logged, maybe directly before that, or mentioned as the exception cause?

Christian Semrau