Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

Unable to load bean.xml in AEM java

Avatar

Level 3

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..

3 Replies

Avatar

Level 10

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

Level 3

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

Level 10

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