Unable to load bean.xml in AEM java

Avatar

Avatar

rasikawanjari

Avatar

rasikawanjari

rasikawanjari

22-04-2019

Am trying to load bean.xml file but am getting following error

IOException parsing XML document from class path resource [bean.xml]; nested exception is java.io.FileNotFoundException: class path resource [bean.xml] cannot be opened because it does not exist

This is line of code am using to load bean file is

ApplicationContext context = new ClassPathXmlApplicationContext("bean.xml");

bean.xml file present in src/main/resources folder

provide any solution ASAP..

Replies

Avatar

Avatar

smacdonald2008

Total Posts

12.7K

Likes

1.4K

Correct Reply

2.3K

Avatar

smacdonald2008

Total Posts

12.7K

Likes

1.4K

Correct Reply

2.3K
smacdonald2008

22-04-2019

THIS API (org.springframework.context.ApplicationContxt) is not an AEM API.

Looks like you are attempting to use Spring MVC API in AEM.

To develop in AEM - you should use Sling APIs, OSGi, etc, See this article as a guideline on how to develop against AEM:

Getting Started with AEM Sites - WKND Tutorial

Avatar

Avatar

rasikawanjari

Avatar

rasikawanjari

rasikawanjari

24-04-2019

I have dependency on external customized jar so i have to use ApplicationContext to load bean.xml
is there any solution ?
because which is working  in eclipse  but not in AEM server .

Avatar

Avatar

smacdonald2008

Total Posts

12.7K

Likes

1.4K

Correct Reply

2.3K

Avatar

smacdonald2008

Total Posts

12.7K

Likes

1.4K

Correct Reply

2.3K
smacdonald2008

24-04-2019

The reason it's not working is that you are attempting to use AEM as if its a Spring-based platform.

ApplicationContext is a Spring API: Understanding application-context

As discussed in the WEEKEND tutorial - an AEM site is implemented using:

  • HTL
  • Sling Models
  • Touch UI
  • Core Components v2
  • Editable Templates
  • Style System
  • Maven AEM Project Archetype 15

Not Spring APIs.

I also know SPRING MVC and how it works with Controllers, Views, and Models and annotations like @autowired. AEM uses none of these.

AEM uses OSGi based R6, R7 annotations (like @Reference) : Using OSGi R6 annotations (>= AEM6.2) - Experience Delivers