首页 > 代码库 > javaweb报错总结
javaweb报错总结
1、
org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘sqlMapClient‘ defined in class path resource
[dao/spring-config-dao.xml]: Invocation of init method failed; nested exception is java.io.FileNotFoundException:
class path resource [Sqlmap-config.xml] cannot be opened because it does not exist
解决方法:加入从spring-config.xml进入配置文件,那么其他配置文件的classpath是spring-config所在的路径。
2、
org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘sqlMap‘ defined in class path resource
[dao/spring-config-dao.xml]: Invocation of init method failed; nested exception is org.springframework.core.NestedIOException:
Failed to parse config resource: class path resource [dao/Sqlmap-config.xml]; nested exception is com.ibatis.common.xml.NodeletException:
Error parsing XML. Cause: java.lang.RuntimeException: Error parsing XPath ‘/sqlMapConfig/sqlMap‘.
Cause: com.ibatis.common.xml.NodeletException: Error parsing XML. Cause: org.xml.sax.SAXParseException:
The processing instruction target matching "[xX][mM][lL]" is not allowed.
这个异常解释为:xml文件不能被解析,一般出现这样的问题在于xml格式上,并且问题多出现在xml文件的头部。我就是出现了这个问题。昨天还可以正常运行的,今天来了就运行不了了,很奇怪,查看了下错误信息,找到了原因。这是因为我的xml文件头部有两行空行,第三行才开始写
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" "http://struts.apache.org/dtds/struts-config_1_2.dtd">
的。
总结:<?xml version="1.0" encoding="UTF-8"?>前面不要有任何其他字符,如空格、回车、换行这些否则就会出现上面的异常。
3、
org.springframework.jdbc.BadSqlGrammarException: SqlMapClient operation; bad SQL grammar []; nested exception is com.ibatis.common.jdbc.exception.NestedSQLException:
--- The error occurred while applying a parameter map.
--- Check the user.match-InlineParameterMap.
--- Check the statement (query failed).
--- Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘from user WHERE username = ‘llx‘ AND password = ‘llx‘‘ at line 1
数据库sql语法错误,修改sql语句
<sql id="Column_List_user">
id,
username,
password,
sex,
age,
isDelete,------》最后一个column多了一个逗号,汗,去掉逗号就ok了。
</sql>
4、。
java.lang.ClassCastException: java.lang.Integer cannot be cast to cm.llx.module.pojo.User
类型转换异常。可能ibatis中resultClass错误。
5、
org.springframework.web.servlet.PageNotFound [http-apr-8080-exec-9] - No mapping found for HTTP request with URI [/bookborrow/lwb/user/userlist.do] in DispatcherServlet with name ‘dispatcher‘
需要在servlet配置文件中加入组件扫描,扫描controller。
6、
org.springframework.web.servlet.DispatcherServlet [localhost-startStop-1] - Context initialization failed
Servlet配置文件有问题。
7.
Duplicate entry ‘1‘ for key 1
主键自增,但插入时却有id插入
http://xiao1227372602.iteye.com/blog/1684089
汗,在insert中不要id就行了。
- 。。
INFO 14-04-04 10:16 - org.springframework.web.context.support.XmlWebApplicationContext [localhost-startStop-1] - Refreshing Root WebApplicationContext: startup date [Fri Apr 04 10:16:39 CST 2014]; root of context hierarchy
INFO 14-04-04 10:16 - org.springframework.beans.factory.xml.XmlBeanDefinitionReader [localhost-startStop-1] - Loading XML bean definitions from ServletContext resource [/WEB-INF/classes/ctx-work-web.xml]
Could not open ServletContext resource [/WEB-INF/classes/ctx-work-web.xml]
Context initialization failed
项目开始可以运行,项目clean后,就不能运行了。Spring加载失败。 不能加载web.xml文件。原因: web.xml被clean掉了。
解决方法:svn更新。Clean下项目。
- Data too long for column ‘class_hour_fee‘ at row 1
数据库编码问题,插入数据有中文,将数据库和表改成utf-8即可。
ALTER TABLE `test` DEFAULT CHARACTER SET utf8 COLLATE utf8_bin
或者字段真的太短了,改成text就可以了
- nested exception is org.springframework.web.multipart.MaxUploadSizeExceededException: Maximum upload size of 100000 bytes exceeded; nested exception is org.apache.commons.fileupload.FileUploadBase$SizeLimitExceededException: the request was rejected because its size (237254) exceeds the configured maximum (100000)] with root cause
上次文件大小大于设置的大小,设置在dispatch-servlet
<!-- 这里申明的id必须为multipartResolver -->
<bean id="multipartResolver"
class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<!-- one of the properties available; the maximum file size in bytes -->
<property name="maxUploadSize" value="http://www.mamicode.com/10000000" />
</bean>
- Servlet.service() for servlet jsp threw exception
可能有个 标签括号掉了
12、An error occurred at line: 17 in the jsp file: /WEB-INF/page/outsch/class/add.jsp
path cannot be resolved to a variable
<form class="form-horizontal" role="form" action="<%=path%>/outsch/class/add.html" method="post">
错误原因,使用了<%=path%> ,但未加入
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://"
+ request.getServerName() + ":" + request.getServerPort()
+ path + "/";
%>
- javax.el.PropertyNotFoundException: Property ‘account‘ not found on type java.lang.String
解决办法
- <c:forEach items="productTypes" var="type">
- ${type.typeid } ${type.name } ${type.note } <c:if test="${!empty type.parent }">${type.parent.name }</c:if>
- </c:forEach>
将items="productTypes"修改为
[html] view plaincopyprint?
- items="${productTypes }"解决问题。
- There is no statement named oa_institution.insertEntry in this SqlMap.
解决方法:1.你的sqlmap 文件中确实没有xxx这个statement ,很有可能某个字母写错了
2.sqlmap文件定义了namespace属性,此时在本文件中引用别的statement,就需要这样写:(你的namespace).(定义的statement 的id),如果把namespace属性漏了,就被报此异常
也可能没建立映射关系 在 sqlmap_config.xml 配置文件中
<sqlMap resource="dao/sqlmap/oa_term_class.xml" />
<sqlMap resource="dao/sqlmap/oa_term.xml" />
<sqlMap resource="dao/sqlmap/oa_institution.xml" />
<sqlMap resource="dao/sqlmap/oa_finance.xml" />
- Duplicate <sql>-include ‘oa_finance.Column_List‘ found
Sqlmap_config.xml配置文件中有重复,或者xxx.xml中有重复
16、Description Resource Path Location Type Java compiler level does not match the version of the instal
分类: eclipse2013-03-21 09:30 8102人阅读 评论(5) 收藏 举报
解决办法
在项目上右键Properties-》Project Facets,在打开的Project Facets页面中的Java下拉列表中,选择相应版本。
有可能是java1.6 改成java6之类的
17
The constructor BASE64Decoder() is not accessible due to restriction on required library
分类: Java2013-06-15 10:39 1124人阅读 评论(2) 收藏 举报
搭建G4Studio的开发环境出现这个错误:
Description Resource Path Location Type Access restriction: The constructor BASE64Decoder() is not accessible due to restriction on required library D:\java\Tomcat6\jdk\jre\lib\rt.jar G4Utils.java /G4Studio/JavaCode/org/g4studio/core/util line 805 Java Problem
百度找到答案,只需要在project build path中先移除JRE System Library,再添加库JRE System Library,重新编译后就一切正常了
18、Page directive: illegal to have multiple occurrences of contentType with different values (old: text/html; charset=utf-8,new: text/html;charset=utf-8)
原来是包含页面与被包含页面的@page指令里面的contentType不一致,仔细检查两个文件第一行的 @page,
包含页面的是: <%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
被包含页面: <%@ page language="java" contentType="text/html;charset=utf-8" pageEncoding="utf-8"%>
解决方法:果然contentType="text/html;和charset=utf-8"之间多了一个空格,把两个文件第一行的@page内容改为一致,再执行程序,运行通过。
19.java.lang.UnsupportedOperationException
引起异常代码:
1.String[] strs = new String[]{"a","b"};
2. List<String> strList = Arrays.asList(strs);
3. strList.add("c");
在第三行抛出的异常
经分析java源代码Arrys.asList();方法返回的不是平常熟悉的java.util.ArrayList类的对象。而是Arrays类的内部类的对象,而Arrays类里的内部类ArrayList没有实现AbstractList类的add方法,导致抛此异常! strList.add("c");这行代码调用的add方法实际上是这样的:
public boolean add(E e) {
add(size(), e);
return true;
}
public void add(int index, E element) {
throw new UnsupportedOperationException();
}
解决方法:
String[] strs = new String[]{"a","b"};
List<String> strList = new ArrayList<String>(Arrays.asList(strs));
strList.add("c");
javaweb报错总结