解决ognl.MethodFailedException: Method "list" failed for object com.szy.ResourceAction的问题

最恐怖的是你觉得哪也没问题却还是报错,然后一步步的拆分开来试错, 最后发现是一个多么没有剧情的Exception。

下面是具体Exception的前面一小部分:

ognl.MethodFailedException: Method "list" failed for object com.szy.ResourceAction@28b7e20d [java.lang.ExceptionInInitializerError]
    ognl.OgnlRuntime.callAppropriateMethod(OgnlRuntime.java:1305)
    ognl.ObjectMethodAccessor.callMethod(ObjectMethodAccessor.java:68)
    com.opensymphony.xwork2.ognl.accessor.XWorkMethodAccessor.callMethodWithDebugInfo(XWorkMethodAccessor.java:117)
    com.opensymphony.xwork2.ognl.accessor.XWorkMethodAccessor.callMethod(XWorkMethodAccessor.java:108)
    ognl.OgnlRuntime.callMethod(OgnlRuntime.java:1369)
    ognl.ASTMethod.getValueBody(ASTMethod.java:90)
    ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:212)
    ognl.SimpleNode.getValue(SimpleNode.java:258)
    ognl.Ognl.getValue(Ognl.java:494)
    ognl.Ognl.getValue(Ognl.java:458)

其它走过的弯路就不说了,直接说错误点吧,下面是我开始时的hibernate.cfg.xml配置:

<hibernate-configuration  xmlns="http://www.hibernate.org/xsd/hibernate-configuration" xsi:schemaLocation="http://www.hibernate.org/xsd/hibernate-configuration hibernate-configuration-4.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <session-factory>
    <property name="connection.driver_class">com.mysql.jdbc.Driver</property> 
    <property name="connection.url">jdbc:mysql://localhost:3306/blog</property> 
    <property name="connection.username">root</property>
    <property name="connection.password">root</property>
    <property name="dialect">org.hibernate.dialect.MySQL5Dialect</property>

    <property name="connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property>
    <property name="initialPoolSize" value="3"></property>
    <property name="minPoolSize" value="3"></property>
    <property name="maxPoolSize" value="5"></property>
    <property name="acquireIncrement" value="3"></property>
    <property name="maxStatements" value="8"></property>
    <property name="maxStatementsPerConnection" value="5"></property>
    <property name="maxIdleTime" value="1800"></property>

    <property name="show_sql">true</property>
    <property name="hbm2ddl.auto">update</property>

    <mapping resource="com/szy/Resource.hbm.xml"/>

    </session-factory>
</hibernate-configuration>

把它改为:

<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
    <session-factory>
    <property name="connection.driver_class">com.mysql.jdbc.Driver</property> 
    <property name="connection.url">jdbc:mysql://localhost:3306/blog</property> 
    <property name="connection.username">root</property>
    <property name="connection.password">root</property>
    <property name="dialect">org.hibernate.dialect.MySQL5Dialect</property>

    <property name="connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property>
    <property name="initialPoolSize">3</property>
    <property name="minPoolSize">3</property>
    <property name="maxPoolSize">5</property>
    <property name="acquireIncrement">3</property>
    <property name="maxStatements">8</property>
    <property name="maxStatementsPerConnection" >5</property>
    <property name="maxIdleTime">1800</property>

    <property name="show_sql">true</property>
    <property name="hbm2ddl.auto">update</property>

    <mapping resource="com/szy/blog/domain/Resource.hbm.xml"/>

    </session-factory>
</hibernate-configuration>

注意:
*改动的地方是把原来配置数据源时的property标签的value属性值移到property的开始和结束标签中间。然而property标签是完全支持value属性的,为什么不能写在value属性里,我也不知道。。
*头文件也要做相应的改动

版权声明:本文为博主原创文章,未经博主允许不得转载。

 

你可能感兴趣的:(exception)