Created scheduler but not able to see log output in the project log | Community
Skip to main content
Level 2
April 15, 2021
Solved

Created scheduler but not able to see log output in the project log

  • April 15, 2021
  • 2 replies
  • 2007 views

Below is the code for configuring the scheduler. You can refer to the screenshot of the configuration

 

@ObjectClassDefinition(
name = "AEM: SlingSchedulerConfiguration",
description = "Sling scheduler configuration"
)
public @interface SchedulerConfig
{

@AttributeDefinition(name = "Cron-job expression")
String scheduler_expression() default "*/10 * * * * ?";

@AttributeDefinition(name = "A parameter",
description = "Can be configured in /system/console/configMgr")
String myParameter() default "";
}

 

 

@Designate(ocd=SchedulerConfig.class)
@8220494(service=Runnable.class, immediate = true)
public class MyScheduler implements Runnable
{
private final Logger logger = LoggerFactory.getLogger(getClass());

private String myParameter;
@9944223
public void run() {
logger.debug("MyScheduler is now running, myParameter='{}'", myParameter);
}

@580286
protected void activate(final SchedulerConfig config) {
myParameter = config.myParameter();
}
}

 

 

 

 

 

 

 

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 Asutosh_Jena_

Hi @ashwinikhaple 

 

Please update the below line of code:

 

@component(service=MyScheduler.class, immediate = true)

@Designate(ocd=SchedulerConfig.class)

public class MyScheduler implements Runnable

 

Service class should be your component class name.

 

Thanks!

 

2 replies

Asutosh_Jena_
Community Advisor
Asutosh_Jena_Community AdvisorAccepted solution
Community Advisor
April 15, 2021

Hi @ashwinikhaple 

 

Please update the below line of code:

 

@component(service=MyScheduler.class, immediate = true)

@Designate(ocd=SchedulerConfig.class)

public class MyScheduler implements Runnable

 

Service class should be your component class name.

 

Thanks!

 

Level 2
April 15, 2021

I am getting the below error

 

Caused by: org.apache.sling.api.scripting.ScriptEvaluationException:
at org.apache.sling.scripting.core.impl.DefaultSlingScript.call(DefaultSlingScript.java:416) [org.apache.sling.scripting.core:2.0.56]
at org.apache.sling.scripting.core.impl.DefaultSlingScript.eval(DefaultSlingScript.java:184) [org.apache.sling.scripting.core:2.0.56]
at org.apache.sling.scripting.core.impl.DefaultSlingScript.service(DefaultSlingScript.java:491) [org.apache.sling.scripting.core:2.0.56]
at org.apache.sling.servlets.resolver.internal.SlingServletResolver.handleError(SlingServletResolver.java:621) [org.apache.sling.servlets.resolver:2.4.24]
... 68 common frames omitted
Caused by: org.apache.sling.api.SlingException:
at org.apache.sling.scripting.jsp.jasper.servlet.JspServletWrapper.handleJspExceptionInternal(JspServletWrapper.java:691) [org.apache.sling.scripting.jsp:2.3.4]
at org.apache.sling.scripting.jsp.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:608) [org.apache.sling.scripting.jsp:2.3.4]
at org.apache.sling.scripting.jsp.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:533) [org.apache.sling.scripting.jsp:2.3.4]
at org.apache.sling.scripting.jsp.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:449) [org.apache.sling.scripting.jsp:2.3.4]
at org.apache.sling.scripting.jsp.JspScriptEngineFactory.callJsp(JspScriptEngineFactory.java:342) [org.apache.sling.scripting.jsp:2.3.4]
at org.apache.sling.scripting.jsp.JspScriptEngineFactory.access$100(JspScriptEngineFactory.java:97) [org.apache.sling.scripting.jsp:2.3.4]
at org.apache.sling.scripting.jsp.JspScriptEngineFactory$JspScriptEngine.eval(JspScriptEngineFactory.java:603) [org.apache.sling.scripting.jsp:2.3.4]
at org.apache.sling.scripting.core.impl.DefaultSlingScript.call(DefaultSlingScript.java:388) [org.apache.sling.scripting.core:2.0.56]
... 71 common frames omitted
Caused by: org.eclipse.jetty.io.RuntimeIOException: org.eclipse.jetty.io.EofException
at org.eclipse.jetty.server.ResponseWriter.isOpen(ResponseWriter.java:133) [org.apache.felix.http.jetty:4.0.8]
at org.eclipse.jetty.server.ResponseWriter.write(ResponseWriter.java:202) [org.apache.felix.http.jetty:4.0.8]
at java.io.PrintWriter.write(Unknown Source)

Vijayalakshmi_S
Level 10
April 15, 2021

Hi @ashwinikhaple,

Code that you have shared in your query should work as is. (Written following the code that comes with Sample Scheduler in AEM Maven archetype project)

Only reason for not seeing the lop output is the log level. 

Note : In general, Service name should always be the interface that the component implements. (service attribute in @Component annotation)