Problem adding Java component bean to AEM 6.3 component in Eclipse | Community
Skip to main content
Level 4
May 15, 2018
Solved

Problem adding Java component bean to AEM 6.3 component in Eclipse

  • May 15, 2018
  • 4 replies
  • 2467 views

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.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by arunpatidar

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

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.

4 replies

arunpatidar
Community Advisor
Community Advisor
May 15, 2018

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

Arun Patidar
Level 4
May 15, 2018

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.

arunpatidar
Community Advisor
arunpatidarCommunity AdvisorAccepted solution
Community Advisor
May 15, 2018

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

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.

Arun Patidar
Level 4
May 15, 2018

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