[java网文系列一]SSH整合常出现问题
1、org.springframework.beans.NotWritablePropertyException(很畸形的bug)
出现异常的原因是在application-xxx.xml中property name的错误。
<property name="....">中name的名字是与bean的set方法相关的,而且要注意大小写。一般第二个字母不能大写
比如
public class PostManageImpl extends BaseManage implements PostManage {
private PostDAO dao = null;
public void setPostDAO(PostDAO postDAO){
this.dao = postDAO;
}
}
那么xml的定义应该是:
<bean id="postManage" parent="txProxyTemplate">
<property name="target">
<bean class="com.yz.spring.service.implement.PostManageImpl">
<property name="postDAO"><ref bean="postDAO"/></property>对
<property name="dao"><ref bean="postDAO"/></property>错
</bean>
</property>
</bean>
2、Struts中的DispatchAction中提交jsp中请求事件不能跳转到指定页面
原因是在DispatchAction中存在execute方法,Action会优先执行此方法而不会按照url传过来的method方法执行,所以千万注意此处
3、Field 'id' doesn't have a default value
原因是数据库中id属性值没有让它“自动增长”
4、could not initialize proxy - no Session
Hibernate3 错误: could not initialize proxy - no Session
org.hibernate.LazyInitializationException: could not initialize proxy - no Session
at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:57)
at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:111)
原因:
hibernate3 many-to-one的默认选项是 lazy = "proxy"
解决方法:
<many-to-one> & <one-to-many> 中设置 lazy="false"
5、在使用Jbpm工作流引擎的时候,Hibernate配置文件一定要加上属性
<property name="hibernate.hbm2ddl.auto">update</property>
Hbm2dll.auto是数据库表和类自动连接更新
6、jbpm与Spring整合报错:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jbpmConfiguration' defined in ServletContext resource [/WEB-INF/classes/applicationContext.xml]: Initialization of bean failed; nested exception is java.lang.IllegalArgumentException: a beanFactoryReference already exists for key jbpmConfiguration
解决方法:去掉struts-config.xml文件中的org.springframework.web.struts.ContextLoaderPlugIn,也就是与Spring整合的插件
我的异常网推荐解决方案:org.springframework.beans.factory.BeanCreationException:,http://www.myexception.cn/j2ee/10759.html