這篇文章主要介紹了Java程式設計ssh整合常見錯誤解析,如果有什麼不足之處,歡迎留言補充。
1. org.springframework.transaction.CannotCreateTransactionException: Could not open JPA EntityManager for transaction; nested exception is java.lang.UnsupportedOperationException: Not ported by#supSourceported by#supSource.
##Spring不能為JAP建立交易。原因是bean.xml設定了資料來源persistence.xml中要把資料庫連線去掉
<property name="hibernate.connection.username" value="xxx"/> <property name="hibernate.connection.password" value="xxx"/> <property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/xxx? useUnicode=true&characterEncoding=UTF-8"/>
#2.
原因:@Id @GeneratedValue(strategy = GenerationType.AUTO)
這個註解寫在get方法上不要寫在屬性聲明上。
3.
Caused by: java.sql.SQLException: Data too long for column 'visible' at row 1
原因:實體類別欄位中的visible插入到資料庫中所對應的值為ASCII碼味49,超出範圍。
換個mysql的jar包解決問題。
4.
#Fall: Exception sending context initialized event to listener instance of class org.springframework.web. context.ContextLoaderListener java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
此問題多樣化,查閱資料說是jar包commons-logging.jar問題,但解決的方式是重新匯入專案...
5.
#原因: Spring2.5下asm-2.2.3.jar 與hibernate下的asm.jar 衝突, 刪除asm-2.2.3.jar 。
6.
org.apache.jasper.compiler. DefaultErrorHandler.jspError(DefaultErrorHandler.java:40)org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)org.apache.crr.compiler 88)
org.apache.jasper.compiler.Parser.processIncludeDirective(Parser.java:340)
原因:lib中缺少standard.jar , jstl.jar
#7.
at net.fckeditor.connector.impl.AbstractLocalFileSystemConnector.getFolders(AbstractLocalFileSystemConnector.javaLocalFileSystemConnector.getFolders(AbstractLocalFileSystemConnector.javaLocalFileSystemConnector.getFolders(AbstractLocalFileSystemConnector.java:140)##at net.fckeditor.connector.Dispatcher.getFoldersAndOrFiles(Dispatcher.java:204)at net.fckeditor.connector.Dispatcher.doGet(Dispatcher.java:156)at net.fckeditor.conn。 ConnectorServlet.java:89)
#原因:套件衝突,刪除struts1.3自帶的commons-io-1.1.jar,commons-fileupload-1.1.1.jar,加入commons-io-1.3.2.jar,commons-fileupload-1.2.1.jar
8.
IOException while loading persisted sessions: java.io.EOFException
at java.io.ObjectInputStream$PeekInputStream.readFully(ObjectInputStream.java:2281)at java.io.ObjectInputStream$BlockDataInputStream.readShort(ObjectInputStream.java:2750)##2750)at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:780)
at java.io.ObjectInputStream.7e51f00a783d7eb8f68358439dee7daf(ObjectInputStream.java:280)
#原因是tomcat對硬碟的session讀取失敗,徹底解決方法一下:將work下面的文件清空,主要是*.ser文件,或只是刪除掉session.ser即可以解決。
9.javax.persistence.PersistenceException: org.hibernate.PersistentObjectException: detached entity passed to persist: com.dalton.domain.User
原因:
(1) 是entity bean的 @Id標記錯了,標記在了String 等型別上
(2) 對id欄位手工設定了值。
10 org.springframework.web.context.ContextLoader(line:215) - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with
name 'brand' defined in file [D:\Tomcat6\webapps\autoet\WEB-INF\classes\com\autoet\
action\brand\BrandAction.class]: Instantiation of bean failed ; nested exception is
org.springframework.beans.BeanInstantiationException: Could not instantiate bean
class [com.autoet.action.brand.BrandAction]: Constructor threw exception; nested#fexception orception.
原因:專案使用了4c768a35efd9b5c69daed3835397d811掃描機制, 而類別BrandAction沒有標註為原型,為類別添加@Scope("prototype" )標註(與@Controller相同位置)
11 org.hibernate.tool.hbm2ddl.SchemaUpdate(line:222) - could not complete schema updatejava.lang.UnsupportedOperationException: Not supported by BasicDataSource
#原因spring.xml 與persistence.xml中都配置了資料庫連線,註解掉persistence.xml中的連線資訊
12 org.apache.struts2.dispatcher.Dispatcher(line:27) - Dispatcher initialization failedUnable to load configuration. - [unknown location]
Cannot locate the chosen ObjectFactory implementation: spring - [unknown location]
總結#
以上是Java之ssh整合常見錯誤的解決的詳細內容。更多資訊請關注PHP中文網其他相關文章!