SPRING10 Common anomaly resolution method

Source: Internet
Author: User

In the programmer career, the most mentioned should be the three big SSH framework. As the first big frame of the spring framework, we often use it.

However, in the use of the process, encountered a lot of common anomalies, I summarize here, we encourage each other.

One, the exception for the configuration file could not be found

[Plain]View Plaincopy
    1. Org.springframework.beans.factory.BeanDefinitionStoreException:IOException parsing XML
    2. Document from class path resource [Com/herman/ss/controller]; Nested exception is java.io.FileNotFoundException:
    3. Class path resource [Com/herman/ss/controller] cannot is opened because it does not exist
Explanation: This means that, without looking for the configuration file for the controller's XML, modify the configuration file name.
[HTML]View Plaincopy
    1. <init-param>
    2. <param-name>contextconfiglocation</param-name>
    3. <param-value>classpath:com/herman/ss/config/testajax.xml</param-value >
    4. </init-param>
second, the namespace configured in XML does not find the corresponding schema exception [Plain]View Plaincopy
    1. Nested exception is org.xml.sax.saxparseexception:cvc-complex-type.2.4.c:the matching wildcard is strict,
    2. But no declaration can is found for element ' util:list '.
Xmlns:util= "Http://www.springframework.org/schema/util" is removed because util naming is not present in the schema
third, can not find the exception of Jackson.jar [Plain]View Plaincopy
    1. Standardwrapper.throwable
    2. Java.lang.noclassdeffounderror:org/codehaus/jackson/jsonprocessingexception

Missing Jackson's jar package, import Jackson-all-1.9.5.jar

Iv. Bean is not the only exception

[Plain]View Plaincopy
    1. org.springframework.beans.factory.nouniquebeandefinitionexception:    
    2. no qualifying bean of type [com.herman.ss.pojo.person] is  defined:   
    3. expected single matching bean but  found 7: person0,person1,person2,person3,person4,person5,person6  
    4.      at org.springframework.beans.factory.support.defaultlistablebeanfactory.getbean ( defaultlistablebeanfactory.java:313)   
    5.     at  Org.springframework.context.support.AbstractApplicationContext.getBean (abstractapplicationcontext.java:985)   
    6.     at com.herman.ss.test.test0.test1 (test0.java:35)   
    7.     at com.herman.ss.test.test0.main (test0.java:111)   
The exception is that after a class has configured multiple beans, we are still using Ctx.getbean (Person.class), which is to get the Bean object based on the bean's class map. The Bean object returned at this time is not unique and has multiple bean objects. The workaround is to get the Bean object based on the bean's ID.

V. Missing log jar Package

[Plain]View Plaincopy
    1. Java.lang.noclassdeffounderror:org/apache/commons/logging/logfactory
    2. caused by:java.lang.ClassNotFoundException:org.apache.commons.logging.LogFactory
The problem is that the project lacks spring-dependent jar package files. Solution: Join Commons-logging-1.1.3.jar.

Six. Bean exception not found

[Plain]View Plaincopy
    1. Org.springframework.beans.factory.NoSuchBeanDefinitionException:No Bean named ' filter2 ' is defined
The problem is that a bean with name Filter2 is not found in the project. To be blunt is to find the bean with ID filter2 in Applicationcontext.xml, configure it.

Vi. Lack of Spring-webmvc-4.0.6.release.jar package

[Plain]View Plaincopy
    1. Severity: Error Loading WebappClassLoader
    2. Context:/struts_spring_project
    3. Delegate:false
    4. Repositories:
    5. /web-inf/classes/
    6. ----------> Parent Classloader:
    7. [Email protected]
    8. Org.springframework.web.servlet.DispatcherServlet
    9. Java.lang.ClassNotFoundException:org.springframework.web.servlet.DispatcherServlet

Solution: Add Spring's MVC rack package to your project. If my spring version is 4.0.6, then add the Spring-webmvc-4.0.6.release.jar in.

Vii. Lack of Spring-aop-4.0.6.release.jar package

[Plain]View Plaincopy
    1. Java.lang.noclassdeffounderror:org/springframework/aop/targetsource
    2. Java.lang.ClassNotFoundException:org.springframework.aop.TargetSource
Solution: Add Spring's AOP rack package to your project. If my spring version is 4.0.6, then add the Spring-aop-4.0.6.release.jar in.

Viii. Lack of Spring-expression-4.0.6.release.jar package

[Plain]View Plaincopy
    1. Java.lang.noclassdeffounderror:org/springframework/expression/expressionparser
    2. Java.lang.ClassNotFoundException:org.springframework.expression.ExpressionParser

Solution: Add spring's expression rack package to your project. If my spring version is 4.0.6, then add the Spring-expression-4.0.6.release.jar in.

The name of the bean, name or ID, or alias aliases already exist.

[Plain]View Plaincopy
    1. Org.springframework.beans.factory.parsing.BeanDefinitionParsingException:
    2. Configuration problem:bean name ' A ' is already used in this <beans> element

Workaround: Change the name of the duplicate to a name.

X. The bean's automatic loading cannot find the corresponding bean problem

[Plain]View Plaincopy
    1. Org.springframework.beans.factory.NoSuchBeanDefinitionException:No qualifying Bean of type [Com.yyc.ym.biz.YycBiz] Found for dependency:expected at least 1 beans which qualifies as Autowire candidate for this dependency. Dependency annotations: {@org. springframework.beans.factory.annotation.Autowired (Required=true)}
Workaround: Add default-autowire= "ByName" default-lazy-init= "true" to the <beans> root node in the configuration file or <context:component-scan Base-package= "com.xxx.dao.*" ></context:component-scan> package below with * match

SPRING10 Common anomaly resolution method

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.