The type org.springframework.beans.BeansException cannot be resolved. It is indirectly referenced from required .class files

32,920

Solution 1

If you aren't using maven (or any other dependency management tool, for that matter), you should add spring-context dependencies manually, which are spring-beans, spring-core, spring-aop and spring-expression, of course each of them have their own dependencies either (Transitive Dependency). By the way, BeansException is part of spring-beans module

Solution 2

May be you are missing org.springframework.beans-3.0.4.RELEASE jar

Solution 3

I have problems with *org.springframework.context.EnvironmentAware*
Adding this dependency in pom from maven repository solve my problem.

*<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-beans</artifactId>
    <version>5.0.3.RELEASE</version>
</dependency>*

Solution 4

Yes I've managed to resolve the issue.... I use the following pattern: the program and the results without error

Version: 3.0.4.RELEASE

Then select -> Maven-> Update Project

Share:
32,920
Elavarasan
Author by

Elavarasan

Updated on August 06, 2022

Comments

  • Elavarasan
    Elavarasan almost 2 years

    Hi am facing issue with below error in eclipse please help to resolve this issue.

    Error message

    The type org.springframework.beans.BeansException cannot be resolved. It is indirectly referenced from required .class files

    I imported the jar file (org.springframework.context-3.0.4.RELEASE) even then am facing this issue.

    see below code( where am getting issue at line ApplicationContext appCtx = new ClassPathXmlApplicationContext("applicationContext.xml");)

        package com.csp.test.document;
    
        import static org.junit.Assert.*;
        import org.junit.Test;
        import org.springframework.context.ApplicationContext;
        import org.springframework.context.support.ClassPathXmlApplicationContext;
    
        import com.csp.model.Document;
        import com.csp.service.DocumentService;
    
        public class DocumentTest {
    
            @Test
            public void testGetDocument() {
                ApplicationContext appCtx = new ClassPathXmlApplicationContext(
                        "applicationContext.xml");
    
                DocumentService documentService = (DocumentService) appCtx
                        .getBean("documentService");
    
                Document doc = documentService.getDocument(1);
    
                String status = null;
    
                if (doc != null) {
                    status = documentService.saveDocument(doc);
                } else {
                    System.out.println("error in retreiving document");
                }
    
                assertEquals("Success Status", "SUCCESS", status);
    
            }
    
        }
    
    • Gaurav
      Gaurav over 4 years
      this jar needs to be present in the dependencies.
  • Elavarasan
    Elavarasan over 9 years
    Thank you :) as you said I have download (spring-beans-3.1.xsd download) jar and its worked for me......
  • Ali Dehghani
    Ali Dehghani over 9 years
    Your welocome. for better dependency management, i recommend to use maven
  • Tushar
    Tushar over 7 years
    Welcome to StackOverflow! Look around, it's English site. For now, I've translated the post in English. Please post your questions, answers and comments in English.
  • ketan
    ketan almost 7 years
    If you are maven user then upgrade your version >= 4.0.0
  • sql_dummy
    sql_dummy about 6 years
    Okay now I saw when this exception is raised, can you give the reason like what exactly calls BeansException
  • Gaurav
    Gaurav over 4 years
    exactly! this jar needs to be present in the dependencies.