1. 程式人生 > >ssh框架遇到的問題總結

ssh框架遇到的問題總結

lease eth end jsp constant word pos don boot

1.org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘dataSource‘ defined in class path resource [applicationContext.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property ‘driverName‘ of bean class [com.mchange.v2.c3p0.ComboPooledDataSource]: Bean property ‘driverName‘ 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 ‘driverName‘ of bean class [com.mchange.v2.c3p0.ComboPooledDataSource]: Bean property ‘driverName‘ is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
錯誤翻譯過來就是:driverClassName 名我 com.mchange.v2.c3p0.ComboPooledDataSource不認得,改個我認識的,不然我罷工
解決:改名
driverClassName -->driverClass
url -->jdbcUrl
username -->user
password—>password

2.Caused by: java.lang.NoClassDefFoundError: javax/transaction/SystemException
解決:確少geronimo-jta jar包

3.Caused by: org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property ‘dataSource‘ threw exception; nested exception is java.lang.NoClassDefFoundError: org/springframework/jdbc/datasource/TransactionAwareDataSourceProxy
解決:<!-- 配置事務 -->
<bean id="transactionManager" class="org.springframework.orm.hibernate5.HibernateTransactionManager">
<property name="dataSource" ref="dataSource"></property>//這裏不要用dataSource.改用sessionFactory
</bean>

4.Caused by: java.lang.ClassNotFoundException: org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy
解決:確少spring-jdbc-4.2.4.RELEASE.jar包

5.HTTP Status 500 - Write operations are not allowed in read-only mode (FlushMode.MANUAL): Turn your Session into FlushMode.COMMIT/AUTO or remove ‘readOnly‘ marker from transaction definition.
嚴重: Exception occurred during processing request: Write operations are not allowed in read-only mode (FlushMode.MANUAL): Turn your Session into FlushMode.COMMIT/AUTO or remove ‘readOnly‘ marker from transaction definition.
org.springframework.dao.InvalidDataAccessApiUsageException: Write operations are not allowed in read-only mode (FlushMode.MANUAL): Turn your Session into FlushMode.COMMIT/AUTO or remove ‘readOnly‘ marker from transaction definition.

解決:在service的類上加上@Transactional註解


6.Bean ‘sessionFactory‘; nested exception is org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Tag ‘property‘ must have a ‘name‘ attribute
Offending resource: class path resource [applicationContext.xml]
Caused by: org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Tag ‘property‘ must have a ‘name‘ attribute
Offending resource: class path resource [applicationContext.xml]

解決:<!-- 配置hibernate映射文件 -->時<property name="">的值忘記寫了

7.Caused by: java.lang.ClassNotFoundException: com.mchange.v2.ser.Indirector”
解決:缺少mchange-commons-java-0.2.3.4.jar

8.java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
解決:缺少mysql驅動jar包

9.Could not load requested class : com.ssh.entity.User
解決:因為pojo裏的文件,xml的文件以及數據庫裏的文件之間的映射有問題

Caused by: org.springframework.aop.framework.AopConfigException: Cannot proxy target class because CGLIB2 is not available. Add CGLIB to the class path or specify proxy interfaces.
解決:可能jar包重復也可能缺少cglib-2.1.3.jar

10.No result defined for action com.ssh.action.UserAction and result success
解決:是Struts.xml配置問題


11.Caused by: org.hibernate.hql.internal.ast.QuerySyntaxException: Emp is not mapped [from Emp]
解決:applicationContext中沒有加載*.hbm.xml映射文件

12.Caused by: org.hibernate.boot.MappingException: Association [com.ssh.entity.Dept.setEmp] references an unmapped entity [com.ssh.entity.Dept.setEmp] : origin(null)

解決:是xxx.hbm.xml中<class name="com.ssh.entity.User" table="user">name中的路徑應該是xxx實體類的路徑,結果寫到其他的實體類的路徑了


13.Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘deptDaoImpl‘ defined in class path resource [applicationContext.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property ‘sessionFactory‘ of bean class [com.ssh.dao.impl.DeptDaoImpl]: Bean property ‘sessionFactory‘ is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
解決:沒有依賴註入

14.嚴重: Servlet.service() for servlet [jsp] threw exception
javax.el.PropertyNotFoundException: Property [id] not found on type [java.lang.String]

解決:jsp中輸出的id與實體類的eid不一致<c:forEach items="list" var="emp">或者是<c:forEach items="list" var="emp">items中應該寫成${list }
<td>${emp.id }</td>

15.Caused by: org.hibernate.MappingException: Duplicate property mapping of ename found in com.ssh.entity.Emp
解決:xxx.hbm.xml映射文件中有重復字段

16.HTTP Status 500 - not-null property references a null or transient value : com.ssh.entity.Emp.esex; nested exception is org.hibernate.PropertyValueException: not-null property references a null or transient value : com.ssh.entity.Emp.esex
解決:是xxx.hbm.xml中的屬性設置為不能為空,但是我前臺表單中的數據填寫為空了。


17.org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unnamed bean definition specifies neither ‘class‘ nor ‘parent‘ nor ‘factory-bean‘ - can‘t generate bean name
Offending resource: class path resource [springmvc.xml]
解決:由於:bean 沒有配置完整,少了class等屬性的配置或者配置了空的bean<bean></bean>


18.java.lang.IllegalArgumentException: Expected MultipartHttpServletRequest: is a MultipartResolver configured?
解決:這是因為找不到multipartReslover的原因,在springMVC配置文件配置它的時候,不能用其他名字,只能用指定名字id="multipartResolver",否則就出現這種找不到的錯誤。

Caused by: 元素類型為 "struts" 的內容必須匹配 "((package|include|bean|constant)*,unknown-handler-stack?)"。 - file:/E:/JavaDeveleper/apache-tomcat-9.0.0.M22/webapps/shop/WEB-INF/classes/struts.xml:17:10
解決:Struts.xml配置文件中的action要寫在package中

19.java.lang.NoSuchMethodException: com.opensymphony.xwork2.ActionSupport.listAll()
解決:spring.xml核心配置文件忘記配置給應類的Javabean實例化

20.Caused by: Action class [userAction] not found - action - file:/C:/Users/smfx1314/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/sshtest/WEB-INF/classes/struts.xml:7:63
java.lang.NoSuchMethodException: com.ssh.action.UserAction.save()

解決:原因是缺少jar包:struts2-spring-plugin-2.1.8.jar或者清理緩存,project

21.There is no Action mapped for namespace [/] and action name [delete] associated with context path [/sshtest]. - [unknown location]
解決:Struts.xml中的action方法使用的是user_*的方式,在jsp頁面中或其他請求中沒有按照user_*的方式請求,加上前綴user就可以了

ssh框架遇到的問題總結