- 浏览: 64688 次
- 性别:
- 来自: 广州
文章分类
最新评论
-
就不给你佛:
甚好
M2工程 mvn deploy 401 403错误处理 -
lian819:
相当简洁, 支持一个
Tomcat7配置发布jndi数据源 -
judim:
window.showModalDialog 去掉水平滚动条在 ...
window.showModalDialog 去掉水平滚动条 -
leoz0802:
哥们。。。想问下怎么设置热部署不重启服务器。谢了。。。最好有p ...
run-jetty-run热部署问题补充 -
napoleonshow:
谢谢分享!!
struts2错误集合
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
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
- struts2错误集合.rar (5 KB)
- 下载次数: 5
发表评论
-
解决Jetty运行时锁定静态文件(css, js, image)的问题
2012-12-07 08:46 1554解决Jetty运行时锁定静态文件(css, js, im ... -
jetty的Form too large异常解决方案
2012-12-07 08:46 1549在用jetty做图片上传时发现jetty的reque ... -
【转】Quartz CronTrigger最完整配置说明
2012-12-03 13:27 1075CronTrigger配置格式: 格式: [秒] [分 ... -
struts2-OGNL表达式中的#、%和$
2012-12-03 13:26 749OGNL表达式非常强大~其中#、%、$这三个符号在OGN ... -
struts2.x标签if test 的一个字符型值字符串比较(转)
2012-12-03 13:25 868例如这个语句 要判断struts堆栈里systemSettin ... -
run-jetty-run热部署问题补充
2011-07-07 12:00 2844本身配置了run-jetty-run来debug自己的war, ... -
Tomcat部署两个相同工程遇到问题及解决方案汇总
2011-04-13 11:30 1643一、 我写了2个用了struts2的项目。 若我把这2个项目全 ... -
Tomcat7配置发布jndi数据源
2011-04-13 11:24 2388Tomcat7配置发布jndi数据源 Jul-13-2010 ...
相关推荐
### Struts2错误集合知识点详解 #### 一、类型转换问题 在开发过程中,经常会遇到类型转换的问题。这里提到了几种常见的类型转换方法。 1. **`java.lang.ClassCastException`:** 当尝试将一个对象强制转换为另一个...
5. **处理异常**:学习如何配置Struts2的全局异常处理,优雅地处理程序中的错误。 6. **文件上传和下载**:掌握如何使用Struts2的FileUpload插件处理文件上传和下载功能。 7. **国际化**:学习如何实现应用的多...
在标题中提到的"struts2-json包集合 不会出现任何报错",意味着这个压缩包集合包含了一组兼容的Struts2和JSON相关的库,可以避免常见的错误,特别是`textutils class找不到`的问题。 在描述中,提到了几个关键的包...
6. **异常处理**:Struts2提供了统一的异常处理机制,允许开发者自定义错误页面和错误处理策略。 7. **国际化与本地化**:支持多语言环境,可以轻松实现应用的国际化和本地化。 8. **表单验证**:内置了强大的表单...
此标签类似于Struts1中的JavaBean引用,但在Struts2中并不常用,因为Struts2更倾向于使用Action来处理业务逻辑。 C. `<s:checkbox>`, `<s:checkboxlist>`, `<s:combobox>`, `<s:component>`: 这些标签用于创建复选...
Struts2的全局异常处理机制允许开发者定义全局的错误页面或Action,统一处理应用中抛出的异常。这通常通过`<global-exception-mappings>`和`<global-results>`配置实现。 六、插件体系 Struts2拥有丰富的插件系统...
Struts2是一个强大的MVC(模型-视图-控制器)框架,用于构建企业级Java Web应用程序。在Struts2框架中,标签库是其一大特色,它提供了丰富的自定义标签,使得开发者能够更加便捷地创建动态页面。这些标签极大地简化...
6. S2-019:这个漏洞是由于Struts2的常量映射配置错误导致的,攻击者可以利用此漏洞通过HTTP请求执行任意的Java代码。 7. S2-037:这个漏洞与Struts2的StrutsPrepareAndExecuteFilter组件有关,允许攻击者通过OGNL...
8. **错误与异常处理**:Struts2提供了全局和局部两种错误处理方式,可以自定义错误页面,实现友好的错误提示。 9. **表单验证**:Struts2的Validator组件可以对用户输入进行验证,支持JSR303/JSR349 Bean ...
- Struts2中的`<s:iterator>`标签用于迭代集合中的元素。在迭代过程中,可以通过`isEven()`方法来判断当前元素是否处于偶数位置。此方法返回`true`表示当前位置是偶数位置,即第一个元素的位置不是偶数位置,第二个...
Struts2是一个强大的MVC(模型-视图-控制器)框架,被广泛应用于Java Web开发。这个实例项目展示了如何在实际应用中结合Struts2、国际化、类型转换以及Struts2自定义标签来实现用户管理功能,包括用户数据的增删改查...
这个"Struts2精简jar包"集合了Struts2框架的核心组件,使得开发者在集成到自己的项目时可以避免下载和管理大量不必要的依赖。 首先,Struts2的核心jar包主要包括以下几个组件: 1. **struts2-core**: 这是Struts2...
与Struts1不同的是,Struts2中的错误信息管理更加集中化,可以更容易地在多个页面之间共享这些信息。 - **`<s:actionmessage>`**:用于显示Action级别的消息信息,通常用于提示用户操作结果等非错误的信息。 #### ...
总之,`struts2.x jar`的lib文件集合构成了Struts2框架的基石,它们提供了完整的MVC架构、插件系统、依赖管理和各种Web交互能力,使得开发者可以专注于业务逻辑,而不是底层实现细节。理解并熟练掌握这些库的作用,...
- 异常处理:如果标签在处理过程中遇到问题,Struts2会捕获异常并提供友好的错误信息。 掌握Struts2标签API不仅可以提高开发效率,还能确保代码质量。在实际应用中,应结合Struts2的拦截器、结果类型和配置文件一起...
2. **插件**:Struts2支持许多插件,如struts2-convention-plugin.jar、struts2-json-plugin.jar、struts2-dojo-plugin.jar等,分别用于自动发现Action、JSON响应和Dojo前端库的集成。每个插件都包含特定的功能,...
在Java Web开发领域,Struts2 是一个应用广泛的框架,它作为 Apache 基金会下的一个项目,是继 Struts 1 之后的一个全新版本。Struts2 构建在WebWork 的技术基础上,它为开发者提供了一套完备的MVC(Model-View-...
Struts2是一个强大的MVC框架,它为Java开发者提供了丰富的功能来构建动态Web应用程序。在Struts2中,标签库是其一大特色,极大地简化了视图层的开发,使得HTML页面与Java代码的交互更加方便。这篇简介将深入探讨...