Question: The cause and solution for the exception of org. springframework. Beans. Factory. beancreationexception.
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
At java. Lang. Class. getdeclaredconstructors0 (native method)
At java. Lang. Class. privategetdeclaredconstructors (unknown source)
At java. Lang. Class. getconstructor0 (unknown source)
At java. Lang. Class. getdeclaredconstructor (unknown source)
At org. springframework. Beans. Factory. Support. simpleinstantiationstrategy. instantiate
(Simpleinstantiationstrategy. Java: 54)
At org. springframework. Beans. Factory. Support. abstractautowirecapablebeanfactory. instantiatebean
(Abstractautowirecapablebeanfactory. Java: 752)
At org. springframework. Beans. Factory. Support. abstractautowirecapablebeanfactory. createbeaninstance
(Abstractautowirecapablebeanfactory. Java: 717)
At org. springframework. Beans. Factory. Support. abstractautowirecapablebeanfactory. createbean
(Abstractautowirecapablebeanfactory. Java: 386)
At org. springframework. Beans. Factory. Support. abstractbeanfactory $1. GetObject (abstractbeanfactory. Java: 249)
At org. springframework. Beans. Factory. Support. defaultsingletonbeanregistry. getsingleton
(Defaultsingletonbeanregistry. Java: 155)
At org. springframework. Beans. Factory. Support. abstractbeanfactory. getbean (abstractbeanfactory. Java: 246)
At org. springframework. Beans. Factory. Support. abstractbeanfactory. getbean (abstractbeanfactory. Java: 160)
At org. springframework. Beans. Factory. Support. defaultlistablebeanfactory. preinstantiatesingletons
(Defaultlistablebeanfactory. Java: 291)
At org. springframework. Context. Support. abstractapplicationcontext. Refresh (abstractapplicationcontext. Java: 352)
At org. springframework. Web. Context. contextloader. createwebapplicationcontext (contextloader. Java: 245)
At org. springframework. Web. Context. contextloader. initwebapplicationcontext (contextloader. Java: 188)
At org. springframework. Web. Context. contextloaderlistener. contextinitialized (contextloaderlistener. Java: 49)
At org. Apache. Catalina. Core. standardcontext. listenerstart (standardcontext. Java: 3934)
At org. Apache. Catalina. Core. standardcontext. Start (standardcontext. Java: 4429)
At org. Apache. Catalina. Core. containerbase. addchildinternal (containerbase. Java: 791)
At org. Apache. Catalina. Core. containerbase. addchild (containerbase. Java: 771)
At org. Apache. Catalina. Core. standardhost. addchild (standardhost. Java: 526)
At org. Apache. Catalina. startup. hostconfig. deploydirectory (hostconfig. Java: 987)
At org. Apache. Catalina. startup. hostconfig. deploydirectories (hostconfig. Java: 909)
At org. Apache. Catalina. startup. hostconfig. deployapps (hostconfig. Java: 495)
At org. Apache. Catalina. startup. hostconfig. Start (hostconfig. Java: 1206)
At org. Apache. Catalina. startup. hostconfig. lifecycleevent (hostconfig. Java: 314)
At org. Apache. Catalina. util. lifecyclesupport. firelifecycleevent (lifecyclesupport. Java: 119)
At org. Apache. Catalina. Core. containerbase. Start (containerbase. Java: 1053)
At org. Apache. Catalina. Core. standardhost. Start (standardhost. Java: 722)
At org. Apache. Catalina. Core. containerbase. Start (containerbase. Java: 1045)
At org. Apache. Catalina. Core. standardengine. Start (standardengine. Java: 443)
At org. Apache. Catalina. Core. standardservice. Start (standardservice. Java: 516)
At org. Apache. Catalina. Core. standardserver. Start (standardserver. Java: 710)
At org. Apache. Catalina. startup. Catalina. Start (Catalina. Java: 583)
At sun. Reflect. nativemethodaccessorimpl. invoke0 (native method)
At sun. Reflect. nativemethodaccessorimpl. Invoke (unknown source)
At sun. Reflect. delegatingmethodaccessorimpl. Invoke (unknown source)
At java. Lang. Reflect. method. Invoke (unknown source)
At org. Apache. Catalina. startup. Bootstrap. Start (Bootstrap. Java: 288)
At org. Apache. Catalina. startup. Bootstrap. Main (Bootstrap. Java: 413)
16:14:57 org. Apache. Catalina. Core. standa Ah ror listenerstart
Cause of the exception:
This is because package conflicts occur when the spring framework and Hibernate framework are integrated. This bug is generated when myeclipse6.0 is used.
Jar files are: ASM. Jar conflicts with the asm-2.2.3.jar.
Solution: the video says to delete the asm-2.2.3.jar can run normally!
However, after I delete my machine, I still report the following error: 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
Later, I went to my lib directory and deleted many. Jar files with similar names (five or six. Jar files can be deleted), but I still reported the error, which is exciting!
Next, I went to watch the video and looked for clues. I suddenly found that myeclipse6.1 was used. hibernate only supported 3.1, while myeclipse6.5 was used in the video.
Hibernate3.2, So I downloaded myeclipse6.5 online. After the installation, I created a new project and copied all the files of the previous project (because the. Jar files are different
The previous project cannot be used directly.) after the project is deployed, it is indeed a full range of features in the higher version, and the errors reported are more targeted!
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. Io. filenotfoundexception: Class path resource [COM. oristand. Bean. User. HBM. xml] cannot be opened because it does not
Exist
Caused by: Java. Io. filenotfoundexception: Class path resource [COM. oristand. Bean. User. HBM. xml] cannot be opened because it
Does not exist
Analysis Error:
<Property name = "mappingresources">
<List>
<Value> com. oristand. Bean. User. HBM. xml </value>
</List>
</Property>
Changed:
<Property name = "mappingresources">
<List>
<Value> COM/oristand/bean/user. HBM. xml </value>
</List>
</Property>
Re-deployment and run: the following error occurs again, which is even more exciting:
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;) V
Caused by: Java. Lang. nosuchmethoderror: org. objectweb. ASM. classvisitor. Visit (iiljava/lang/string; ljava/lang/string;
[Ljava/lang/string;) V
At this time, delete the corresponding asm-2.2.3.jar, re-deploy and run,
Success !!!!!!!!!!!!!!!!!!!!!!