`
g4_gc
  • 浏览: 61807 次
  • 性别: Icon_minigender_1
  • 来自: 广州
社区版块
存档分类
最新评论

struts2错误集合

    博客分类:
  • ssh
阅读更多
1.java.lang.ClassCastException: java.lang.Integer  从session取值后转化到int
String ss=session.get("id").toString();
int id=Integer.parseInt(ss);
2.将string转化为float
float f=Float.valueOf("11");
3.将Integer转化为String
4.String转化为double
Double.parseDouble("11.1");
5.struts2 标签换行
在默认情况下,表单元素是分布在不同行的。如下代码:
<s:form action="login2"> 
<s:textfield label="用户名" name="username"/>   
<s:password label="密码" name="password"/>   
<s:submit label="提交"/>
</s:form>
我们看着以上的代码跟HTML的差不了多少,但是因为struts2表单默认将表单内的每一个元素都分在单独的一行,label属性就如同我们在HTML中在<input type="text"/>前面的文字标签一样。如果我们不想让它自动换行,那就应该写成如下格式:
<s:form action="login2" theme="simple">   
<s:textfield label="用户名" name="username"/>   
<s:password label="密码" name="password"/>   
<s:submit label="提交"/>
</s:form>
但在设置theme="simple"后,表单元素的label属性将失效,这时我们就得在表单元素前面加入想用label显示的文字。如:
<s:form action="login2" theme="simple">     
用户名:<s:textfield label="用户名" name="username"/>     
密码:<s:password label="密码" name="password"/>   
<s:submit label="提交"/>
</s:form>
此时显示的为将不在是label中的值,而是显示文本框前面的文字,按钮则显示它原来的默认值:sbumit。

ell-formed character data or markup.
6.No result defined for action com.upload.UploadAction and result input
form中可能缺少:method="post"
7. \upload\鏉庡紑澶峔缁欎腑鍥藉鐢熺殑绗簩灏佷俊.doc (系统找不到指定的路径。)
public String getSavePath() {
return ServletActionContext.getRequest().getRealPath(savePath);//不能写成return this.savePath;
}
8.The method getRealPath(String) from the type ServletRequest is deprecated
ServletActionContext.getRequest().getRealPath(savePath);
把页面中的编码改成GBK
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
改为:<%@ page  language="java" contentType="text/html;charset=GBK"%>

9.如何使用JDK中的bin的native2ascii来进行中文转换
10.Exception in thread "main" java.util.MissingResourceException: Can't find bundle for base name mess, locale zh_CN

无法读取中文数据
11.struts2中不能用<s:hidden>标签,否则action只会返回"input"

12.Exception starting filter struts2
java.lang.ClassNotFoundException: org.apache.struts2.dispatcher.FilterDispatcher

没有加入Struts2需要的几个包
__________________________________________________________________________________________
13.Error building results for action validateName in namespace  - action
Caused by: There is no result type defined for type 'json' mapped with name 'success' - result

_________________________________________________________________________________________
14.uk.ltd.getahead.dwr.util.CommonsLoggingOutput error
严重: Found reference to variable named 'c0-e1', but no variable of that name could be found.
2009-2-5 17:32:56 uk.ltd.getahead.dwr.util.CommonsLoggingOutput info
信息: Exec[0]: validator.doPost()
2009-2-5 17:32:56 org.apache.struts2.validators.DWRValidator doPost
严重: Error while trying to validate
There is no Action mapped for action name . - [unknown location]
___________________________________________________________________________________________
15.Bean type class com.opensymphony.xwork2.ObjectFactory with the name xwork has already been loaded by bean
________________________________________________________________________________________________
16.警告: No configuration found for the specified action: 'login.action' in namespace: ''. Form action defaulting to 'action'

___________________________________________________________________________________________
17.2009-2-9 12:00:55 com.opensymphony.xwork2.validator.ActionValidatorManagerFactory <clinit>
信息: Detected AnnotationActionValidatorManager, initializing it...

attribute's literal value
______________________________________________________________________________________________
18.严重: Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.orm.hibernate3.LocalSessionFactoryBean]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: org/dom4j/DocumentException
Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.orm.hibernate3.LocalSessionFactoryBean]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: org/dom4j/DocumentException
Caused by: java.lang.NoClassDefFoundError: org/dom4j/DocumentException
____________________________________________________________
19.信息: building session factory
Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userDao' defined in class path resource [applicationContext.xml]: Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: org/objectweb/asm/Type
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: org/objectweb/asm/Type
Caused by: java.lang.NoClassDefFoundError: org/objectweb/asm/Type

缺少包:asm.jar
__________________________________________________________________________________________
20.信息: building session factory
Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userDao' defined in class path resource [applicationContext.xml]: Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: net/sf/cglib/proxy/CallbackFilter
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: net/sf/cglib/proxy/CallbackFilter
Caused by: java.lang.NoClassDefFoundError: net/sf/cglib/proxy/CallbackFilter

缺少包:commons-collections-2.1.1.jar

_____________________________________________________________________________________
21.信息: Loading XML bean definitions from class path resource [applicationContext.xml]
Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userDao' defined in class path resource [applicationContext.xml]: Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.orm.hibernate3.LocalSessionFactoryBean]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: org/dom4j/DocumentException
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.orm.hibernate3.LocalSessionFactoryBean]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: org/dom4j/DocumentException
Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.orm.hibernate3.LocalSessionFactoryBean]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: org/dom4j/DocumentException
Caused by: java.lang.NoClassDefFoundError: org/dom4j/DocumentException

缺少包:dom4j-1.6.1.jar

___________________________________________________________________________
22.严重: 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 'sessionFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Instantiation of bean failed; nested exception is java.lang.NoClassDefFoundError: javax/transaction/TransactionManager
Caused by: java.lang.NoClassDefFoundError: javax/transaction/TransactionManager

缺少包:jta.jar
___________________________________________________________________________
23.java.lang.IllegalArgumentException: sessionFactory or hibernateTemplate is required
根据提示在配置文件中为这个类添加一个property属性
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
就不会报错.但是其它的Service类并不需要这么做,让我感觉很奇怪.最终发现原来是我让CataogService  extends HibernateDaoSupport .改正后运行正常,goood
牢记....
________________________________________________________________________________
24.Exception in thread "main" java.lang.NoClassDefFoundError: net/sf/ehcache/CacheException
缺少包:ehcache-1.2.3.jar
________________________________________________________________________________
25.Exception in thread "main" java.lang.NoClassDefFoundError: net/sf/cglib/core/KeyFactory
缺少包:cglib-2.1.3.jar
_______________________________________________________________________________________
26.Exception in thread "main" java.lang.NoClassDefFoundError: antlr/ANTLRException

___________________________________________________________
27.Exception starting filter struts
Action class [loginbean] not found
加入包:struts2-spring-plugin-2.0.6.jar
struts.xml文件中加入:
<constant name="objectFactory" value="spring"></constant>
______________________________________________________________________
28.log4j:WARN No appenders could be found for logger (org.apache.catalina.startup.TldConfig).
log4j:WARN Please initialize the log4j system properly.
加入文件
log4j.properties
#
# Log4J Settings for log4j 1.2.x (via jakarta-commons-logging)
#
# The five logging levels used by Log are (in order):
#
#   1. DEBUG (the least serious)
#   2. INFO
#   3. WARN
#   4. ERROR
#   5. FATAL (the most serious)


# Set root logger level to WARN and append to stdout
log4j.rootLogger=INFO, stdout

log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout

# Pattern to output the caller's file name and line number.
log4j.appender.stdout.layout.ConversionPattern=%d %5p (%c:%L) - %m%n

# Print only messages of level ERROR or above in the package noModule.
log4j.logger.noModule=FATAL

# OpenSymphony Stuff
log4j.logger.com.opensymphony=INFO
log4j.logger.org.apache.struts2=INFO

# Spring Stuff
log4j.logger.org.springframework=INFO
___________________________________________________________________________
29.警告: Settings: Could not parse struts.locale setting, substituting default VM locale)
原来要解决也不难,
创建struts.properties这个文件,放在src目录下就可以了
struts.locale=en_GB
____________________________________________________
30.No configuration found. Configuring ehcache from ehcache-failsafe.xml found in the classpath
把hibernate里ehcache-1.2.3.jar的ehcache.xml拷贝到src目录下,hibernate3用到了ehcache
___________________________________________________________________________________
31. Missing classdef for creator 'script'. Failed to load uk.ltd.getahead.dwr.create.ScriptedCreator. Cause: org/apache/bsf/BSFException
缺少包:bsf.jar
_____________________________________________________
32.No result defined for action com.action.LoginAction and result input - action - file:/E:/struts2Workspace/login/WebRoot/WEB-INF/classes/struts.xml:11:55
当使用struts2的配置文件验证时,若表单验证不通过,系统将默认返回"input",这时要在struts.xml中配置这个result
<result name="input">/login.jsp</result>
_________________________________________________________________________
33.org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: org/apache/commons/collections/SequencedHashMap
Caused by:
java.lang.NoClassDefFoundError: org/apache/commons/collections/SequencedHashMap
缺少包:commons-collections-2.1.1.jar
_______________________________________________________________________________________
34.org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: net/sf/ehcache/CacheException
Caused by:
java.lang.NoClassDefFoundError: net/sf/ehcache/CacheException
缺少包:ehcache-1.2.3.jar
___________________________________________________________________________________
35.No result defined for action com.action.ValidateNameAction and result input - action


_____________________________________________-
36.java.sql.SQLException: Positioned Update not supported.
分析---------------------------------------------------------------------------------------
在我的ValidateNameAction中一共有3个properties,其中有个bean是userManager而且是在spring framework中已经实例化了的,问题就出在它身上了。于是在struts.xml中加入该bean的exclude,再测试,成功了!
发送action的request后,服务返回JSON数据。

解决-----------------------------------------------------------------------------------------
<package name="demo" namespace="/" extends="json-default">
   <action name="roomStatus" class="room" method="roomStatus">
    <result type="json">
     <param name="excludeProperties">
                      userManager
       </param>
      </result>
   </action>
</package>
_________________________________________________________________________________________________
37.java.lang.OutOfMemoryError: PermGen space及其解决方法
PermGen space的全称是Permanent Generation space,是指内存的永久保存区域OutOfMemoryError: PermGen space从表面上看就是内存益出,解决方法也一定是加大内存。说说为什么会内存益出:这一部分用于存放Class和Meta的信息,Class在被 Load的时候被放入PermGen space区域,它和和存放Instance的Heap区域不同,GC(Garbage Collection)不会在主程序运行期对PermGen space进行清理,所以如果你的APP会LOAD很多CLASS的话,就很可能出现PermGen space错误。这种错误常见在web服务器对JSP进行pre compile的时候。
内存溢出。
如果你的应用中有很多CLASS的话,就很可能出现PermGen space错误,
这种错误常见在web服务器对JSP进行pre compile的时候。如果你的WEB APP下使用了大量的第三方jar, 其大小超过了jvm默认的大小(4M)
那么就会产生此错误信息了。

解决方法: 手动设置MaxPermSize大小
修改TOMCAT_HOME/bin/catalina.sh
在“echo "Using CATALINA_BASE: $CATALINA_BASE"”上面加入以下行:
JAVA_OPTS="-server -XX:PermSize=64M -XX:MaxPermSize=128m

____________________________________________________________________________________________________---
38.struts2 中execute方法不执行问题
为一个action比如是LoginAction增加一个验证文件LoginAction-validation.xml,如果验证文件中要验证的字段多于登陆到LoginAction的页面上的字段,那么系统就会返回INPUT,而不会执行execute方法

________________________________________________________________________________________________________
39.java.lang.OutOfMemoryError: PermGen space
补充一下Windows下的做法:
设置环境变量JAVA_OPTS=-Xms512m -Xmx1024m -XX:PermSize=256m -XX:MaxPermSize=256m
即可,java.lang.OutOfMemoryError: PermGen space的问题以前经常遇到,现在可以对付了
________________________________________________________________________________________________________
40.org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: org/dom4j/io/SAXReader
Caused by: java.lang.NoClassDefFoundError: org/dom4j/io/SAXReader
解决的方法:加入包dom4j-1.6.1.jar
分享到:
评论
1 楼 napoleonshow 2011-04-14  
谢谢分享!!

相关推荐

    struts2错误集合.txt

    struts2错误集合.txt,里有有本人学习STRUTS2时遇到的问题,以及问题的解决方法

    struts2+hibernate+spring整合jar包

    在对struts2,hibernate以及spring进行整合时,我们经常会使用MyEclipse自己为我们导入jar包,而实际上有很多jar包我们用不上,而且各框架之间的jar包还可能会有冲突,最终导致我们的项目过大,部署时间长,还可能会...

    Struts2-登录验证码

    完整的Struts2框架,联系oracle数据库实现登录验证 验证码功能:点击图片切换验证码,验证码错误提示 登录成功后变量session中的list集合 内含备注

    struts2 标签库 帮助文档

    Struts 2 标签库(文档手册) Tags-API-CLSW-JSP &lt;%@ taglib prefix="s" uri="/struts-tags" %&gt; 就能使用struts2.0的标签库 下面就介绍每个标签的具体应用实例说明:按字母排列 A: 1. 2. &lt;s:a href=""&gt;&lt;/s:a&gt;-...

    Struts常见错误的全面汇总

    集合了各种常见的错误和异常,希望对大家有帮助

    Spring3Struts2、Hibernate3 Jar包

    ssh集合spring3、struts2、hibernate3框架jar包集合支持annotation,属于最大jar包集合、诚信赚分、如有未知错误与本人联系、······

    低清版 大型门户网站是这样炼成的.pdf

    2.5.3 自定义国际化struts 2校验错误消息 92 2.5.4 struts 2的自带校验器 92 2.6 struts 2的拦截器 94 2.6.1 struts 2内建拦截器介绍 95 2.6.2 定义和使用拦截器栈 97 2.6.3 使用自定义拦截器 98 2.7 小结 100...

    struts转化器.rar

    关于struts的转化器,数组属性的类型转换器,集合属性的类型转换器,直接封装成Object,直接封装成Map,类型转换的错误处理,全局类型转换器

    ajax+json+Struts2实现list传递实例讲解

    由于实习需要,需要通过ajax来获取后台的List集合里面的值。由于前面没有接触过,所以今天就来研究下了。 一、首先需要下载JSON依赖的jar包。它主要是依赖如下: json-lib-2.2.2-jdk15 ezmorph-1.0.4 commons-...

    J2EE教程资料 JavaEE程序设计与应用开发教程 全套PPT课件资源集合 共21个章节 含上机习题和全部源代码.rar

    11 Struts标签和错误处理(共38页) 12 Struts2基础开发(共30页) 13 Hibernate基础编程(共26页) 14 Hibernate高级编程(共27页) 15 Spring基础编程(共24页) 16 Struts、Spring、Hibernate的整合(共22页) 17...

    Struts in Action中文版

    2. 深入 STRUTS架构..................................................................................37 2.1. 随便谈谈......................................................................................

    Java Web编程宝典-十年典藏版.pdf.part2(共2个)

    全书分4篇,共24章,其中,第1篇为技能学习篇,主要包括Java Web开发环境、JSP语法、JSP内置对象、Java Bean技术、Servlet技术、EL与JSTL标签库、数据库应用开发、初识Struts2基础、揭密Struts2高级技术、Hib锄劬e...

    struts in Action

    2. 深入STRUTS 架构..................................................................................37 2.1. 随便谈谈.......................................................................................

    java面试题大全--java基础,struts,spring,ejb等

    10.找出下列代码可能存在的错误,并说明原因: 二、JSP&Servlet技术 1.描述JSP和Servlet的区别、共同点、各自应用的范围 2.在Web开发中需要处理HTML标记时,应做什么样的处理,要筛选那些字符(&lt; &gt; & “”) 3.在...

    Java学习笔记-个人整理的

    \contentsline {chapter}{Contents}{2}{section*.1} {1}Java基础}{17}{chapter.1} {1.1}基本语法}{17}{section.1.1} {1.2}数字表达方式}{17}{section.1.2} {1.3}补码}{19}{section.1.3} {1.3.1}总结}{23}{...

    FreeMark学习笔记

    还可以使用数字范围定义数字集合,如2..5等同于[2, 3, 4, 5],但是更有效率.注意,使用数字范围来定义集合时无需使用方括号,数字范围也支持反递增的数字范围,如5..2 5,Map对象 Map对象使用花括号包括,Map中的key-value...

    Spring in Action(第二版 中文高清版).part2

    16.2 协同使用Spring和WebWork 2/Struts 2 16.3 集成Spring和Tapestry 16.3.1 集成Spring和Tapestry 3 16.3.2 集成Spring和Tapestry 4 16.4 协同使用Spring和JSF 16.4.1 解析JSF管理的属性 16.4.2 解析Spring...

Global site tag (gtag.js) - Google Analytics