Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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);

        }

    }
like image 886
Elavarasan Avatar asked Dec 11 '14 14:12

Elavarasan


2 Answers

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

like image 168
Ali Dehghani Avatar answered Nov 15 '22 07:11

Ali Dehghani


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

like image 37
kyzh101 Avatar answered Nov 15 '22 06:11

kyzh101