Spring Hibernate configuration conflicts in AOP __java learning

Source: Internet
Author: User
Tags aop
Spring hibernate configuration conflict in AOP
Spring2.0 hibernate3.1.x/hibernate3.2


When you use spring's AOP programming, you use these several lib:
Asm-2.2.2.jar
Asm-commons-2.2.2.jar
Asm-util-2.2.2.jar


Hibernate If you use Lib:
Asm.jar
Asm-attrs.jar


where Asm-2.2.2.jar and Asm.jar exist class conflicts ...
Using one or both of these, you may receive the following error:
Java.lang.noclassdeffounderror:org/objectweb/asm/codevisitor
Java.lang.noclassdeffounderror:org/objectweb/asm/commons/emptyvisitor
Java.lang.NoSuchMethodError:org.objectweb.asm.ClassVisitor.visit ...


The solution is:
1). Remove the 3 lib of hibernate on the Classpath
Asm.jar
Asm-attrs.jar
Cglib-2.1.3.jar
2). Join the following 4 lib in spring
Asm-2.2.2.jar
Asm-commons-2.2.2.jar
Asm-util-2.2.2.jar
Cglib-nodep-2.1_3.jar


If no more, try to delete the check.




Java.lang.SecurityException:class "Javax.xml.bind.JAXBContext" ' s signer information does not match signer information Of the other classes in the same package
This error is because the loaded package has two classes with the same path, or two classes with the same name in a package.
It is possible to load the same package two times or unpack it, load the jar file first, and then load the unpacked class into the




Error Configuring application Listener of Class Org.springframework.web.context.ContextLoaderListener
Try the next spring package and add the Spring.jar to the project. Some of the packages may not be included when eclipse is generated.




Error creating Bean with Name ' datasource ' defined in file
Instantiation of Bean failed; Nested exception is Java.lang.noclassdeffounderror:org/apache/commons/pool/impl/genericobjectpool
Try adding Commons-dbcp.jar,commons-pool.jar and Commons-collections.jar to Classpath.




The Hibernatetemplate in Hibernate 3.1, Class should be org.springframework.orm.hibernate3.HibernateTemplate, not org.springframework.orm.hibernate.HibernateTemplate, for some reason I am still using 3.1, earlier in playing Springside feel hibernate 3.2 hibernate annotations more convenient.


Cannot find the action or the error of the other reason, some version hibernate version will have some conflict aspects of the problem, you can change a version of the hibernate try, personal feeling hibernate version of the application will be more sensitive




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


Reason: Missing Jta.jar or unable to find Hbm.xml file causes sessionfactory error, check hbm file path is correct, file exists
<property name= "Mappingresources" >
<list>
<value>com/yourcompany/model/login.hbm.xml
</value>
</list>
</property>


In addition, this error may be caused by errors in the HBM file, such as establishing a constraint relationship between tables when the table was originally designed, so when some of the persisted classes were generated and others with associated tables did not generate the persisted class. The hbm file also has a one-to-many correlation for the generation, and the other table does not generate the persistence class. So the runtime will report this error. It is OK to remove the configuration that is temporarily unused in the hbm file.




2007-06-26 18:38:13,671 ERROR [Com.yourcompany.model.dao.LoginDAO]-<save failed>
Org.springframework.jdbc.BadSqlGrammarException:Hibernate operation:could not insert: [Com.yourcompany.model.Login ]; Bad SQL grammar [inserts into Mysql__login (name, password) VALUES (?,?)]; Nested exception is java.sql.SQLException:Table ' mysql.mysql__login ' doesn ' t exist
Java.sql.SQLException:Table ' mysql.mysql__login ' doesn ' t exist


The hbm file inside the catalog= "' MySQL" can be removed.
Note also that the DAO file generated by eclipse should be:
public void Save (Login transientinstance) {
Log.debug ("Saving Login instance");
try {
Gethibernatetemplate (). Save (Transientinstance);
Log.debug ("Save Successful");
catch (RuntimeException re) {
Log.error ("Save Failed", re);
throw re;
}
}
Instead of the original public void Save (Logindao transientinstance)


Just add in the applicationcontext.xml.
<property name= "Mappingresources" >
<list>
<value>com/yourcompany/hibernate/Users.hbm.xml</value>
</list>
</property>
Add this code and you won't find the action.
Another version of Hibernate should be OK




Invalid Path/addcustomer was requested
The path you entered is incorrect, check the path of the registered action in spring and the path you entered are consistent, and note that the case is consistent


2007-08-08 15:36:17,406 ERROR [Org.hibernate.proxy.BasicLazyInitializer]-cglib enhancement Failed:dao. User
Java.lang.NoSuchMethodError:org.objectweb.asm.ClassVisitor.visit (iiljava/lang/string; ljava/lang/string; [Ljava/lang/string; ljava/lang/string;) V
At Net.sf.cglib.core.ClassEmitter.begin_class (classemitter.java:77)


Some jar files shared by Spring and Hibernate have version conflicts, delete Web-inf/lib/asm-2.2.3.jar, and then restart Tomcat.


Asm-2.2.3.jar
Asm.jar
Asm-attrs.jar
Asm-commons-2.2.3.jar
Asm-util-2.2.3.jar


In addition, if you report the following error:


caused By:java.lang.SecurityException:class "Org.objectweb.asm.CodeVisitor" ' s signer information does not match signer Information of the other classes in the same package


Also due to the previous reason, some jar files shared by spring and Hibernate have a version conflict and need to be deleted Asm-2.2.3.jar




Resources cannot is null
In addition to what everyone said, if you do not load the validation plug-in in the Struts-config.xml configuration, you will also report the above error, please add it in the configuration file
<plug-in classname= "Org.springframework.web.struts.ContextLoaderPlugIn"/>
<plug-in classname= "Org.apache.struts.validator.ValidatorPlugIn" >
<set-property property= "pathnames" value= "/web-inf/validator-rules.xml,/web-inf/validation.xml"/>
</plug-in>




Hibernate java.lang.NullPointerException


Check the configuration file.
In Struts-config, for example, the name and path of the action are consistent, and are consistent with the name that is registered in spring. Special attention to case. HBM file configuration is wrong, case ...


----------------------------------------------------------------------------------------------


%%%%error creating Sessionfactory%%%% Java.lang.SecurityException:class " Org.apache.commons.collections.SequencedHashMap "' s signer informationdoes not match signer information of other classes In the same package
Because I used the 6.0.1, so I did not appear this exception. Later, Google found that a lot of people have encountered this fault, speculation is commons-collections.jar problem, May and myeclipse 6.0.0 with the package has problems. For example, the following is a solution:

Solution:
1) Download MyEclipse 6.0. to develop;
2 or go to http://commons.apache.org/collections/to download a new package, the original Commons-collections-xxx.jar to delete, and then replace with the new package. Note: Be sure to go to the application's publishing directory to do this work, and after the replacement can not republish the application, and then immediately restart the Tomcat test.


--------------------------------------------------------------------------------------------------------


1, java.lang.NoSuchMethodError:org.springframework.util.ObjectUtils.nullSafeToString (ljava/lang/object;) ljava/ lang/string;
Spring's jar bundle conflict Error:
I am using the spring2.0 jar package, should be used for work scheduling so add a 1.2 version of the Spring.jar do support, the project runs in the container run nothing, the unit test will appear above errors.
References: http://www.javaeye.com/post/365364
2,
Support. Disposablebeanadapter (disposablebeanadapter.java:148)-couldn ' t invoke destroy method of beans with name ' sessionfact Ory '
Java.lang.IllegalStateException:Shutdown in progress
Looked up the following information, also someone met, looked for a similar http://www.blogjava.net/allen-zhe/archive/2007/03/20/104880.html, my solution, Just add a destroy-method= "close" configuration to the data source configuration.
The solution is to see http://forum.springframework.org/archive/index.php/t-19665.html this article to come out.
3, Org.hibernate.HibernateException:CGLIB enhancement failed:
The reason is myeclipse6.0 Cglib-2.1.3.jar have bugs, instead cglib-2.1.jar on it
4, [This is in the server runtime only reported, a bit digress] there is also a more subtle error, as long as the Log4j property file is set to debug only the error code will be reported as follows:
DEBUG [main] XML. Defaultnamespacehandlerresolver (defaultnamespacehandlerresolver.java:128)-Ignoring namespace handler [ Org.springframework.scripting.config.LangNamespaceHandler]: Handler class not found
Java.lang.ClassNotFoundException:org.springframework.scripting.config.LangNamespaceHandler
Can not find the hint of the class, Google search for a period of time did not find this class in that bag, the last one to be sure myeclipse own bag must have, indeed found, is less loaded Spring-support.jar package. In MyEclipse's Spring2.0 Misc libraires Library.

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.