简体   繁体   English

由于Spring + iBatis中的SQLException,导致UndeclaredThrowableException吗?

[英]UndeclaredThrowableException due to SQLException in Spring + iBatis?

I am getting the following exception when I typo the SQL driver name or the database server is offline, basically any SQLException. 当我输入SQL驱动程序名称或数据库服务器脱机时,出现以下异常,基本上是任何SQLException。

I can't determine where the UndeclaredThrowableException is coming from. 我无法确定UndeclaredThrowableException的来源。 Line 194 in SqlMapClientTemplate is this: SqlMapClientTemplate中的第194行是这样的:

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? 我不知道在哪里引入$ Proxy?

The $Proxy59 class must be the type of the springCon variable. $Proxy59类必须是类型springCon变量。 It is a JDK proxy type, probably introduced by the Spring framework, as a wrapper for the real connection. 它是JDK代理类型,可能是Spring框架引入的,作为实际连接的包装。 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). 我知道有一个池化连接提供程序,该提供程序返回通过代理来抑制close()方法的连接(因为连接是池化的,因此调用close不是客户端的任务)。

Maybe the proxy's handler for the toString() method throws a checked exception, which is possible with the proxy mechanics, but not allowed. 也许toString()方法的代理处理程序会引发一个已检查的异常,这对于代理机制而言是可能的,但不允许这样做。

The Java Documentation says: Java文档说:

  • "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." “如果调用检查引发的异常无法分配给接口方法的throws子句中声明的任何异常类型,则代理实例上的方法调用将引发UndeclaredThrowableException。UndeclaredThrowableException将与由invoke方法引发的异常。”

Do you get any other exception logged, maybe directly before that, or mentioned as the exception cause? 您是否还记录了其他任何异常,也许是在此之前,或者被提及为异常原因?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM