WCMUsePojo in AEM6.3 not working

Avatar

Avatar
Give Back 3
Level 2
prashanth55
Level 2

Likes

7 likes

Total Posts

20 posts

Correct reply

2 solutions
Top badges earned
Give Back 3
Give Back
Ignite 1
Validate 1
Boost 5
View profile

Avatar
Give Back 3
Level 2
prashanth55
Level 2

Likes

7 likes

Total Posts

20 posts

Correct reply

2 solutions
Top badges earned
Give Back 3
Give Back
Ignite 1
Validate 1
Boost 5
View profile
prashanth55
Level 2

07-10-2018

Hi All,

I have created a class which extends WCMUsePojo. But it's not working, it is giving following error.

com.adobe.cq.sightly.WCMUsePojo Failed to activate Use class

java.lang.NullPointerException: null

This is the code:

import com.adobe.cq.sightly.WCMUsePojo;

public class TestUse extends WCMUsePojo {

     String text;

   

    @Override

    public void activate() throws Exception {

    text = get("text", String.class);

        log.debug("Text: {}", text);

        log.info("--- Started : : Activate");       

    }

    public String getText (){

        return this.text;

    }   

}

I have also included uber.jar in the pom.and the bundle is in the active state.

Please help me to resolve this issue.

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Give Back 3
Level 2
prashanth55
Level 2

Likes

7 likes

Total Posts

20 posts

Correct reply

2 solutions
Top badges earned
Give Back 3
Give Back
Ignite 1
Validate 1
Boost 5
View profile

Avatar
Give Back 3
Level 2
prashanth55
Level 2

Likes

7 likes

Total Posts

20 posts

Correct reply

2 solutions
Top badges earned
Give Back 3
Give Back
Ignite 1
Validate 1
Boost 5
View profile
prashanth55
Level 2

08-10-2018

Thanks All, the issue is solved. The acs-commons bundle is causing the issue because of twitter dependency. It is working fine after adding twitter bundle and restarting the core bundle.

Answers (8)

Answers (8)

Avatar

Avatar
Give Back 50
Employee
Feike_Visser1
Employee

Likes

247 likes

Total Posts

970 posts

Correct reply

221 solutions
Top badges earned
Give Back 50
Give Back 5
Give Back 3
Give Back 25
Give Back 10
View profile

Avatar
Give Back 50
Employee
Feike_Visser1
Employee

Likes

247 likes

Total Posts

970 posts

Correct reply

221 solutions
Top badges earned
Give Back 50
Give Back 5
Give Back 3
Give Back 25
Give Back 10
View profile
Feike_Visser1
Employee

08-10-2018

Good to hear, although I can't see how this bundle can affect this.

Avatar

Avatar
Validate 1
MVP
raj_mandalapu
MVP

Likes

125 likes

Total Posts

203 posts

Correct reply

72 solutions
Top badges earned
Validate 1
Contributor
Shape 1
Give Back 5
Give Back 3
View profile

Avatar
Validate 1
MVP
raj_mandalapu
MVP

Likes

125 likes

Total Posts

203 posts

Correct reply

72 solutions
Top badges earned
Validate 1
Contributor
Shape 1
Give Back 5
Give Back 3
View profile
raj_mandalapu
MVP

07-10-2018

How are you deploying bundle ? are you deploying through Felix console ? or did use CRXDE to create a class? please post entire code?

Try below code : to read value from dialog we should use below code

getProperties().get("text", String.class);

I think get is used when you pass a parameter from sightly. this caused null pointer exception

get("text", String.class);

Avatar

Avatar
Validate 1
MVP
raj_mandalapu
MVP

Likes

125 likes

Total Posts

203 posts

Correct reply

72 solutions
Top badges earned
Validate 1
Contributor
Shape 1
Give Back 5
Give Back 3
View profile

Avatar
Validate 1
MVP
raj_mandalapu
MVP

Likes

125 likes

Total Posts

203 posts

Correct reply

72 solutions
Top badges earned
Validate 1
Contributor
Shape 1
Give Back 5
Give Back 3
View profile
raj_mandalapu
MVP

07-10-2018

I think it is because of log.debug. I don't see creating an instance for the Logger class in your code.

Avatar

Avatar
Give Back 50
Employee
Feike_Visser1
Employee

Likes

247 likes

Total Posts

970 posts

Correct reply

221 solutions
Top badges earned
Give Back 50
Give Back 5
Give Back 3
Give Back 25
Give Back 10
View profile

Avatar
Give Back 50
Employee
Feike_Visser1
Employee

Likes

247 likes

Total Posts

970 posts

Correct reply

221 solutions
Top badges earned
Give Back 50
Give Back 5
Give Back 3
Give Back 25
Give Back 10
View profile
Feike_Visser1
Employee

08-10-2018

Can you share the full stacktrace? And also the code seems not to be complete.

Avatar

Avatar
Validate 25
MVP
Ratna_Kumar
MVP

Likes

159 likes

Total Posts

755 posts

Correct reply

134 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give Back 50
Give Back 5
View profile

Avatar
Validate 25
MVP
Ratna_Kumar
MVP

Likes

159 likes

Total Posts

755 posts

Correct reply

134 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give Back 50
Give Back 5
View profile
Ratna_Kumar
MVP

08-10-2018

Hi Prashanth,

Have you checked this article which tells how to use WCMUsePojo class

Adobe Experience Manager Help | Creating an Adobe Experience Manager HTML Template Language componen...

Thanks,

Ratna Kumar.

Avatar

Avatar
Coach
MVP
Arun_Patidar
MVP

Likes

1,444 likes

Total Posts

3,327 posts

Correct reply

941 solutions
Top badges earned
Coach
Contributor 2
Ignite 10
Give Back 700
Boost 1000
View profile

Avatar
Coach
MVP
Arun_Patidar
MVP

Likes

1,444 likes

Total Posts

3,327 posts

Correct reply

941 solutions
Top badges earned
Coach
Contributor 2
Ignite 10
Give Back 700
Boost 1000
View profile
Arun_Patidar
MVP

07-10-2018

Avatar

Avatar
Validate 1
Level 10
edubey
Level 10

Likes

277 likes

Total Posts

1,502 posts

Correct reply

392 solutions
Top badges earned
Validate 1
Give Back 50
Give Back 5
Give Back 3
Give Back 25
View profile

Avatar
Validate 1
Level 10
edubey
Level 10

Likes

277 likes

Total Posts

1,502 posts

Correct reply

392 solutions
Top badges earned
Validate 1
Give Back 50
Give Back 5
Give Back 3
Give Back 25
View profile
edubey
Level 10

07-10-2018

You should be seeing line no where NPE is occuring, can you check?

Also is that the complete code?

Make sure you bundle is resolved in felix

Avatar

Avatar
Validate 1
Level 10
edubey
Level 10

Likes

277 likes

Total Posts

1,502 posts

Correct reply

392 solutions
Top badges earned
Validate 1
Give Back 50
Give Back 5
Give Back 3
Give Back 25
View profile

Avatar
Validate 1
Level 10
edubey
Level 10

Likes

277 likes

Total Posts

1,502 posts

Correct reply

392 solutions
Top badges earned
Validate 1
Give Back 50
Give Back 5
Give Back 3
Give Back 25
View profile
edubey
Level 10

07-10-2018

code will not compile if that's the case