[RTFACT-7694] Internal error due to bad cron expression Created: 22/Jul/15  Updated: 14/Nov/17  Resolved: 19/Oct/15

Status: Resolved
Project: Artifactory Binary Repository
Component/s: None
Affects Version/s: 3.9.2
Fix Version/s: 4.2.0

Type: Bug Priority: Critical
Reporter: Itamar Berman-Eshel Assignee: Michael Pasternak (Inactive)
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Trigger

 Description   

Setting a job with invalid cron expression creates a 500 internal error in Artifactory.

For example, performing repository push replication with a cron job that runs only once, i.e:
0 50 21 22 7 ? 2015 to run in July 22nd 2015 at 21:50.
Once the replication runs and this time has passed, trying to enter the repository replication configuration page will result in a 500 internal error:

2015-07-22 21:51:19,032 [http-bio-8081-exec-9] [ERROR] (o.a.w.DefaultExceptionMapper:114) - Unexpected error occurred
org.apache.wicket.WicketRuntimeException: Method onRequest of interface org.apache.wicket.behavior.IBehaviorListener targeted at org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink$1 {event='onclick'} on component [ [Component id = link]] threw an exception
	at org.apache.wicket.RequestListenerInterface.internalInvoke(RequestListenerInterface.java:270) ~[wicket-core-1.5.5.jar:1.5.5]
	at org.apache.wicket.RequestListenerInterface.invoke(RequestListenerInterface.java:241) ~[wicket-core-1.5.5.jar:1.5.5]
	at org.apache.wicket.request.handler.ListenerInterfaceRequestHandler.invokeListener(ListenerInterfaceRequestHandler.java:255) ~[wicket-core-1.5.5.jar:1.5.5]
	at org.apache.wicket.request.handler.ListenerInterfaceRequestHandler.respond(ListenerInterfaceRequestHandler.java:234) ~[wicket-core-1.5.5.jar:1.5.5]
	at org.apache.wicket.request.cycle.RequestCycle$HandlerExecutor.respond(RequestCycle.java:781) ~[wicket-core-1.5.5.jar:1.5.5]
	at org.apache.wicket.request.RequestHandlerStack.execute(RequestHandlerStack.java:64) ~[wicket-request-1.5.5.jar:1.5.5]
	at org.apache.wicket.request.cycle.RequestCycle.execute(RequestCycle.java:255) [wicket-core-1.5.5.jar:1.5.5]
	at org.apache.wicket.request.cycle.RequestCycle.processRequest(RequestCycle.java:212) [wicket-core-1.5.5.jar:1.5.5]
	at org.apache.wicket.request.cycle.RequestCycle.processRequestAndDetach(RequestCycle.java:283) [wicket-core-1.5.5.jar:1.5.5]
	at org.apache.wicket.protocol.http.WicketFilter.processRequest(WicketFilter.java:185) [wicket-core-1.5.5.jar:1.5.5]
	at org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:241) [wicket-core-1.5.5.jar:1.5.5]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) [catalina.jar:7.0.56]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) [catalina.jar:7.0.56]
	at org.artifactory.webapp.servlet.RepoFilter.execute(RepoFilter.java:200) [artifactory-web-application-3.9.2.jar:na]
	at org.artifactory.webapp.servlet.RepoFilter.doFilter(RepoFilter.java:92) [artifactory-web-application-3.9.2.jar:na]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) [catalina.jar:7.0.56]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) [catalina.jar:7.0.56]
	at org.artifactory.webapp.servlet.AccessFilter.useAuthentication(AccessFilter.java:314) [artifactory-web-application-3.9.2.jar:na]
	at org.artifactory.webapp.servlet.AccessFilter.doFilterInternal(AccessFilter.java:190) [artifactory-web-application-3.9.2.jar:na]
	at org.artifactory.webapp.servlet.AccessFilter.doFilter(AccessFilter.java:152) [artifactory-web-application-3.9.2.jar:na]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) [catalina.jar:7.0.56]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) [catalina.jar:7.0.56]
	at org.artifactory.webapp.servlet.RequestFilter.doFilter(RequestFilter.java:67) [artifactory-web-application-3.9.2.jar:na]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) [catalina.jar:7.0.56]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) [catalina.jar:7.0.56]
	at org.artifactory.webapp.servlet.ArtifactoryFilter.doFilter(ArtifactoryFilter.java:92) [artifactory-web-application-3.9.2.jar:na]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) [catalina.jar:7.0.56]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) [catalina.jar:7.0.56]
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220) [catalina.jar:7.0.56]
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122) [catalina.jar:7.0.56]
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170) [catalina.jar:7.0.56]
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103) [catalina.jar:7.0.56]
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116) [catalina.jar:7.0.56]
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:421) [catalina.jar:7.0.56]
	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1070) [tomcat-coyote.jar:7.0.56]
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611) [tomcat-coyote.jar:7.0.56]
	at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316) [tomcat-coyote.jar:7.0.56]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_51]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_51]
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-coyote.jar:7.0.56]
	at java.lang.Thread.run(Thread.java:745) [na:1.8.0_51]
Caused by: java.lang.reflect.InvocationTargetException: null
	at sun.reflect.GeneratedMethodAccessor141.invoke(Unknown Source) ~[na:na]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_51]
	at java.lang.reflect.Method.invoke(Method.java:497) ~[na:1.8.0_51]
	at org.apache.wicket.RequestListenerInterface.internalInvoke(RequestListenerInterface.java:260) ~[wicket-core-1.5.5.jar:1.5.5]
	... 40 common frames omitted
Caused by: java.lang.NullPointerException: null
	at org.quartz.CronExpression.getTimeAfter(CronExpression.java:1167) ~[quartz-2.2.1.jar:na]
	at org.quartz.CronExpression.getNextValidTimeAfter(CronExpression.java:334) ~[quartz-2.2.1.jar:na]
	at org.artifactory.webapp.wicket.util.CronUtils.isCronIntervalLessThanMinimum(CronUtils.java:99) ~[artifactory-web-application-3.9.2.jar:na]
	at org.artifactory.addon.replication.web.RepoReplicationBasePanel.shouldDisplayCronExpWarning(RepoReplicationBasePanel.java:213) ~[artifactory-addon-replication-3.9.2.jar:na]
	at org.artifactory.addon.replication.web.local.LocalRepoMultiReplicationPanel.setCronExpWarnLabel(LocalRepoMultiReplicationPanel.java:267) ~[artifactory-addon-replication-3.9.2.jar:na]
	at org.artifactory.addon.replication.web.local.LocalRepoMultiReplicationPanel.getFormComponent(LocalRepoMultiReplicationPanel.java:137) ~[artifactory-addon-replication-3.9.2.jar:na]
	at org.artifactory.addon.replication.web.local.LocalRepoMultiReplicationPanel.construct(LocalRepoMultiReplicationPanel.java:116) ~[artifactory-addon-replication-3.9.2.jar:na]
	at org.artifactory.addon.replication.web.local.LocalRepoMultiReplicationPanel.<init>(LocalRepoMultiReplicationPanel.java:92) ~[artifactory-addon-replication-3.9.2.jar:na]
	at org.artifactory.addon.replication.web.ReplicationWebAddonImpl$LocalRepoReplicationTab.getPanel(ReplicationWebAddonImpl.java:103) ~[artifactory-addon-replication-3.9.2.jar:na]
	at org.artifactory.addon.replication.web.ReplicationWebAddonImpl$LocalRepoReplicationTab.getPanel(ReplicationWebAddonImpl.java:1) ~[artifactory-addon-replication-3.9.2.jar:na]
	at org.artifactory.addon.replication.web.ReplicationWebAddonImpl$BaseRepoReplicationTab.getPanel(ReplicationWebAddonImpl.java:119) ~[artifactory-addon-replication-3.9.2.jar:na]
	at org.artifactory.addon.replication.web.ReplicationWebAddonImpl$BaseRepoReplicationTab.getPanel(ReplicationWebAddonImpl.java:1) ~[artifactory-addon-replication-3.9.2.jar:na]
	at org.artifactory.webapp.wicket.page.config.repos.RepoTabbedPanel.setSelectedTab(RepoTabbedPanel.java:51) ~[artifactory-web-application-3.9.2.jar:na]
	at org.artifactory.webapp.wicket.panel.tabbed.SubmittingTabbedPanel$1.onSubmit(SubmittingTabbedPanel.java:43) ~[artifactory-web-application-3.9.2.jar:na]
	at org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink$1.onSubmit(AjaxSubmitLink.java:68) ~[wicket-core-1.5.5.jar:1.5.5]
	at org.apache.wicket.ajax.form.AjaxFormSubmitBehavior$1.onSubmit(AjaxFormSubmitBehavior.java:172) ~[wicket-core-1.5.5.jar:1.5.5]
	at org.apache.wicket.markup.html.form.Form.delegateSubmit(Form.java:1151) ~[wicket-core-1.5.5.jar:1.5.5]
	at org.apache.wicket.markup.html.form.Form.process(Form.java:834) ~[wicket-core-1.5.5.jar:1.5.5]
	at org.apache.wicket.markup.html.form.Form.onFormSubmitted(Form.java:762) ~[wicket-core-1.5.5.jar:1.5.5]
	at org.apache.wicket.ajax.form.AjaxFormSubmitBehavior.onEvent(AjaxFormSubmitBehavior.java:158) ~[wicket-core-1.5.5.jar:1.5.5]
	at org.apache.wicket.ajax.AjaxEventBehavior.respond(AjaxEventBehavior.java:184) ~[wicket-core-1.5.5.jar:1.5.5]
	at org.apache.wicket.ajax.AbstractDefaultAjaxBehavior.onRequest(AbstractDefaultAjaxBehavior.java:369) ~[wicket-core-1.5.5.jar:1.5.5]
	... 44 common frames omitted

If you shut down the server, it will not start back up until you fix the config descriptor and import it by bootstrapping it.
Here is the error when trying to start without fixing the config:

2015-07-22 14:27:18,761 [art-init] [ERROR] (o.a.w.s.ArtifactoryContextConfigListener:96) - Application could not be initialized: Based on configured schedule, the given trigger 'DEFAULT.org.artifactory.repo.replication.LocalReplicationJob#1970d37c-5bca-4a04-8ed8-2f9a019611dc' will never fire.
java.lang.reflect.InvocationTargetException: null
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.8.0_51]
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[na:1.8.0_51]
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:1.8.0_51]
	at java.lang.reflect.Constructor.newInstance(Constructor.java:422) ~[na:1.8.0_51]
	at org.artifactory.webapp.servlet.ArtifactoryContextConfigListener.configure(ArtifactoryContextConfigListener.java:220) ~[artifactory-web-application-3.9.2.jar:na]
	at org.artifactory.webapp.servlet.ArtifactoryContextConfigListener.access$1(ArtifactoryContextConfigListener.java:180) ~[artifactory-web-application-3.9.2.jar:na]
	at org.artifactory.webapp.servlet.ArtifactoryContextConfigListener$1.run(ArtifactoryContextConfigListener.java:92) ~[artifactory-web-application-3.9.2.jar:na]
Caused by: java.lang.RuntimeException: Error in scheduling job: DEFAULT.org.artifactory.repo.replication.LocalReplicationJob#1970d37c-5bca-4a04-8ed8-2f9a019611dc
	at org.artifactory.schedule.quartz.QuartzTask.scheduleTask(QuartzTask.java:86) ~[artifactory-core-3.9.2.jar:na]
	at org.artifactory.schedule.TaskBase.schedule(TaskBase.java:89) ~[artifactory-storage-common-3.9.2.jar:na]
	at org.artifactory.schedule.TaskServiceImpl.onContextReady(TaskServiceImpl.java:111) ~[artifactory-core-3.9.2.jar:na]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_51]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_51]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_51]
	at java.lang.reflect.Method.invoke(Method.java:497) ~[na:1.8.0_51]
	at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317) ~[spring-aop-4.1.5.RELEASE.jar:4.1.5.RELEASE]
	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:201) ~[spring-aop-4.1.5.RELEASE.jar:4.1.5.RELEASE]
	at com.sun.proxy.$Proxy43.onContextReady(Unknown Source) ~[na:na]
	at org.artifactory.spring.ArtifactoryApplicationContext.setReady(ArtifactoryApplicationContext.java:399) ~[artifactory-core-3.9.2.jar:na]
	at org.artifactory.spring.ArtifactoryApplicationContext.refresh(ArtifactoryApplicationContext.java:231) ~[artifactory-core-3.9.2.jar:na]
	at org.artifactory.spring.ArtifactoryApplicationContext.<init>(ArtifactoryApplicationContext.java:114) ~[artifactory-core-3.9.2.jar:na]
	... 7 common frames omitted
Caused by: org.quartz.SchedulerException: Based on configured schedule, the given trigger 'DEFAULT.org.artifactory.repo.replication.LocalReplicationJob#1970d37c-5bca-4a04-8ed8-2f9a019611dc' will never fire.
	at org.quartz.core.QuartzScheduler.scheduleJob(QuartzScheduler.java:882) ~[quartz-2.2.1.jar:na]
	at org.quartz.impl.StdScheduler.scheduleJob(StdScheduler.java:249) ~[quartz-2.2.1.jar:na]
	at org.artifactory.schedule.quartz.QuartzTask.scheduleTask(QuartzTask.java:84) ~[artifactory-core-3.9.2.jar:na]
	... 19 common frames omitted


 Comments   
Comment by Avi Zaig (Inactive) [ 05/Jan/16 ]

The solution for versions below 4.2.0 is by modifying the config descriptor as described in the following:
https://www.jfrog.com/confluence/display/RTF/Configuration+Files#ConfigurationFiles-BootstrappingtheGlobalConfiguration

Need to remove any invalid cron expressions there and then to restart Artifactory again.

Generated at Tue Aug 11 16:57:52 UTC 2020 using Jira 8.5.3#805003-sha1:b4933e02eaff29a49114274fe59e1f99d9d963d7.