- 浏览: 408452 次
- 性别:
- 来自: 北京
文章分类
- 全部博客 (268)
- java (22)
- Acegi (8)
- Ajax (17)
- Annotation (3)
- Ant (3)
- JBOSS (6)
- Xdoclet (1)
- CSS (20)
- Data Warehouse (11)
- DB2 (3)
- DOM (1)
- dos (2)
- JMF (1)
- JMS (5)
- J2EE (17)
- Hibernate (7)
- struts (10)
- CORBA (1)
- 职业 (2)
- JSF (1)
- JSTL (8)
- 其它 (1)
- Log4j (7)
- svg (7)
- quartz (3)
- web2.0 (2)
- velocity (2)
- apache commons (1)
- js (9)
- html (4)
- sql (3)
- linux (4)
- dwr (14)
- spring (5)
- GWT (7)
- portlet (4)
- 软件工程 (10)
- actionscript (1)
- 测试 (1)
- tomcat (3)
- flash (0)
- 线程 (1)
- mysql (6)
- flex (1)
- oracle (7)
- crystalreport (4)
- itext (4)
- memcache (2)
- linux 监控 (2)
- mongodb (1)
- Kafka (5)
- 网络 (2)
- 分布式计算 (2)
最新评论
-
chenyongxin:
mark
JBoss 4.0.2集群基本知识及配置方法指南 -
softor:
我找到了,下载吧:http://ishare.iask.sin ...
jad是最简单的class反编译为java文件的小工具 (转载) -
softor:
求下载
dodo@lovehang.com
jad是最简单的class反编译为java文件的小工具 (转载) -
juedui0769:
不错!
请问: 如何在 将 log4j.appender ...
Tomcat 日志 配置 (转载) -
spp_1987:
// 建立一个上传文件的输出流
...
Struts上传多个及N个文件的例子
1、
org.springframework.orm.ObjectRetrievalFailureException: Object of class [com.xindeco.myregister.pojo.MyRegisterInfo] with identifier [14]: not found
MyRegisterInfo在数据库没有identifier [14]对象。
2、
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Initialization of bean failed; nested exception is org.hibernate.MappingException: Repeated column in mapping for entity: com.xindeco.myregister.pojo.MyRegisterInfo column: password (should be mapped with insert="false" update="false")
出错原因:password 和repassword同时对应数据库表中的password一列,同时update和insert都设为true。
xml文件如下:
<property name="password"
type="java.lang.String"
update="true"
insert="true"
access="property"
column="password"
length = "32"
/>
<property name="repassword"
type="java.lang.String"
update="false"
insert="false"
access="property"
column="password"
length = "32"
/>
解决的方法:
将repassword的insert和update设为false。
3、
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Initialization of bean failed;
nested exception is org.hibernate.PropertyNotFoundException: Could not find a getter for ID in class
错误原因:hibernate的映射文件中ID是大写的,而pojo的类中id是小写的
注意事项:每个pojo的类都要继承abstractEntity,其中abstractEntity类有个ID的属性要重写
public abstract class AbstractEntity
implements Entity, BaseDTO {
abstract public long getID();
abstract public void setID(long id);
public int hashCode() {
return (int)this.getID();
}
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (obj instanceof Entity) {
return this.getID() == ( (Entity) obj).getID();
}
return false;
}
}
4、
org.springframework.dao.InvalidDataAccessApiUsageException: Write operations are not allowed in read-only mode (FlushMode.NEVER) - turn your Session into FlushMode.AUTO or remove 'readOnly' marker from transaction definition
错误原因:
在application.xml文件中deleteRegister方法以delete开头,并没有被设定为可更改的,应如下设置:
<!--为事物创建代理类,并指定方法的事物类型-->
<bean id="baseTxProxy" lazy-init="true" abstract="true" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="transactionManager">
<ref bean="transactionManager"/>
</property>
<property name="transactionAttributes">
<props>
<prop key="add*">PROPAGATION_REQUIRED</prop>
<prop key="cancel*">PROPAGATION_REQUIRED</prop>
</props>
</property>
</bean>
加上一行
<prop key="delete*">PROPAGATION_REQUIRED</prop>
5、
ERROR org.apache.struts.util.RequestUtils - Error creating form bean of class com.xindeco.business.web.form.GraAppInfoForm
public class GraAppInfoForm
extends ActionForm 错误写成
public abstratic class GraAppInfoForm
extends ActionForm
6、
2006-04-25 08:56:38,495 ERROR com.xindeco.business.web.action.GraAppAction - com.xindeco.business.web.action.GraAppAction@8e2fb5
java.lang.ClassCastException: $Proxy0
at com.xindeco.business.web.action.GraAppAction.newone(GraAppAction.java:30)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:274)
at com.xindeco.core.web.action.BaseAction.dispatchMethod(BaseAction.java:153)
at org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:194)
actioin类中的newone方法如下:
public class GraAppAction
extends BaseAction {
public ActionForward newone(ActionMapping mapping, ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws Exception {
GraAppService graservice = (GraAppService) this.getBean("GraAppService");
}
applicationcontext中的GraAppService的配置如下:
<bean id="GraAppDAO" class="com.xindeco.business.dao.impl.GraAppDAOImpl">
<property name="support">
<ref local="support"/>
</property>
<property name="sessionFactory">
<ref local="sessionFactory"/>
</property>
</bean>
<bean id="GraAppService" parent="baseTxProxy">
<property name="target">
<bean class="com.xindeco.business.service.impl.GraAppServiceImpl" autowire="byName">
<property name="baseDAO">
<ref bean="GraAppDAO"/>
</property>
</bean>
</property>
</bean>
因此this.getBean("GraAppService");是为了得到GraAppServicImpl类的实现。GraAppService是interface
public class GraAppServiceImpl extends BaseServiceImpl
implements GraAppService{
}
7、org.hibernate.hql.ast.QuerySyntaxException: Demand is not mapped. [from Demand where unitid = ? and needNum > usedNeedNum]
hibernate.cfg.xml没有配置Demand.hbm.xml文件的目录
8、org.springframework.jdbc.BadSqlGrammarException: Bad SQL grammar [] in task 'Hibernate operation'; nested exception is java.sql.SQLException: 列名 'id' 无效。
java.sql.SQLException: 列名 'name' 无效。
因为hibernate声明的id,name的columnid属性没有与数据库的字段对应,所以id,name无效。
9、java.lang.NumberFormatException: null
at java.lang.Integer.parseInt(Integer.java:415)
at java.lang.Integer.parseInt(Integer.java:497)
at com.xindeco.business.service.impl.DemandServiceImpl.findDemandListByUnitId(DemandServiceImpl.java:33)
错误语句为
needNum = Integer.parseInt(demand.getNeedNum());
usedNeedNum = Integer.parseInt(demand.getUsedNeedNum());
因为demand.getUsedNeedNum()==null,无法转化为string 类型,
10、rg.apache.jasper.JasperException: /GraAppInfo/GraAppInfoNew.jsp(343,29) According to TLD, tag bean:write must be empty, but is not
错误的原因:
<select name="politicsID" >
<option value="">请选择</option>
<logic:notEmpty name="politicsList">
<logic:iterate id="politics" name="politicsList">
</logic:notEmpty>
<option value="<bean:write name="politics" property="codeID"/>"><bean:write name="politics" property="codeName"/></option>
</logic:iterate>
</select>
就因为少了/>
以后懂得通过查找字数,来检查错误
11、2006-04-26 13:27:54,812 ERROR com.xindeco.core.util.BeanUtils - bean property [Nation] copy failed
com.xindeco.core.exception.ConvertException: org.springframework.orm.hibernate3.HibernateSystemException: Unknown entity: java.lang.String; nested exception is org.hibernate.MappingException: Unknown entity: java.lang.String
beanUtil.beanCopy(grapojo,form,BizConstants.CONVERTER);
要求:
1、pojo类的属性只有与form属性名字相同,才能beancopy成功
2、pojo中属性是实体,在form中一定要用int,long表示
出现这错误的原因是pojo中的属性不是实体,而错误写成:
string
private String nation;应改成 private Syscode nation;
12、
2006-04-26 14:38:37,843 ERROR com.xindeco.business.web.action.GraAppAction - com.xindeco.business.web.action.GraAppAction@fa1b2d
java.lang.NullPointerException
at com.xindeco.business.web.action.GraAppAction.newone(GraAppAction.java:43)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
hibernate配置文件没改,程序找不到相应的类
<many-to-one
name="FSUnit"
class="com.xindeco.business.pojo.EmployUnitBaseInfo"
cascade="none"
outer-join="auto"
update="true"
insert="true"
access="property"
column="fSUnit"
/>
其实FSUnit对应的类应该是FSUnit
<many-to-one
name="FSUnit"
class="com.xindeco.business.pojo.FSUnit"
cascade="none"
outer-join="auto"
update="true"
insert="true"
access="property"
column="fSUnit"
/>
13、
org.hibernate.MappingException: An association from the table GraAppInfo refers to an unmapped class: com.xindeco.business.pojo.FSUnit
错误原因:hibernate.cfg.xml没有配置fsunit.hbm.xml文件的位置
14、
java.lang.ClassCastException: com.xindeco.business.dao.impl.GraAppDAOImpl
at com.xindeco.business.service.impl.GraAppServiceImpl.addGraduateApp(GraAppServiceImpl.java:16)
GraAppServiceImpl.java:16
第16行: GraAppDAO dao = (GraAppDAO) this.getBaseDAO();//其实得到的是GraAppDAOImpl
错误的原因是
public class GraAppDAOImpl
extends BaseDAOImpl {
}
没有实现GraAppDAO接口,正确的做法是
public class GraAppDAOImpl
extends BaseDAOImpl implements GraAppDAO {
}
先继承后实现
15、2006-04-27 08:38:54,078 ERROR com.xindeco.business.web.action.GraAppAction - com.xindeco.business.web.action.GraAppAction@1d6399b
java.lang.ClassCastException: com.xindeco.business.pojo.SysCode
at org.hibernate.type.StringType.set(StringType.java:26)
at org.hibernate.type.NullableType.nullSafeSet(NullableType.java:63)
at org.hibernate.type.NullableType.nullSafeSet(NullableType.java:40)
一般是因为hibernate声明类型和pojo类声明的类型不一样,并且前面已经出现了Hibernate: insert into TGraAppInfo (name, whereFrom, degree, college, speciality, studentRelTel, remark, higherEduLength, highSchool, studyResume, normalOrNot, proxyUnit, workPost, workPlace, studentAddress, studentPostNumber, nation, appStatus) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
的操作提示,查出错误的原因有:
<many-to-one
name="demand"
class="com.xindeco.business.pojo.Syscode"
cascade="none"
outer-join="auto"
update="true"
insert="true"
access="property"
column="demandID"
/>
<property
name="appStatus"
type="int"
update="true"
insert="true"
access="property"
column="appStatus"
length="10"
/>
应改为
<many-to-one
name="demand"
class="com.xindeco.business.pojo.Demand"
cascade="none"
outer-join="auto"
update="true"
insert="true"
access="property"
column="demandID"
/>
<many-to-one
name="nation"
class="com.xindeco.business.pojo.SysCode"
cascade="none"
outer-join="auto"
update="true"
insert="true"
access="property"
column="nation"
/>
16、
org.springframework.dao.InvalidDataAccessApiUsageException: object references an unsaved transient instance - save the transient instance before flushing: com.xindeco.business.pojo.SysCode
at org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:626)
at org.springframework.orm.hibernate3.HibernateTransactionManager.convertHibernateAccessException(HibernateTransactionManager.java:570)
at
org.springframework.orm.hibernate3.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:482)
pojo类为:
public class GraAppInfo{
private College college;
}
action 类为
public class GraAppAction
extends BaseAction {
public ActionForward add(ActionMapping mapping, ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws Exception {
graInfo.setCollege(new College());\\必须从数据库找到college这个对象,而不能新生成
graInfo.getCollege().setID(graForm.getCollegeID());
graInfo.setAppStatus(Integer.parseInt("0"));
service.addGraduateApp(graInfo);
}
public class GraAppServiceImpl extends BaseServiceImpl
implements GraAppService{
public boolean addGraduateApp(GraAppInfo info)
{
this.getBaseDAO().save(info);
return true;
}
}
dao类save方法为
getHibernateTemplate().save(obj);
当cascade="all",插入new college 除了id和原来的记录一样,其他的字段全部都被更新,为null
当cascase=“insert”,插入new college 只会把它的id插入grainfo表中,其他字段不变。
17、java.sql.SQLException: Unable to convert between java.lang.Integer and BLOB.
因为
<property
name="province"
type="com.xindeco.business.pojo.SysCode"//不能用复杂类,
update="true"
insert="true"
access="property"
column="provinceId"
/>
应该改为
<many-to-one
name="province"
class="com.xindeco.business.pojo.SysCode"
cascade="none"
outer-join="auto"
update="true"
insert="true"
access="property"
column="provinceId"
/>
18、javax.servlet.jsp.JspException: Cannot create iterator for this collection
at org.apache.struts.taglib.logic.IterateTag.doStartTag(IterateTag.java:265)
jsp文件如下:
<logic:notEmpty name="graduateList" >
<logic:iterate id="graduate" name="graduateList" >
</ogic:notEmpty >
</ogic:iterat>
graduateList是一个类,而logic:iterator要求必须是ArrayList,HashSet....这样的集合类,而graduateList中一个属性是ArrayList或HashSet的
应改为:
<logic:notEmpty name="graduateList" property="items">
<logic:iterate id="graduate" name="graduateList" property="items" >
</ogic:notEmpty >
</ogic:iterat>
19、2006-05-11 17:13:37,468 ERROR com.xindeco.business.web.action.GraAppAction - com.xindeco.business.web.action.GraAppAction@bc22eb
org.hibernate.LazyInitializationException: could not initialize proxy - the owning Session was closed
SysUser user= (SysUser) request.getSession().getAttribute(WebConstants.SESSION_USER);
System.out.println(user.getRole().getRoleName());
当hibernate session取出数据放到http session时,
由于sysuser中role的lazy=“true”,所以没有将RoleName放到http session中,当System.out.println(user.getRole().getRoleName());
时,虽然http session还开着, hibernat seesion已经关闭
<many-to-one
name="role"
class="com.xindeco.business.pojo.SysRole"
lazy="false"
cascade="none"
outer-join="auto"
update="true"
insert="true"
access="property"
column="roleID"
/>
20、Association references unmapped class: com.xindeco.workflow.WFNode
因为application.xml文件中没有配置<mapping resource="com/xindeco/workflow/WFNode.hbm.xml"/>
系统找不到WFNode
< set
name = " nodes "
table = " WF_ROLENODES "
lazy = " true "
inverse = " false "
cascade = " none "
sort = " unsorted "
>
< key
column = " roleID "
>
</ key >
< many - to - many
class = " com.xindeco.workflow.WFNode "
column = " nodeId "
outer - join = " auto "
/>
</ set >
org.springframework.orm.ObjectRetrievalFailureException: Object of class [com.xindeco.myregister.pojo.MyRegisterInfo] with identifier [14]: not found
MyRegisterInfo在数据库没有identifier [14]对象。
2、
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Initialization of bean failed; nested exception is org.hibernate.MappingException: Repeated column in mapping for entity: com.xindeco.myregister.pojo.MyRegisterInfo column: password (should be mapped with insert="false" update="false")
出错原因:password 和repassword同时对应数据库表中的password一列,同时update和insert都设为true。
xml文件如下:
<property name="password"
type="java.lang.String"
update="true"
insert="true"
access="property"
column="password"
length = "32"
/>
<property name="repassword"
type="java.lang.String"
update="false"
insert="false"
access="property"
column="password"
length = "32"
/>
解决的方法:
将repassword的insert和update设为false。
3、
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Initialization of bean failed;
nested exception is org.hibernate.PropertyNotFoundException: Could not find a getter for ID in class
错误原因:hibernate的映射文件中ID是大写的,而pojo的类中id是小写的
注意事项:每个pojo的类都要继承abstractEntity,其中abstractEntity类有个ID的属性要重写
public abstract class AbstractEntity
implements Entity, BaseDTO {
abstract public long getID();
abstract public void setID(long id);
public int hashCode() {
return (int)this.getID();
}
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (obj instanceof Entity) {
return this.getID() == ( (Entity) obj).getID();
}
return false;
}
}
4、
org.springframework.dao.InvalidDataAccessApiUsageException: Write operations are not allowed in read-only mode (FlushMode.NEVER) - turn your Session into FlushMode.AUTO or remove 'readOnly' marker from transaction definition
错误原因:
在application.xml文件中deleteRegister方法以delete开头,并没有被设定为可更改的,应如下设置:
<!--为事物创建代理类,并指定方法的事物类型-->
<bean id="baseTxProxy" lazy-init="true" abstract="true" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="transactionManager">
<ref bean="transactionManager"/>
</property>
<property name="transactionAttributes">
<props>
<prop key="add*">PROPAGATION_REQUIRED</prop>
<prop key="cancel*">PROPAGATION_REQUIRED</prop>
</props>
</property>
</bean>
加上一行
<prop key="delete*">PROPAGATION_REQUIRED</prop>
5、
ERROR org.apache.struts.util.RequestUtils - Error creating form bean of class com.xindeco.business.web.form.GraAppInfoForm
public class GraAppInfoForm
extends ActionForm 错误写成
public abstratic class GraAppInfoForm
extends ActionForm
6、
2006-04-25 08:56:38,495 ERROR com.xindeco.business.web.action.GraAppAction - com.xindeco.business.web.action.GraAppAction@8e2fb5
java.lang.ClassCastException: $Proxy0
at com.xindeco.business.web.action.GraAppAction.newone(GraAppAction.java:30)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:274)
at com.xindeco.core.web.action.BaseAction.dispatchMethod(BaseAction.java:153)
at org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:194)
actioin类中的newone方法如下:
public class GraAppAction
extends BaseAction {
public ActionForward newone(ActionMapping mapping, ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws Exception {
GraAppService graservice = (GraAppService) this.getBean("GraAppService");
}
applicationcontext中的GraAppService的配置如下:
<bean id="GraAppDAO" class="com.xindeco.business.dao.impl.GraAppDAOImpl">
<property name="support">
<ref local="support"/>
</property>
<property name="sessionFactory">
<ref local="sessionFactory"/>
</property>
</bean>
<bean id="GraAppService" parent="baseTxProxy">
<property name="target">
<bean class="com.xindeco.business.service.impl.GraAppServiceImpl" autowire="byName">
<property name="baseDAO">
<ref bean="GraAppDAO"/>
</property>
</bean>
</property>
</bean>
因此this.getBean("GraAppService");是为了得到GraAppServicImpl类的实现。GraAppService是interface
public class GraAppServiceImpl extends BaseServiceImpl
implements GraAppService{
}
7、org.hibernate.hql.ast.QuerySyntaxException: Demand is not mapped. [from Demand where unitid = ? and needNum > usedNeedNum]
hibernate.cfg.xml没有配置Demand.hbm.xml文件的目录
8、org.springframework.jdbc.BadSqlGrammarException: Bad SQL grammar [] in task 'Hibernate operation'; nested exception is java.sql.SQLException: 列名 'id' 无效。
java.sql.SQLException: 列名 'name' 无效。
因为hibernate声明的id,name的columnid属性没有与数据库的字段对应,所以id,name无效。
9、java.lang.NumberFormatException: null
at java.lang.Integer.parseInt(Integer.java:415)
at java.lang.Integer.parseInt(Integer.java:497)
at com.xindeco.business.service.impl.DemandServiceImpl.findDemandListByUnitId(DemandServiceImpl.java:33)
错误语句为
needNum = Integer.parseInt(demand.getNeedNum());
usedNeedNum = Integer.parseInt(demand.getUsedNeedNum());
因为demand.getUsedNeedNum()==null,无法转化为string 类型,
10、rg.apache.jasper.JasperException: /GraAppInfo/GraAppInfoNew.jsp(343,29) According to TLD, tag bean:write must be empty, but is not
错误的原因:
<select name="politicsID" >
<option value="">请选择</option>
<logic:notEmpty name="politicsList">
<logic:iterate id="politics" name="politicsList">
</logic:notEmpty>
<option value="<bean:write name="politics" property="codeID"/>"><bean:write name="politics" property="codeName"/></option>
</logic:iterate>
</select>
就因为少了/>
以后懂得通过查找字数,来检查错误
11、2006-04-26 13:27:54,812 ERROR com.xindeco.core.util.BeanUtils - bean property [Nation] copy failed
com.xindeco.core.exception.ConvertException: org.springframework.orm.hibernate3.HibernateSystemException: Unknown entity: java.lang.String; nested exception is org.hibernate.MappingException: Unknown entity: java.lang.String
beanUtil.beanCopy(grapojo,form,BizConstants.CONVERTER);
要求:
1、pojo类的属性只有与form属性名字相同,才能beancopy成功
2、pojo中属性是实体,在form中一定要用int,long表示
出现这错误的原因是pojo中的属性不是实体,而错误写成:
string
private String nation;应改成 private Syscode nation;
12、
2006-04-26 14:38:37,843 ERROR com.xindeco.business.web.action.GraAppAction - com.xindeco.business.web.action.GraAppAction@fa1b2d
java.lang.NullPointerException
at com.xindeco.business.web.action.GraAppAction.newone(GraAppAction.java:43)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
hibernate配置文件没改,程序找不到相应的类
<many-to-one
name="FSUnit"
class="com.xindeco.business.pojo.EmployUnitBaseInfo"
cascade="none"
outer-join="auto"
update="true"
insert="true"
access="property"
column="fSUnit"
/>
其实FSUnit对应的类应该是FSUnit
<many-to-one
name="FSUnit"
class="com.xindeco.business.pojo.FSUnit"
cascade="none"
outer-join="auto"
update="true"
insert="true"
access="property"
column="fSUnit"
/>
13、
org.hibernate.MappingException: An association from the table GraAppInfo refers to an unmapped class: com.xindeco.business.pojo.FSUnit
错误原因:hibernate.cfg.xml没有配置fsunit.hbm.xml文件的位置
14、
java.lang.ClassCastException: com.xindeco.business.dao.impl.GraAppDAOImpl
at com.xindeco.business.service.impl.GraAppServiceImpl.addGraduateApp(GraAppServiceImpl.java:16)
GraAppServiceImpl.java:16
第16行: GraAppDAO dao = (GraAppDAO) this.getBaseDAO();//其实得到的是GraAppDAOImpl
错误的原因是
public class GraAppDAOImpl
extends BaseDAOImpl {
}
没有实现GraAppDAO接口,正确的做法是
public class GraAppDAOImpl
extends BaseDAOImpl implements GraAppDAO {
}
先继承后实现
15、2006-04-27 08:38:54,078 ERROR com.xindeco.business.web.action.GraAppAction - com.xindeco.business.web.action.GraAppAction@1d6399b
java.lang.ClassCastException: com.xindeco.business.pojo.SysCode
at org.hibernate.type.StringType.set(StringType.java:26)
at org.hibernate.type.NullableType.nullSafeSet(NullableType.java:63)
at org.hibernate.type.NullableType.nullSafeSet(NullableType.java:40)
一般是因为hibernate声明类型和pojo类声明的类型不一样,并且前面已经出现了Hibernate: insert into TGraAppInfo (name, whereFrom, degree, college, speciality, studentRelTel, remark, higherEduLength, highSchool, studyResume, normalOrNot, proxyUnit, workPost, workPlace, studentAddress, studentPostNumber, nation, appStatus) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
的操作提示,查出错误的原因有:
<many-to-one
name="demand"
class="com.xindeco.business.pojo.Syscode"
cascade="none"
outer-join="auto"
update="true"
insert="true"
access="property"
column="demandID"
/>
<property
name="appStatus"
type="int"
update="true"
insert="true"
access="property"
column="appStatus"
length="10"
/>
应改为
<many-to-one
name="demand"
class="com.xindeco.business.pojo.Demand"
cascade="none"
outer-join="auto"
update="true"
insert="true"
access="property"
column="demandID"
/>
<many-to-one
name="nation"
class="com.xindeco.business.pojo.SysCode"
cascade="none"
outer-join="auto"
update="true"
insert="true"
access="property"
column="nation"
/>
16、
org.springframework.dao.InvalidDataAccessApiUsageException: object references an unsaved transient instance - save the transient instance before flushing: com.xindeco.business.pojo.SysCode
at org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:626)
at org.springframework.orm.hibernate3.HibernateTransactionManager.convertHibernateAccessException(HibernateTransactionManager.java:570)
at
org.springframework.orm.hibernate3.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:482)
pojo类为:
public class GraAppInfo{
private College college;
}
action 类为
public class GraAppAction
extends BaseAction {
public ActionForward add(ActionMapping mapping, ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws Exception {
graInfo.setCollege(new College());\\必须从数据库找到college这个对象,而不能新生成
graInfo.getCollege().setID(graForm.getCollegeID());
graInfo.setAppStatus(Integer.parseInt("0"));
service.addGraduateApp(graInfo);
}
public class GraAppServiceImpl extends BaseServiceImpl
implements GraAppService{
public boolean addGraduateApp(GraAppInfo info)
{
this.getBaseDAO().save(info);
return true;
}
}
dao类save方法为
getHibernateTemplate().save(obj);
当cascade="all",插入new college 除了id和原来的记录一样,其他的字段全部都被更新,为null
当cascase=“insert”,插入new college 只会把它的id插入grainfo表中,其他字段不变。
17、java.sql.SQLException: Unable to convert between java.lang.Integer and BLOB.
因为
<property
name="province"
type="com.xindeco.business.pojo.SysCode"//不能用复杂类,
update="true"
insert="true"
access="property"
column="provinceId"
/>
应该改为
<many-to-one
name="province"
class="com.xindeco.business.pojo.SysCode"
cascade="none"
outer-join="auto"
update="true"
insert="true"
access="property"
column="provinceId"
/>
18、javax.servlet.jsp.JspException: Cannot create iterator for this collection
at org.apache.struts.taglib.logic.IterateTag.doStartTag(IterateTag.java:265)
jsp文件如下:
<logic:notEmpty name="graduateList" >
<logic:iterate id="graduate" name="graduateList" >
</ogic:notEmpty >
</ogic:iterat>
graduateList是一个类,而logic:iterator要求必须是ArrayList,HashSet....这样的集合类,而graduateList中一个属性是ArrayList或HashSet的
应改为:
<logic:notEmpty name="graduateList" property="items">
<logic:iterate id="graduate" name="graduateList" property="items" >
</ogic:notEmpty >
</ogic:iterat>
19、2006-05-11 17:13:37,468 ERROR com.xindeco.business.web.action.GraAppAction - com.xindeco.business.web.action.GraAppAction@bc22eb
org.hibernate.LazyInitializationException: could not initialize proxy - the owning Session was closed
SysUser user= (SysUser) request.getSession().getAttribute(WebConstants.SESSION_USER);
System.out.println(user.getRole().getRoleName());
当hibernate session取出数据放到http session时,
由于sysuser中role的lazy=“true”,所以没有将RoleName放到http session中,当System.out.println(user.getRole().getRoleName());
时,虽然http session还开着, hibernat seesion已经关闭
<many-to-one
name="role"
class="com.xindeco.business.pojo.SysRole"
lazy="false"
cascade="none"
outer-join="auto"
update="true"
insert="true"
access="property"
column="roleID"
/>
20、Association references unmapped class: com.xindeco.workflow.WFNode
因为application.xml文件中没有配置<mapping resource="com/xindeco/workflow/WFNode.hbm.xml"/>
系统找不到WFNode
< set
name = " nodes "
table = " WF_ROLENODES "
lazy = " true "
inverse = " false "
cascade = " none "
sort = " unsorted "
>
< key
column = " roleID "
>
</ key >
< many - to - many
class = " com.xindeco.workflow.WFNode "
column = " nodeId "
outer - join = " auto "
/>
</ set >
评论
2 楼
liondinas
2008-01-03
也许是因为某些包你没有导进去
1 楼
wywweifeng
2007-12-16
org.apache.jasper.JasperException
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:372)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
root cause
java.lang.NullPointerException
org.apache.struts.taglib.tiles.InsertTag.processAttribute(InsertTag.java:687)
org.apache.struts.taglib.tiles.InsertTag.createTagHandler(InsertTag.java:478)
org.apache.struts.taglib.tiles.InsertTag.doStartTag(InsertTag.java:438)
org.apache.jsp.adopt_jsp._jspx_meth_tiles_insert_0(adopt_jsp.java:449)
org.apache.jsp.adopt_jsp._jspx_meth_html_html_0(adopt_jsp.java:134)
org.apache.jsp.adopt_jsp._jspService(adopt_jsp.java:79)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:372)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
root cause
java.lang.NullPointerException
org.apache.struts.taglib.tiles.InsertTag.processAttribute(InsertTag.java:687)
org.apache.struts.taglib.tiles.InsertTag.createTagHandler(InsertTag.java:478)
org.apache.struts.taglib.tiles.InsertTag.doStartTag(InsertTag.java:438)
org.apache.jsp.adopt_jsp._jspx_meth_tiles_insert_0(adopt_jsp.java:449)
org.apache.jsp.adopt_jsp._jspx_meth_html_html_0(adopt_jsp.java:134)
org.apache.jsp.adopt_jsp._jspService(adopt_jsp.java:79)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
发表评论
-
使用Struts的Token机制解决表单的重复提交
2008-07-31 13:29 727Struts的Token(令牌)机制能够很好的解决表单重复提交 ... -
Struts标签中的多层logic:iterator详解
2007-10-28 12:44 1287logic:Iterator标签(以 ... -
Struts标签
2007-10-28 12:44 894html:form注意事项 在使用html:form时需指定 ... -
Struts标签-Html(转载)
2007-10-28 12:43 1191Struts Html标签和标准的HTML标签功能相同,这里提 ... -
Struts标签
2007-10-28 12:43 1060Struts标签 solo L 发布日 ... -
Strus常见错误及原因分析
2007-10-28 12:42 3098本篇文章包含了在用Struts开发web应用时经常碰到的一些异 ... -
Struts提供了五个标签库
2007-10-28 12:41 1263Struts提供了五个标签库,即:HTML、Bean、Logi ... -
Struts常见错误及原因分析
2007-10-28 12:41 7291 异常 javax.servlet.jsp.JspE ... -
Struts上传多个及N个文件的例子
2007-10-28 12:16 1197最近一个基于Struts的项目中要用到上传多张图片到系统中,我 ...
相关推荐
根据给定的文件信息,我们可以总结出以下几个关键知识点,它们对于解决Exchange Server 2010的常见问题至关重要。 ### 1. 安装.NET Framework 3.5.1 在安装Exchange Server 2010之前,确保服务器上已安装了.NET ...
面对ORA-01033错误,关键是理解其背后的逻辑机制,并采取适当的措施来管理数据库实例的状态。无论是通过设置环境变量、使用SQL*Plus控制数据库生命周期,还是利用PL/SQL Developer进行更高级的用户管理和权限调整,...
《JAVA几个常见错误简析》 在Java编程中,错误处理是开发者必须面对的重要环节。本文主要分析了Java中常见的空指针异常(NullPointerException),这是许多初学者和经验丰富的开发者都可能遇到的问题。了解这些错误...
ORA-01460错误的出现可能源于以下几个方面: 1. **数据类型不兼容**:当源表中的数据类型与目标表的数据类型不匹配,且Oracle数据库无法自动完成转换时,会引发此错误。 2. **复杂的对象类型**:在处理包含嵌套对象...
这主要涉及并发处理、故障隔离和错误处理等关键技术。 首先,错误处理是软件开发中至关重要的一环。在C/C++这样的编程语言中,由于其对指针的广泛使用,错误往往与非法指针访问或数组越界等问题密切相关。为了提高...
解决这个问题的关键在于丰富学生的典型题型库,提高他们对新问题的分析能力,鼓励他们在解题时进行独立思考,避免盲目套用旧模式。 经历性干扰包括强信息干扰和思维迁移。强信息干扰指的是学生对某些特定数学知识...
这篇文章虽然标题为“纠正几个关于赚钱的错误认知”,但其实主要讨论的是市场营销和人性洞察在商业活动中的应用。以下是对这些观点的详细解读: 1. **消费者购买的往往是情感和幻想**:消费者并不总是追求产品的...
磁盘错误检测修复主要涉及以下几个知识点: 1. **磁盘错误类型**:常见的磁盘错误包括逻辑错误和物理错误。逻辑错误通常由文件系统损坏、病毒攻击或不正常关机引起,可以通过扫描和修复文件系统来解决。物理错误则...
比如:“面对一个棘手的问题时,我首先会冷静分析问题的根源,然后和团队成员一起头脑风暴,寻找最佳解决方案。失败的经验让我更清楚地认识到事前规划的重要性,这将帮助我避免未来的错误。” 在处理成绩与期望的...
下面将详细解析几个常见的ICC错误,帮助学习者更好地理解并解决它们。 ### ICC错误集锦:看懂ICC AVR的报错 #### 错误一:未知文件类型(@main.lk) 当你看到“unknownfiletype@main.lk,passedtolinker”这类错误时...
面对段错误,有效的调试是解决问题的关键。以下是两种常用的调试方法: 1. **利用gdb进行逐步调试** `gdb`是一款强大的命令行调试工具,可以帮助开发者定位和修复程序中的各种错误,包括段错误。使用gdb进行调试...
基于以上信息,我们可以深入探讨以下几个知识点: 1. **考研网络科目**:网络科目通常包括OSI七层模型、TCP/IP五层模型、IP地址分类、子网掩码、路由选择算法、HTTP、FTP等基础协议,以及网络安全、网络编程等相关...
蓝屏时显示的错误信息分为几个关键部分: 1. 停机码(Stop Code):例如STOP 0x0000001E,这是识别错误类型的标识,每个停机码都对应一种特定的错误情况。 2. 参数集:括号中的四个数字(如0xC0000005, 0xFDE38AF9, ...
小学数学教育中,低年级学生在解决问题时常常会出现思维错误,这主要体现在以下几个方面: 1. **单一联系代替运算分析**:学生有时会忽略题目中关键的数量关系,直接以表面的个别因素为依据进行解答。例如,当面对...
这两个错误表明数据文件验证失败,文件大小与记录的正确大小不符。这可能是由于数据库非正常关闭导致的。要解决这个问题,需要计算出文件应有的字节数,然后在操作系统级别创建一个空文件并将其附加到错误的数据文件...
【五年级语文上册 第7单元 面对错误测试题 北师大版-北师大版小学五年级上册语文试题】 本测试题主要针对五年级学生的语文学习,...通过解决这些问题,学生可以加深对“面对错误”的理解和处理方式,提高语文素养。
在焊管制造企业中,为实现智能化生产,即智能制管,有几个关键问题需要优先解决。 首先,成本投入是企业应用人工智能技术时必须面对的问题。实现智能制管需要对生产设备进行升级改造,引进先进的传感器、控制和自动...
针对这个特定的JavaScript语法错误问题,我们可以采用以下几种方法来解决: ##### 1. 修改`onerror`事件处理函数 一种常见的做法是修改浏览器的`onerror`事件处理函数。通过重写该函数,可以捕获并处理所有未捕获...
### 解决FileZilla Server因路径错误导致无法启动问题详细图文教程 #### 一、问题背景与概述 在配置Windows 2021服务器时,遇到了一个关于FileZilla Server因路径错误导致服务无法启动的问题。FileZilla Server是...
### 安装Win7展开失败错误代码:0x80070570 ...总之,面对安装Win7过程中出现的错误代码0x80070570,关键在于细致地排查每个可能的原因,并逐一尝试相应的解决措施。希望上述信息能对遇到类似问题的用户有所帮助。