论坛首页 入门技术论坛

ssh错误总结

浏览 4324 次
锁定老帖子 主题:ssh错误总结
该帖已经被评为新手帖
作者 正文
   发表时间:2010-02-25   最后修改:2010-02-25

 

SSH 错误总结

Struts1.x

1 javax.servlet.ServletException: Must specify type attribute if name is specified

你看看你的 jsp 页面中标签中是否定义了 name 属性,如果定义了,那么 type 属性一定要定义 . 一般删除就可以了 ,name 属性值就是你 struts-config.xml 中定义的 action name 的值 .

    2 No bean found under attribute key XXX”

struts-config.xml 里定义了一个 ActionForm ,但 type 属性指定的类不存在, type 属性的值应该是 Form 类的全名。或者是,在 Action 的定义中, name attribute 属性指定的 ActionForm 不存在。

    3 “Cannot find bean XXX in any scope”

Action 里一般会 request.setAttribute() 一些对象,然后在转向的 jsp 文件里(用 tag request.getAttribute() 方法)得到这些对象并显示出来。这个异常是说 jsp 要得到一个对象,但前面的 Action 里并没有将对象设置到 request (也可以是 session servletContext )里。可能是名字错了,请检查 jsp 里的 tag 的一般是 name 属性,或 getAttribute() 方法的参数值;或者是 Action 逻辑有问题没有执行 setAttribute() 方法就先转向了。还有另外一个可能,纯粹是 jsp 文件的问题,例如会指定一个 id 值,然后在循环里使用这个值作为 name 的值,如果这两个值不同,也会出现此异常。(都是一个道理, request 里没有对应的对象。)
   4
Missing message for key "XXX"”
缺少所需的资源,检查 ApplicationResources.properties 文件里是否有 jsp 文件里需要的资源,例如:这行代码会找 msg.name.prompt 资源,如果 AppliationResources.properties 里没有这个资源就会出现本异常。在使用多模块时,要注意在模块的 struts-config-xxx.xml 里指定要使用的资源文件名称,否则当然什么资源也找不到,这也是一个很容易犯的错误。

   5 “No getter method for property XXX of bean teacher”
这条异常信息说得很明白, jsp 里要取一个 bean 的属性出来,但这个 bean 并没有这个属性。你应该检查 jsp 中某个标签的 property 属性的值。例如下面代码中的 cade 应该改为 code 才对
   6
Cannot find ActionMappings or ActionFormBeans collection”
待解决。

   7 Cannot retrieve mapping for action XXX”
.jsp 的标签里指定 action='/XXX' ,但这个 Action 并未在 struts-config.xml 里设置过。

   8 HTTP Status 404 - /xxx/xxx.jsp
Forward
path 属性指向的 jsp 页面不存在,请检查路径和模块,对于同一模块中的 Action 转向, path 中不应包含模块名;模块间转向,记住使用 contextRelative="true"

   9 没有任何异常信息,显示空白页面
可能是 Action 里使用的 forward struts-config.xml 里定义的 forward 名称不匹配。
   10
“The element type "XXX" must be terminated by the matching end-tag "XXX".”
这个是 struts-config.xml 文件的格式错误,仔细检查它是否是良构的 xml 文件,关于 xml 文件的格式这里就不赘述了。

   11 “Servlet.init() for servlet action threw exception”
一般出现这种异常在后面会显示一个关于 ActionServlet 的异常堆栈信息,其中指出了异常具体出现在代码的哪一行。我曾经遇到的一次提示如下:

java.lang.NullPointerException
    at org.apache.struts.action.ActionServlet.parseModuleConfigFile(ActionServlet.java:1003)
    at org.apache.struts.action.ActionServlet.initModuleConfig(ActionServlet.java:955)
为解决问题,先下载 struts 的源码包,然后在 ActionServlet.java 的第 1003 行插入断点,并对各变量进行监视。很丢人,我竟然把 struts-config.xml 文件弄丢了,因此出现了上面的异常,应该是和 CVS 同步时不小心删除的。

    12 Resources not defined for Validator”
这个是利用 Validator 插件做验证时可能出现的异常,这时你要检查 validation.xml 文件,看里面使用的资源是否确实有定义, form 的名称是否正确,等等。
    13
、切记当有列在数据库中用的是 text 类型 的,所以从数据库中取内容时必须要一项项按顺序取,很个性

    14 <SELECT&NBSP; property="applyType" #ff0000?="" onchange="javascript:document.

当控件没有 name 属性,但是有 property 属性时,在 javascript 中, <SELECT&NBSP; color="#ff0000" property="applyType" >

var selectedType = eval('document.forms[0].applyType .options[' + document.forms[0].applyType.selectedIndex + '].value') ;

可以使用 property 名???

    15. 请选择申请类型
      
社团申请
       
奖学金申请
       
助学金申请

      下拉框显示从数据库中取出的值所对应的类型

     16 、从链接中取得参数的方法: String strMsgId = request.getParameter("id") ;

     17 The requested resource (/qlsc/) is not available. 
这是因为 clean 了以后没有再 build

     18 、若是 .xml 配置没有问题,则在页面上可打开,是一棵树的样子

     19 、在出现两个相同的 .do 时,程序会不知道应该安那个进行处理,会出现空白页面!

     20 mssqlserver.jar   msbase.jar   msutil.jar  拷到 common/lib 下,会少很多错
form.getXXX()
方法不能连续用好多次(对一个属性而言),会出错    很个性

     21.

       请选择班级:

select property="classId" ,总是报告 No getter method available for property className for bean under name org.apache.struts.taglib.html.BEAN
,原因应该是在该 jsp 对应的 form 中没有相应的属性以及 set get 方法。

    22 、即使端口坏了,但用到数据库时还要插上网线,原因是在 tomcat/conf/server.xml  使用的是 ip ,改为 localhost ,并将 DAO.java ip 也改为 localhost 就不存在该问题了。

    23 enctype="multipart/form-data"  用在界面中好像是用于附件   没有的话不用,会出现 outofmemoryerror 错误

    24 No selector attribute (cookie/header/name/parameter) was specified 原因是 <logic:match value=" 程序补充 " property="type" name="question">
                <html:textarea property="complement" cols="20" rows="5"/>
              </logic:match>
中,忘记了 name 属性

org.hibernate.id.IdentifierGenerationException: ids for this class must be manually assigned before calling save():
原因: <id> 元素配置不正确, <id> 元素缺少其子元 <generator></generator> 的配置。解决方法: <id> 元素映射了相应数据库表的主键字段, 对其子元素 <generator class="">, 其中 class 的取值可以为 increment identity sequence hilo native...... 等,一般取其值为 native
2.
java.lang.IllegalArgumentException: id to load is required for loading
方案 :Users user=(Users)this.getHibernateTemplate().get(Users.class, id); 如果以用户名为参数不能用此方法
3.
org.springframework.dao.InvalidDataAccessResourceUsageException: could not execute query; nested exception is org.hibernate.exception.SQLGrammarException: could not execute query
方案: sql 语句有错误
4.
严重 : Error starting static Resources
java.lang.IllegalArgumentException: Document base D:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps\tomcat-docs does not exist or is not a readable directory
严重 : Error in resourceStart()
2007-6-6 23:32:25 org.apache.catalina.core.StandardContext start
严重 : Error getConfigured
2007-6-6 23:32:25 org.apache.catalina.core.StandardContext start
严重 : Context startup failed due to previous errors
2007-6-6 23:32:25 org.apache.catalina.core.StandardContext start
严重 : Exception during cleanup after start failed
LifecycleException: Container StandardContext[/tomcat-docs] has not been started
5.jsf+spring+hibernate
严重 : 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 'dataSource' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Instantiation of bean failed; nested exception is java.lang.NoClassDefFoundError: org/apache/commons/pool/impl/GenericObjectPool
Caused by: java.lang.NoClassDefFoundError: org/apache/commons/pool/impl/GenericObjectPool
严重 : Error listenerStart
2007-6-8 10:31:55 org.apache.catalina.core.StandardContext start
严重 : Context [/shj01] startup failed due to previous errors
2007-6-8 10:31:55 org.apache.catalina.core.ApplicationContext log
方案: spring-framework-2.0.5\lib\jakarta-commons 下的 commons-collections.jar commons-dbcp.jar   commons-pool.jar 加载到工程去
6.
严重 : Exception sending context initialized event to listener instance of class com.sun.faces.config.ConfigureListener
javax.faces.FacesException: Can't parse configuration file:jar:file:/E:/
工具 /apache-tomcat-6.0.9/apache-tomcat-6.0.9/webapps /jsf02/WEB-INF/lib/jsf-impl.jar!/com/sun/faces/standard-html-renderkit.xml
方案:把 tomcat 的安装文件换了位置就没事了
7.spring MVC+hibernate
严重 : StandardWrapper.Throwable
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.NoSuchMethodError: org.objectweb.asm.ClassVisitor.visit(IILjava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;)V
Caused by: java.lang.NoSuchMethodError: org.objectweb.asm.ClassVisitor.visit(IILjava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;)V
方案:
在使用 Spring AOP 编程时,会用到这几个 lib
asm-2.2.2.jar
asm-commons-2.2.2.jar
asm-util-2.2.2.jar
Hibernate
使用如果 lib
asm.jar
asm-attrs.jar
其中 asm-2.2.2.jar asm.jar 存在类上的冲突!!!
使用其中之一或两者都使用,可能会出现如下错误:
java.lang.NoClassDefFoundError: org/objectweb/asm/CodeVisitor
java.lang.NoClassDefFoundError: org/objectweb/asm/commons/EmptyVisitor
java.lang.NoSuchMethodError: org.objectweb.asm.ClassVisitor.visit
。。。。。。
解决办法是:
1.
去掉类路径上的关于 Hibernate 3 lib
asm.jar
asm-attrs.jar
cglib-2.1.3.jar
2.
加入 Spring 中的以下 4 lib
asm-2.2.2.jar
asm-commons-2.2.2.jar
asm-util-2.2.2.jar
cglib-nodep-2.1_3.jar
8.spring MVC+hibernate
Exception in thread "main" org.springframework.dao.InvalidDataAccessResourceUsageException: Could not execute JDBC batch update; nested exception is org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update
Caused by: org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update
9.
org.springframework.beans.factory.CannotLoadBeanClassException: Error loading class [org.springframework.transaction.interceptor.TransactionProxyFactoryBean] for bean with name 'userService' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: problem with class file or dependent class; nested exception is java.lang.NoClassDefFoundError: org/springframework/aop/framework/AbstractSingletonProxyFactoryBean
Caused by: java.lang.NoClassDefFoundError: org/springframework/aop/framework/AbstractSingletonProxyFactoryBean
方案:没加 spring 2.0 aop libraries
10.
org.apache.jasper.JasperException: Unable to compile class for JSP:
方案: jsp 网页中的 java 代码有问题
11.
Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'CompanyController' defined in class path resource [com/company/test/company-config.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'methodNameResolver' of bean class [com.company.action.CompanyController]: Bean property 'methodNameResolver' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property 'methodNameResolver' of bean class [com.company.action.CompanyController]: Bean property 'methodNameResolver' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?


控制器没继承 MultiActionController

12.
Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'turDiffService' defined in class path resource [com/expert/test/expert-config.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'turDifficultDao' of bean class [com.expert.operation.impl.TurDiffSerImpl]: Bean property 'turDifficultDao' is not writable or has an invalid setter method. Did you mean 'truDifficultDao'?
Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property 'turDifficultDao' of bean class [com.expert.operation.impl.TurDiffSerImpl]: Bean property 'turDifficultDao' is not writable or has an invalid setter method. Did you mean 'truDifficultDao'?
原因:
在定义时 TurDifficultDao turDifficultDao ,把有个字母写错,后发现错误,改过来了,但没把 get() set() 方法中对应的改过来

13.

Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'urlMapping' defined in class path resource [com/expert/test/expert-config.xml]: Initialization of bean failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named '' is defined
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named '' is defined


原因:
expert-config.xml 中创建
<bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="mappings">
   <props>
   
    <prop key=""></prop>
   
    </props>
</property>
</bean>
没有给 <prop key=""></prop> 赋值

14.

org.springframework.orm.hibernate3.HibernateQueryException: Instruction is not mapped

[from Instruction]; nested exception is org.hibernate.hql.ast.QuerySyntaxException:

Instruction is not mapped [from Instruction]
Caused by: org.hibernate.hql.ast.QuerySyntaxException: Instruction is not mapped [from

Instruction]
原因:在 data-config.xml 中没加入 <value>com/serializ/Instruction.hbm.xml</value>
15.

java.sql.SQLException: Field 'userId' doesn't have a default value
原因:把配置文件的主键改为 <generator class="assigned" /> 可以进行自定义主键值,因为我在设主键时没有设成自动增长的,要求填默认值是受了配置文件里 <generator class="native"/> 的影响了。

16.org.apache.jasper.JasperException: Unable to compile class for JSP

原因: jsp 页面中的 java 代码括号不对称!

论坛首页 入门技术版

跳转论坛:
Global site tag (gtag.js) - Google Analytics