Java編程ssh整合常見錯(cuò)誤解析
1. org.springframework.transaction.CannotCreateTransactionException: Could not open JPA EntityManager for transaction; nested exception is java.lang.UnsupportedOperationException: Not supported by BasicDataSource
Spring不能為JAP創(chuàng)建事務(wù)。原因是bean.xml設(shè)定了數(shù)據(jù)源persistence.xml中要把數(shù)據(jù)庫連接去掉
<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. org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'productServiceBean': Injection of persistence fields failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [beans.xml]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: org.hibernate.MappingException: Could not determine type for: java.util.Set, for columns: [org.hibernate.mapping.Column(childtypes)]
原因:@Id @GeneratedValue(strategy = GenerationType.AUTO)
這個(gè)注解寫在get方法上不要寫在屬性聲明上。
3. javax.persistence.PersistenceException: org.hibernate.exception.DataException: could not insert: [com.yufei.bean.product.ProductType]
Caused by: java.sql.SQLException: Data too long for column 'visible' at row 1
原因:實(shí)體類字段中的visible插入到數(shù)據(jù)庫中所對應(yīng)的值為ASCII碼味49,超出范圍。
換個(gè)mysql的jar包解決問題。
4. web容器出現(xiàn)
嚴(yán)重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
此問題多樣化,查閱資料說是jar包c(diǎn)ommons-logging.jar問題 ,但解決的方式是重新導(dǎo)入項(xiàng)目...
5. org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'productTypeService': Injection of persistence fields failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [beans.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
原因: Spring2.5下asm-2.2.3.jar 與hibernate下的asm.jar 沖突, 刪除asm-2.2.3.jar 。
6. Failed to load or instantiate TagLibraryValidator class: org.apache.taglibs.standard.tlv.JstlCoreTLV
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:88)
org.apache.jasper.compiler.Parser.processIncludeDirective(Parser.java:340)
原因:lib中缺少standard.jar , jstl.jar
7. java.lang.NoSuchFieldError: DIRECTORY
at net.fckeditor.connector.impl.AbstractLocalFileSystemConnector.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.connector.ConnectorServlet.doGet(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
java.io.EOFException
at java.io.ObjectInputStream$PeekInputStream.readFully(ObjectInputStream.java:2281)
at java.io.ObjectInputStream$BlockDataInputStream.readShort(ObjectInputStream.java:2750)
at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:780)
at java.io.ObjectInputStream.<init>(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
org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException
原因:
(1) 是entity bean的 @Id標(biāo)記錯(cuò)了,標(biāo)記在了String 等類型上
(2) 對id字段手工設(shè)定了值。
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
exception is java.lang.NullPointerException
原因:項(xiàng)目使用了<context:component-scan/>掃描機(jī)制, 而類BrandAction沒有標(biāo)注為原型,
為類添加 @Scope("prototype")標(biāo)注(與@Controller相同位置)
11 org.hibernate.tool.hbm2ddl.SchemaUpdate(line:222) - could not complete schema update
java.lang.UnsupportedOperationException: Not supported by BasicDataSource
原因 spring.xml 與 persistence.xml中都配置了數(shù)據(jù)庫連接,注釋掉persistence.xml中的連接信息
12 org.apache.struts2.dispatcher.Dispatcher(line:27) - Dispatcher initialization failed
Unable to load configuration. - [unknown location]
Cannot locate the chosen ObjectFactory implementation: spring - [unknown location]
原因 struts.xml中使用了<constant name="struts.objectFactory" value="spring"/>,將其注釋掉
總結(jié)
以上就是本文關(guān)于Java編程ssh整合常見錯(cuò)誤解析的全部內(nèi)容,希望能對大家有所幫助。如有不足之處,歡迎留言指出,小編會(huì)及時(shí)更正。感興趣的朋友可以參閱:Kryo框架使用方法代碼示例、Java集合框架源碼分析之LinkedHashMap詳解、淺談Zookeeper開源客戶端框架Curator等以及本站其他相關(guān)專題,感謝大家對本站的支持!
- 詳解Java使用Jsch與sftp服務(wù)器實(shí)現(xiàn)ssh免密登錄
- 詳解JAVAEE——SSH三大框架整合(spring+struts2+hibernate)
- java通過ssh連接服務(wù)器執(zhí)行shell命令詳解及實(shí)例
- java-SSH2實(shí)現(xiàn)數(shù)據(jù)庫和界面的分頁
- Java框架SSH結(jié)合Easyui控件實(shí)現(xiàn)省市縣三級聯(lián)動(dòng)示例解析
- SSH框架網(wǎng)上商城項(xiàng)目第25戰(zhàn)之使用java email給用戶發(fā)送郵件
- Java實(shí)現(xiàn)SSH模式加密
- Java的web開發(fā)中SSH框架的協(xié)作處理應(yīng)用筆記
- 基于Java實(shí)現(xiàn)ssh命令登錄主機(jī)執(zhí)行shell命令過程解析
相關(guān)文章
淺談Spring AOP中args()和argNames的含義
這篇文章主要介紹了Spring AOP中args()和argNames的含義,具有很好的參考價(jià)值,希望對大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2021-07-07Java8中Stream?API的peek()方法詳解及需要注意的坑
這篇文章主要給大家介紹了關(guān)于Java8中Stream?API的peek()方法詳解及需要注意的坑,Java 中的 peek 方法是 Java 8 中的 Stream API 中的一個(gè)方法,它屬于中間操作,文中通過代碼介紹的非常詳細(xì),需要的朋友可以參考下2024-06-06Java switch 語句如何使用 String 參數(shù)
這篇文章主要介紹了Java switch 語句如何使用 String 參數(shù),文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,,需要的朋友可以參考下2019-06-06JAVA實(shí)現(xiàn)較完善的布隆過濾器的示例代碼
這篇文章主要介紹了JAVA實(shí)現(xiàn)較完善的布隆過濾器的示例代碼,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2018-10-10springboot項(xiàng)目整合mybatis并配置mybatis中間件的實(shí)現(xiàn)
這篇文章主要介紹了springboot項(xiàng)目整合mybatis并配置mybatis中間件的實(shí)現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2021-04-04SpringBoot實(shí)現(xiàn)定時(shí)發(fā)送郵件的三種方法案例詳解
這篇文章主要介紹了SpringBoot三種方法實(shí)現(xiàn)定時(shí)發(fā)送郵件的案例,Spring框架的定時(shí)任務(wù)調(diào)度功能支持配置和注解兩種方式Spring?Boot在Spring框架的基礎(chǔ)上實(shí)現(xiàn)了繼承,并對其中基于注解方式的定時(shí)任務(wù)實(shí)現(xiàn)了非常好的支持,本文給大家詳細(xì)講解,需要的朋友可以參考下2023-03-03Spring Boot 中常用的注解@RequestParam及基本用法
@RequestParam 是 Spring Framework 和 Spring Boot 中常用的注解之一,用于從請求中獲取參數(shù)值,本文給大家介紹Spring Boot 中常用的注解@RequestParam,感興趣的朋友一起看看吧2023-10-10