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
BedrockMission!

Learn More

View all

Sign in to view all badges

data inject to JCR null when try to resolve

Avatar

Avatar
Validate 1
Level 2
dilips50359074
Level 2

Likes

2 likes

Total Posts

30 posts

Correct Reply

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

Avatar
Validate 1
Level 2
dilips50359074
Level 2

Likes

2 likes

Total Posts

30 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Ignite 3
Ignite 1
Give Back 5
Give Back 3
View profile
dilips50359074
Level 2

09-09-2019

Gentlemen,

Thank you for helping me with some of my questions.

I am facing a technical issue

a) I am calling a java class from the sling scheduler which runs at regular interval.

b) This java class has code which will delete nodes from specific path in the jcr and recreates them based on the data given by other service.

In the scheduler

run method   (using the below code)

        AspectServiceImpl objAspectServiceImpl = new AspectServiceImpl();

        try {

               Boolean result = objAspectServiceImpl.InjectAlertData(alertList);

               }

In the AspectServiceImpl  (I have a method InjectAlertData, i have datawrite configured in OSGI configuration, this will open connection and insert data into specified node)

@Override

public boolean InjectAlertData(List<AlertModel> alertList) throws Exception

{

    log.info("into injectalertdata  " + alertList.size()); 

           try

           {

             Map<String, Object> param = new HashMap<String, Object>();

             log.info("into map"); 

             param.put(ResourceResolverFactory.SUBSERVICE, "datawrite");

                 log.info("after datawrite"); 

              ResourceResolver resolver = null;

             log.info("into injectalertdata try"); 

                         

      

                 resolver = resolverFactory.getServiceResourceResolver(param);      (this is throwing error not much description , just says null)

               log.info("after resolver"); 

               session = resolver.adaptTo(Session.class);

did any one of you face this issue?  If yes can you please guide me to resolve this.

Replies

Avatar

Avatar
Establish
MVP
Gaurav-Behl
MVP

Likes

248 likes

Total Posts

1,147 posts

Correct Reply

283 solutions
Top badges earned
Establish
Give back 300
Give Back 50
Give Back 5
Give Back 3
View profile

Avatar
Establish
MVP
Gaurav-Behl
MVP

Likes

248 likes

Total Posts

1,147 posts

Correct Reply

283 solutions
Top badges earned
Establish
Give back 300
Give Back 50
Give Back 5
Give Back 3
View profile
Gaurav-Behl
MVP

09-09-2019

Why do you instantiate the service in your code yourself?  -   AspectServiceImpl objAspectServiceImpl = new AspectServiceImpl();

Can you confirm that your scheduler is annotated with SCR/OSGI annotations?

Refer code samples here -

acs-aem-samples/bundle/src/main/java/com/adobe/acs/samples/schedulers/impl at master · Adobe-Consult...

https://adobe-consulting-services.github.io/acs-aem-samples/

Avatar

Avatar
Validate 1
Level 2
dilips50359074
Level 2

Likes

2 likes

Total Posts

30 posts

Correct Reply

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

Avatar
Validate 1
Level 2
dilips50359074
Level 2

Likes

2 likes

Total Posts

30 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Ignite 3
Ignite 1
Give Back 5
Give Back 3
View profile
dilips50359074
Level 2

09-09-2019

Thanks for the reply Gaurav,

I do not know any other way to instantiate a class at this point  (AspectSerivceImpl).  If there is any other way, please share.

I am using the archtype19 project which comes with sample code(simpleScheduledTask), I am using that.

Can you please elaborate more on SCR/OSGI annotation please...

Avatar

Avatar
Establish
MVP
Gaurav-Behl
MVP

Likes

248 likes

Total Posts

1,147 posts

Correct Reply

283 solutions
Top badges earned
Establish
Give back 300
Give Back 50
Give Back 5
Give Back 3
View profile

Avatar
Establish
MVP
Gaurav-Behl
MVP

Likes

248 likes

Total Posts

1,147 posts

Correct Reply

283 solutions
Top badges earned
Establish
Give back 300
Give Back 50
Give Back 5
Give Back 3
View profile
Gaurav-Behl
MVP

09-09-2019

Avatar

Avatar
Coach
MVP
Arun_Patidar
MVP

Likes

1,356 likes

Total Posts

3,227 posts

Correct Reply

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

Avatar
Coach
MVP
Arun_Patidar
MVP

Likes

1,356 likes

Total Posts

3,227 posts

Correct Reply

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

10-09-2019

Hi,

Just to check do you have system user and mapping in place to get subservice sesison

resolver = resolverFactory.getServiceResourceResolver(param);      (this is throwing error not much description , just says null)

Service Users in AEM

Avatar

Avatar
Coach
Employee
Jörg_Hoh
Employee

Likes

1,115 likes

Total Posts

3,149 posts

Correct Reply

1,072 solutions
Top badges earned
Coach
Give back 600
Ignite 5
Ignite 3
Ignite 1
View profile

Avatar
Coach
Employee
Jörg_Hoh
Employee

Likes

1,115 likes

Total Posts

3,149 posts

Correct Reply

1,072 solutions
Top badges earned
Coach
Give back 600
Ignite 5
Ignite 3
Ignite 1
View profile
Jörg_Hoh
Employee

10-09-2019

Services should not be instantiated, but just referenced. Therefor it's best they are stateless, in case multiple invocations can happen at the same time.

Jörg

Avatar

Avatar
Validate 1
Level 2
dilips50359074
Level 2

Likes

2 likes

Total Posts

30 posts

Correct Reply

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

Avatar
Validate 1
Level 2
dilips50359074
Level 2

Likes

2 likes

Total Posts

30 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Ignite 3
Ignite 1
Give Back 5
Give Back 3
View profile
dilips50359074
Level 2

11-09-2019

Thanks all for your support. 

AspectServiceImpl objAspectServiceImpl = new AspectServiceImpl();  (this should be just referenced using the OSGI).

Avatar

Avatar
Give Back 5
Level 2
scottm91515441
Level 2

Likes

5 likes

Total Posts

35 posts

Correct Reply

5 solutions
Top badges earned
Give Back 5
Give Back 3
Give Back 10
Give Back
Boost 5
View profile

Avatar
Give Back 5
Level 2
scottm91515441
Level 2

Likes

5 likes

Total Posts

35 posts

Correct Reply

5 solutions
Top badges earned
Give Back 5
Give Back 3
Give Back 10
Give Back
Boost 5
View profile
scottm91515441
Level 2

15-09-2019

You should be using @Reference to create service objects.