日期:2014-05-20  浏览次数:21284 次

SSH项目运行报:Could not find a getter for pid in class...在线等!!!!
这个是运行部分错误信息:
[ERROR] 2011-09-05 15:58:25,991 org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3799) Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactoryId' defined in class path resource [net/zzvc/szmt/aug/config/beans.xml]: Invocation of init method failed; nested exception is org.hibernate.HibernateException: Unable to instantiate default tuplizer [org.hibernate.tuple.entity.PojoEntityTuplizer]
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at org.hibernate.tuple.entity.EntityTuplizerFactory.constructTuplizer(EntityTuplizerFactory.java:107)
... 49 more
Caused by: org.hibernate.PropertyNotFoundException: Could not find a getter for pid in class net.zzvc.szmt.aug.entity.TblPopedomgroup
at org.hibernate.property.BasicPropertyAccessor.createGetter(BasicPropertyAccessor.java:306)
at org.hibernate.property.BasicPropertyAccessor.getGetter(BasicPropertyAccessor.java:299)
at org.hibernate.mapping.Property.getGetter(Property.java:294)
at org.hibernate.tuple.entity.PojoEntityTuplizer.buildPropertyGetter(PojoEntityTuplizer.java:300)
at org.hibernate.tuple.entity.AbstractEntityTuplizer.<init>(AbstractEntityTuplizer.java:141)
at org.hibernate.tuple.entity.PojoEntityTuplizer.<init>(PojoEntityTuplizer.java:78)
... 54 more
2011-9-5 15:58:25 org.apache.catalina.core.StandardContext start
严重: Error listenerStart
2011-9-5 15:58:25 org.apache.catalina.core.StandardContext start
严重: Context [/ZZVC_HOMEPAGE] startup failed due to previous errors
[INFO] 2011-09-05 15:58:25,991 org.apache.catalina.core.ApplicationContext.log(ApplicationContext.java:653) Closing Spring root WebApplicationContext
log4j:ERROR LogMananger.repositorySelector was null likely due to error in class reloading, using NOPLoggerRepository.
我的TblPopedomgroup类里面有get和set方法的,不知道这是什么情况?
请各位大侠们帮忙解决一下,谢谢!

------解决方案--------------------
问题提示: 
org.hibernate.PropertyNotFoundException: Could not find a getter for attribute 

问题分析: 
1)getter()方法写错了,没有按照javaBean的规则写. 

2)*.hmb.xml中的属性名和pojo中的是否一致.注意:属性名是否多了空格. 
启示:.hbm.xml里的排列最好跟数据库表里的排列一样!最好不要乱改变位置!否则会出莫名其妙的错误! 

3)字段的取名要注意。比如数据库中的字段为M_R_ID,映射到hbm.xml为mRId,那么产生的POJO也是mRId,自动产生的getter方法为:getMRId();相应的setter方法一致,这样就会抛出上面所述异常,这个应该是hibernate的模板格式问题。所以尽量要避免这样的命名。 

解决方法: 
1)换做getmRId(); 问题可解决,没有抛出异常,能取值。 
2)修改数据库字段名。这个最好,不会产生以后的不确定因素。 

我的异常网推荐解决方案:Unable to instantiate default tuplizer [org.hibernate.tuple.entity.PojoEntityTuplizer],http://www.myexception.cn/eclipse/174629.html