Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

[AEM Gems Webinar] Accelerating Experience Manager as a Cloud Service development with Rapid Development Environments
SOLVED

Problem adding Java component bean to AEM 6.3 component in Eclipse

Avatar

Level 4

Hi All,

I am trying to add a Java component bean to an AEM 6.3 component in Eclipse.

I have added the following Java class to the "core" section in the Eclipse project :-

package test;

import com.adobe.cq.sightly.WCMUsePojo;

public class TestComponentBean extends WCMUsePojo

{

    @Override

    public void activate() throws Exception

    {      

    }

   

    public String getContent()

    {

        return "TEST CONTENT";

    }

}

I have added the following HTML to the page template in the "ui.apps" section in the Eclipse project :-

<div data-sly-use.componentBean="${'test.TestComponentBean'}">

    <p> ${componentBean.content} </p>

</div>

The project appears to build and deploy to the AEM 6.3 server correctly.

When I view the page template, I am seeing the following error in the browser in the page source :-

org.apache.sling.scripting.sightly.SightlyException: Cannot find a file corresponding to class test.TestComponentBean in the repository.

Please can you advise me why the class test.TestComponentBean cannot be found and how can I resolve this problem?

Thank you for your time.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

could you please check bundle org.apache.commons.lang3

Screen Shot 2018-05-15 at 1.59.30 PM.png

and update the same in POM file in <Import-Package></Import-Package>

or download new version of Apache Commons Lang bundle(3.7) and install in Felix console.

View solution in original post

4 Replies

Avatar

Community Advisor

Please check below:

1. your bundle is active or not

2. check bundle manifest export-package header

3. Instantiate Java object in HTL like below:

     <div data-sly-use.componentBean="test.TestComponentBean"></div>

Thanks

Arun

Avatar

Level 4

Thanks Arun,

I've had a look in http://localhost:4502/system/console/bundles

The package is "Installed" but not "Active".

In the Imported Packages section is the following error :-

org.apache.commons.lang3,version=[3.7,4) -- Cannot be resolved

Do you know how I can resolve this error?

Thank you again for your time.

Avatar

Correct answer by
Community Advisor

could you please check bundle org.apache.commons.lang3

Screen Shot 2018-05-15 at 1.59.30 PM.png

and update the same in POM file in <Import-Package></Import-Package>

or download new version of Apache Commons Lang bundle(3.7) and install in Felix console.

Avatar

Level 4

Thanks.   It is working now.   If I have any more questions I will open a new questions.