Wednesday, July 09, 2008

在调用actionLink组件中碰到的关于hibernate的连接错误

在tapestry5中做一个页面时碰到如下错误:
只要在这个页面中有使用actionLink组件并且传入了context值的时候,会涉及对应的ValueEncoder,程序总是会去通过org.apache.tapestry5.hibernate.HibernateModule.contributeValueEncoderSource去找hibernate.xml.cnf这个默认的配置文件去连接数据库。
当这个hibernate.xml.cnf文件里的配置不能连上数据库时就会在连接超时之后抛出以下错误,之后页面会正常显示,以后再次访问此页面就不会再连接数据库了,页面也是即时刷出来。如果配置文件能够连接上数据库,则会抛出下面第一行的[WARN]信息,连接不会超时,所以页面访问也不会受到影响。

[WARN] cfg.AnnotationBinder Package not found or wo package-info.java: com.test.www.entities
[WARN] cfg.SettingsFactory Could not obtain connection metadata
com.mysql.jdbc.CommunicationsException: Communications link failure due to underlying exception:

** BEGIN NESTED EXCEPTION **

java.net.SocketException
MESSAGE: java.net.ConnectException: Operation timed out

STACKTRACE:

java.net.SocketException: java.net.ConnectException: Operation timed out
at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:156)
at com.mysql.jdbc.MysqlIO.(MysqlIO.java:276)
at com.mysql.jdbc.Connection.createNewIO(Connection.java:2666)
at com.mysql.jdbc.Connection.(Connection.java:1531)
....
at org.apache.tapestry5.hibernate.HibernateModule.contributeValueEncoderSource(HibernateModule.java:149)
....

No comments :