`
qwex9iao
  • 浏览: 173474 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

实际开发常见错误

    博客分类:
  • java
阅读更多
实际开发常见错误

1、  绑定错了对象导致attempted to delete null:

现象:在页面中删除对象失败

原因:在DAO的remove方法中

public void reomveSight(Long[] sightid) throws SightException

{

      for(int i=0;i<sightid.length;i++)

       super.removeObject(TtourInfo***.class,sightid[i]);

}

绑定错了对象,导致attempted to delete null错误。



2、  在一对多的前提下删除的时候不能级联删除子表中的数据:

现象:删除的时候不能级联删除子表中的数据导致报外键引用的错误。

解决方法:sight景点与image图片是一对多的关系,sight的hbm.xml配置文件原来在配置图片时是:

<!-- bi-directional one-to-many association to TtourInfoImage -->

    <set

        name="ttourInfoImages"

        lazy="true"

        inverse="true"

        cascade="none"

    >

        <meta attribute="field-description">

           @hibernate.set

            lazy="true"

            inverse="true"

            cascade="none"

           @hibernate.collection-key

            column="COMPANY"

           @hibernate.collection-one-to-many

            class="com.strongit.tour.bo.TtourInfoImage"

        </meta>

        <key>

            <column name="SIGHTID" />

        </key>

        <one-to-many

            class="com.strongit.tour.bo.TtourInfoImage"

        />

    </set>

现在改成

<!-- bi-directional one-to-many association to TtourInfoImage -->

    <set

        name="ttourInfoImages"

        lazy="true"

        inverse="true"

        cascade="all"

    >

        <meta attribute="field-description">

           @hibernate.set

            lazy="true"

            inverse="true"

            cascade="all"

           @hibernate.collection-key

            column="COMPANY"

           @hibernate.collection-one-to-many

            class="com.strongit.tour.bo.TtourInfoImage"

        </meta>

        <key>

            <column name="SIGHTID" />

        </key>

        <one-to-many

            class="com.strongit.tour.bo.TtourInfoImage"

        />

    </set>

就可以了。



3、  景区dao配置文件错误

错误描述:

Error registering

bean with name

'tour.scenicArea.sceneryAreaDao'

defined in ServletContext resource

[/WEB-INF/config_ext/applicationContext-tour-sceneryarea-dao.xml]:

Bean class

[import com.strongit.tour.scenicArea.dao.impl.SceneryAreaDaoImpl]

not found;

nested exception is java.lang.ClassNotFoundException:

import com.strongit.tour.scenicArea.dao.impl.SceneryAreaDaoImpl

解决方法:

applicationContext-tour-sceneryarea-dao.xml   中

class="com.strongit.tour.scenicArea.dao.impl.SceneryAreaDaoImpl"

写成了

class="import com.strongit.tour.scenicArea.dao.impl.SceneryAreaDaoImpl"



4、  景点配置文件错误

org.springframework.beans.factory.BeanCreationException:

Error creating bean with name

'tour.service.isightService'

defined in ServletContext resource

[/WEB-INF/config_ext/applicationContext-tour-sight-service.xml]:

Can't resolve reference to bean

'tour.service.sightService'

while setting property 'target';

nested exception is org.springframework.beans.factory.BeanCreationException:

Error creating bean with name 'tour.service.sightService'

defined in ServletContext resource [/WEB-INF/config_ext/applicationContext-tour-sight-service.xml]:

Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException:

Invalid property 'sightDao' of bean class [com.strongit.tour.scenicArea.service.impl.SightServiceImpl]:

Bean property 'sightDao' is not writable or has an invalid setter method:

Does the parameter type of the setter match the return type of the getter?

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'tour.service.sightService' defined in ServletContext resource [/WEB-INF/config_ext/applicationContext-tour-sight-service.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'sightDao' of bean class [com.strongit.tour.scenicArea.service.impl.SightServiceImpl]: Bean property 'sightDao' is not writable or has an invalid setter method: Does the parameter type of the setter match the return type of the getter?

org.springframework.beans.NotWritablePropertyException: Invalid property 'sightDao' of bean class [com.strongit.tour.scenicArea.service.impl.SightServiceImpl]: Bean property 'sightDao' is not writable or has an invalid setter method: Does the parameter type of the setter match the return type of the getter?

错误原因:

在com.strongit.tour.scenicArea.service.impl.SightServiceImpl类中没有对sightDao添加set属性。



5、  修改时没有提交值

缺少<html:hidden property="sceneryareaid"></html:hidden>来绑定id的值。



6、  初始化景点信息出错

org.apache.jasper.JasperException:

/member/tour/sceneryareamanage/sight_edit.jsp(121,7)

According to the TLD attribute property is mandatory for tag text

错误原因:htmltext标记与input标记的属性混用



7、  删除景点报500错

javax.servlet.ServletException:

No bean named '/tour/scenicArea/deleteSightAction' is defined:

错误原因:

在applicationcontext-tour-sight-action中删除的action配置的path

与struts-config-tour-sight中相应的删除配置不相同



8、  加载FORM表单的上传的文件数组元素时报参数错误

错误提示:

IllegalArgumentException          --argument type mismatch

解决方法:

在<html:form中加入enctype="multipart/form-data"



9、  使用HQL语句时出错

景点与图片是一对多的关系,现在要从一的景点中找到相应的图片的所有信息。

在daoimpl中



public List querySQLEx(String SqlStr) throws SightException

{

      return super.getHibernateTemplate().find(SqlStr);

}



public TtourInfoImage getImagePathToSight(Long sightid) throws SightException

{

  return (TtourInfoImage) this.querySQLEx("select TtourInfoImage m where m.ttourInfoSight.sightid="+sightid);

}

在删除的action的调用中

String msg="";

  try

  {

   String [] sightid=request.getParameter("delid").split(",");

   try

   {

    String root = getServletContext().getRealPath("/");

    System.out.println(root);

    Long [] sightID=new Long[sightid.length];

    List fileList=new ArrayList();

    for(int i=0;i<sightid.length;i++)

    {

     sightID[i]=Long.valueOf(sightid[i].trim());

     //把图片对象放入临时保存图片的图片路径数组中

fileList.add(sightService.getImagePathToSight(sightID[i]).getImageFile());

     System.out.println("原图="+sightService.getImagePathToSight(sightID[i]).getImageFile());

     fileList.add(sightService.getImagePathToSight(sightID[i]).getImageBreviry());

     System.out.println("缩略图="+sightService.getImagePathToSight(sightID[i]).getImageBreviry());

    }

    sightService.reomveSight(sightID);//先批量删除景点和与景点有关的图片表的数据

    sightService.delImage(root,fileList);//再删除图片表中,与景点相关的图片

    msg = "景点删除成功!";

   }

   catch (Exception e)

   {

    System.out.println(e.getMessage());

    log.info(e.getMessage());

    msg = "对不起,在您删除的数据中已有数据被使用,无法删除!";

   }

  }

  catch (RuntimeException e)

  {

   e.printStackTrace();

   msg="在删除景点的过程中出现意外错误!";

  }

  request.setAttribute("msg", msg);

     return mapping.findForward("success");



10、  配置文件错误

nested exception is org.springframework.beans.factory.BeanCreationException:

Error creating bean with name 'tour.service.commodityService' defined in ServletContext resource

[/WEB-INF/config_user/applicationContext-tour-commodity-service.xml]:

Error setting property values;

nested exception is org.springframework.beans.PropertyAccessExceptionsException:

PropertyAccessExceptionsException (1 errors);

nested propertyAccessExceptions are:

[org.springframework.beans.TypeMismatchException:

Failed to convert property value of type

[com.strongit.tour.commodityManage.dao.impl.CommodityTypeDAOImpl]

to required type [com.strongit.tour.commodityManage.dao.ICommodityDAO]

for property 'commodityDAO']

org.springframework.beans.factory.BeanCreationException:

Error creating bean with name 'tour.service.commodityService'

defined in ServletContext resource

[/WEB-INF/config_user/applicationContext-tour-commodity-service.xml]:

Error setting property values;

nested exception is org.springframework.beans.PropertyAccessExceptionsException:

PropertyAccessExceptionsException (1 errors); nested propertyAccessExceptions are:

[org.springframework.beans.TypeMismatchException:

Failed to convert property value of type [com.strongit.tour.commodityManage.dao.impl.CommodityTypeDAOImpl]

to required type [com.strongit.tour.commodityManage.dao.ICommodityDAO]

for property 'commodityDAO']

PropertyAccessExceptionsException (1 errors)

org.springframework.beans.TypeMismatchException:

Failed to convert property value of type

[com.strongit.tour.commodityManage.dao.impl.CommodityTypeDAOImpl]

to required type [com.strongit.tour.commodityManage.dao.ICommodityDAO]

for property 'commodityDAO'

错误原因:

在dao配置文件中 class="com.strongit.tour.commodityManage.dao.impl.CommodityDAOImpl"

写成了class="com.strongit.tour.commodityManage.dao.impl.CommodityTypeDAOImpl"



11、  级联删除商品的相关图片时报错

将商品hbm.xml文件中图片的相关链接的cascode="none"改为"all"。



12、  添加商品时没有触发action

在<html:form>里的action写错了。



13、  添加商品时没有找到actoin

javax.servlet.ServletException:

Error creating bean with name

'/tour/commodityManage/addCommodityAction'

defined in ServletContext resource

[/WEB-INF/config_user/applicationContext-tour-commodity-action.xml]:

Error setting property values;

nested exception is org.springframework.beans.NotWritablePropertyException:

Invalid property 'commodityService' of bean class

[com.strongit.tour.commodityManage.action.AddCommodityAction]:

Bean property 'commodityService' is not writable or has an invalid setter method:

Does the parameter type of the setter match the return type of the getter?

在AddCommodityAction.do中少了commodityService的set方法

14、  加载工程时有绔绞欢之类的错误

现象:加载工程时有绔绞欢之类的字样的错误,工程不能启动

解决方法:选中工程,选菜单下的Project下的Properties选项,

把字符编码改为UTF-8。

15、  工程中出现没有编译成的class文件

工程中出现没有编译成class文件时,选eclipe里的project的BuildAutomatically就行。
分享到:
评论

相关推荐

    PHP常见错误处理机制

    404错误定制,在实际项目开发中常见的消息定制处理页

    hive开发中常遇到的坑

    hive 下dual表,Lock,explain, 数据类型,开发常见的问题

    Java项目开发CodeReview 常见问题实例分析及指南

    本文从实际项目中抽取了一些项目中常见的Java开发所涉及的问题,进行实例分析,为各技术经理提供靶子和借鉴参考,如果审查者能够有意识地寻找特定的错误,而不是靠漫无目的的浏览代码来发现错误,那么代码审查的效果...

    网站开发专家Dreamweaver8+PHP动态网站开发实务

    书后的附录给出了常见错误信息 及SQL语法介绍。本书特色在于提供了完整的网站范例,学习后读者将能够 完整地实现网站建购全过程。本书附带光盘中包括所有实例的源文件及习题 文件。 本书语言简洁、内容丰富,...

    C#开发实例大全(基础卷).软件开发技术联盟(带详细书签) PDF 下载

    6.2 常见算法的实际应用 180 实例136 计算1+22+33+44+…+nn的值 180 实例137 计算10!的值 181 实例138 求最大公约数 181 实例139 求最小公倍数 182 实例140 判断素数的算法 183 实例141 按要求生成指定位数的编号 ...

    C#潮流计算和Visio二次开发画电气接线图

    1、 在调查和了解了网络教学的基本需求与应用现状的前提下设计开发了此程序,切合实际,具有较强的实用性。 2、本系统不需要通过网络即可运行,系统运行要求较低。并且系统可以在多种操作系统平台上(Windows NT/...

    python基础篇6.zip

    Python语言基础 Python的历史和特点 Python开发环境的搭建 Python的变量、注释和基本数据类型 条件和循环语句 条件判断和逻辑运算 循环控制和迭代操作 常见的循环和条件语句的应用 ...实践中的常见错误和调试技巧

    python基础篇5.zip

    Python语言基础 Python的历史和特点 Python开发环境的搭建 Python的变量、注释和基本数据类型 条件和循环语句 条件判断和逻辑运算 循环控制和迭代操作 常见的循环和条件语句的应用 ...实践中的常见错误和调试技巧

    python基础篇4.zip

    Python语言基础 Python的历史和特点 Python开发环境的搭建 Python的变量、注释和基本数据类型 条件和循环语句 条件判断和逻辑运算 循环控制和迭代操作 常见的循环和条件语句的应用 ...实践中的常见错误和调试技巧

    python基础篇3.zip

    Python语言基础 Python的历史和特点 Python开发环境的搭建 Python的变量、注释和基本数据类型 条件和循环语句 条件判断和逻辑运算 循环控制和迭代操作 常见的循环和条件语句的应用 ...实践中的常见错误和调试技巧

    python基础篇2.zip

    Python语言基础 Python的历史和特点 Python开发环境的搭建 Python的变量、注释和基本数据类型 条件和循环语句 条件判断和逻辑运算 循环控制和迭代操作 常见的循环和条件语句的应用 ...实践中的常见错误和调试技巧

    python基础篇1.zip

    Python语言基础 Python的历史和特点 Python开发环境的搭建 Python的变量、注释和基本数据类型 条件和循环语句 条件判断和逻辑运算 循环控制和迭代操作 常见的循环和条件语句的应用 ...实践中的常见错误和调试技巧

    网络安全开发包详解代码

    网络安全开发包实现的都是某一种或某一类网络安全技术,都是经过很多网络安全研究和开发者的长期研究而形成的,人们的不断测试和使用使它们逐渐成熟起来,在实际应用中得到了深入推广。 网络安全开发包有很多种,...

    CSTR&Handle Java 客户端.rar

    文章介绍了Android NDK开发的简单概念、常见错误及处理和从第一个Hello World开始实际做一个简单的JNI开发示例,相信看完之后,大家对NDK开发有了一个概念上的认识了,那么接下来我们需要再深入一下NDK的开发,我们...

    挑战Dreamweaver CS3网页设计与Web 2.0开发 (邓文渊)【PDF】

    附录篇——对常见服务器错误信息进行整理,并给出解决方法,让所有困难都迎刃而解。 光盘给出书中案例的源文件、结果文件和中间关键文件,方便对照学习。 本书系台湾大侠支招,适合网页设计与制作人员;网站建设与...

    使用VBA进行solidworks开发指南

    《使用VB进行SolidWorks开发》是一本面向SolidWorks用户和开发者的实用指南,旨在帮助读者利用Visual Basic (VB)编程语言对SolidWorks进行二次开发...- 介绍如何调试VB代码,以及如何处理常见的编程错误和异常等内容。

    经典JAVA.EE企业应用实战.基于WEBLOGIC_JBOSS的JSF_EJB3_JPA整合开发.pdf

    这个项目包括5个实体,这5个实体之间具有复杂的关联关系,而且业务逻辑也相对复杂,希望让读者理论联系实际,真正将jsf+ejb 3+jpa整合真正运用到实际开发中。该案例采用目前最流行、最规范的java ee架构,整个应用...

    ServletEx2 1.0 Java WEB 应用开发框架 完整版 (release, source, document, example 2010-01-13)

    这个框架主要分为四大部份,相信它已经包括了最常见的开发工作: 数据库操作; 模板操作; 表单操作; 工作流操作(开发中)。 目标 – Database数据库操作 不需要开发人员编写SQL,也不需要关心更多的数据库处理 ...

Global site tag (gtag.js) - Google Analytics