Spring Study Notes (5) use the Hibernate Persistence Layer-2 Problem and Solution Summary

Source: Internet
Author: User

Symptom 1:
Org. springframework. beans. factory. beancreationexception: Error creating bean with name 'org. springframework. AOP. support. defapointpointcutadvisor 'defined in NULL: can't resolve reference to bean 'txadvice 'while setting property 'advice'; Nested exception is

Cause: the various packages starting with spring are missing. Compile the new Dist directory in spring SRC and copy all springxxx. jar to jpetstore/WEB-INF/lib. OK.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~

Symptom 2:
Org. springframework. beans. factory. beancreationexception: Error creating bean with name 'sessionfactory 'defined in resource [/WEB-INF/dataAccessContext-hibernate.xml] of servletcontext: instantiation of bean failed; Nested exception is Java. lang. noclassdeffounderror: javax/transaction/transactionmanager
Java. Lang. noclassdeffounderror: javax/transaction/transactionmanager

Cause: JTA. jar is missing, OK

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~

Symptom 3:

Java. Lang. noclassdeffounderror: ORG/dom4j/attribute
Dom4j. jar is missing.
Java. Lang. noclassdeffounderror: net/SF/ehcache/cacheexception
Lack of ehcache. Jar
Java. Lang. noclassdeffounderror: net/SF/cglib/CORE/keyfactory
Lack of cglib-full.jar

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~

Symptom 4:
Org. springframework. beans. factory. beancreationexception: Error creating bean with name 'sessionfactory 'defined in resource [/WEB-INF/dataAccessContext-hibernate.xml] of servletcontext: initialization of bean failed; Nested exception is net. SF. hibernate. mappingexception: cocould not instantiate ID Generator
Net. SF. hibernate. mappingexception: cocould not instantiate ID Generator

Cause:
In HBM, the ID field is defined as an unspecified sequesce and changed to Inc.
<ID
Name = "ID"
Type = "string"
Column = "userid"
>
<Generator class = "net. SF. hibernate. Id. incrementgenerator"/> // It turns out to be sequence.
</ID>
In this way, you can.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~

Symptom 6:
Org. springframework. beans. factory. beancreationexception: Error creating bean with name'/shop/additemtocart. do 'defined in servletcontext resource [/WEB-INF/petstore-servlet.xml]: can't resolve reference to bean 'petstore' while setting property 'petstore'; Nested exception is Org. springframework. beans. factory. nosuchbeandefinitionexception: No bean named 'petstore' is defined
Org. springframework. Beans. Factory. nosuchbeandefinitionexception: No bean named 'petstore' is defined
Cause:
I use struts as action, of course, do not need to use spring Web Framework, so do not need to configure the file with it, such as, petstore-servlet.xml,
There is a remote-servlet.xml, but spring still loads the two files, no way, had to move the two files to another place, but appeared again can not find the two
I/O exception of the file, so I had to copy it back and then clear the file content.
It is easy to use.
The reason is that as long as you define this servlet in Web. XML, he will go to the configuration file (servletname-servlet.xml) corresponding to this servlet name, an error will occur if it is not found. OK, now comment out the servlet definitions and colors for PetStore in Web. XML, delete the petstore-servlet.xml file, haha, no errors are reported.
Similarly, comment out the servlet named remote, delete the remote-servlet.xml, restart tomcat, and no errors are reported. Haha. So it turns out.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~
Symptom:
Java. Lang. nullpointerexception
SRx. Test. testhibernate. userdao. getall (userdao. Java: 9)
Srx.test.struts.action.useraction.exe cute (useraction. Java: 20)
Cause:

Action
Userdao // This class is OK
Public class userdao extends hibernatedaosupport {
Public list getall (){
Return this. gethibernatetemplate (). Find ("select AA from account AA ");
}
}

// This class needs to be modified
Public class useraction extends actionsupport {
Userdao Dao = new userdao ();
List accounts = Dao. getall ();
...
}
Modify:
// Userdao Dao = new userdao ();
Webapplicationcontext WAC = This. getwebapplicationcontext ();
Userdao Dao = (userdao) WAC. getbean ("userdao ");
OK

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.