This conversation has been locked due to inactivity. Please create a new post.
This conversation has been locked due to inactivity. Please create a new post.
Hi All, I have created a simple service in Sling and deployed the same on my AEM instance. However, the activate method is not getting called for this class. Here is my implementation class: package com.company.project.auth.impl; import org.osgi.service.component.annotations.Activate; import org.osgi.service.component.annotations.Component; import org.osgi.service.metatype.annotations.Designate; import org.slf4j.Logger; @Designate(ocd=MyConfiguration.class) @Component(service = MyRequestImpl.class, immediate = true, configurationPid = "com.company.project.auth.impl.MyRequestImpl") public class MyRequestImpl implements MyRequest{ protected final transient Logger logger = LoggerFactory.getLogger(this.getClass()); @Activate protected void activate( final MyConfiguration config) { logger.info("Calling Activate"); } @Override public String myFunction() { logger.info("Calling my function"); } } I am able to see the log, "Calling my function" but not the one, "Calling Activate". Please suggest a solution.
Solved! Go to Solution.
Views
Replies
Total Likes
Hi,
Can you check if your service is active or not? I tried with your code with small modification works for me.
package com.aem.community.core.services;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.metatype.annotations.Designate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.aem.community.core.Config;
@Designate(ocd = Config.class)
@Component(service = MyRequest.class, immediate = true, configurationPid = "com.aem.community.core.services.MyRequest")
public class MyRequestImpl implements MyRequest {
protected final transient Logger logger = LoggerFactory.getLogger(this.getClass());
@Activate
protected void activate(final Config config) {
logger.info("Calling Activate");
}
@Override
public String myFunction() {
logger.info("Calling my function");
return "myfunction";
}
}
Views
Replies
Total Likes
Hi,
Can you check if your service is active or not? I tried with your code with small modification works for me.
package com.aem.community.core.services;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.metatype.annotations.Designate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.aem.community.core.Config;
@Designate(ocd = Config.class)
@Component(service = MyRequest.class, immediate = true, configurationPid = "com.aem.community.core.services.MyRequest")
public class MyRequestImpl implements MyRequest {
protected final transient Logger logger = LoggerFactory.getLogger(this.getClass());
@Activate
protected void activate(final Config config) {
logger.info("Calling Activate");
}
@Override
public String myFunction() {
logger.info("Calling my function");
return "myfunction";
}
}
Views
Replies
Total Likes
Hi Arun
I checked that the service is active. But still On hitting the service, I am not able to see the activate log.
Can you suggest what change made it work for you?
Views
Replies
Total Likes
Views
Replies
Total Likes
Well I am not getting any exception, and the code is also same. Its just that I am using my custom service and configuration so the pid also differs.
But not getting the desired result.
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies