This issue has been created
There are 2 updates, 2 comments.
 
 
Formula pre-caching listener / cid:jira-generated-image-avatar-ed0eb8ca-7fe8-453d-95c6-ec0ed102ce85 FPLISTEN-2 Open

Listener fails with an exception on XWiki 15.10.10 (when formula macro is not installed)

 
View issue   ยท   Add comment
 

Issue created

 
cid:jira-generated-image-avatar-2a452345-37a9-4e2a-8883-f7af20b75ff1 Anca Luca created this issue on 08/Jun/24 13:18
 
Summary: Listener fails with an exception on XWiki 15.10.10 (when formula macro is not installed)
Issue Type: cid:jira-generated-image-avatar-ed0eb8ca-7fe8-453d-95c6-ec0ed102ce85 Bug
Affects Versions: 1.0
Assignee: Unassigned
Created: 08/Jun/24 13:18
Priority: cid:jira-generated-image-static-major-ea8869cf-708d-4e23-b113-302a3e565a32 Major
Reporter: Anca Luca
Description:

On XWiki 15.10.10, the formula macro is not bundled by default in the standard war.

The pre-cacher injects a formula macro but does not add it as a dependency. Thus, when installed on 15.10.10, it fails to initialize the job, with an exception in the logs:

2024-06-01 00:47:44,603 [XWiki initialization] ERROR r.f.i.FormulaPreCacherListener - Failed to start formula pre-caching job. 
org.xwiki.job.JobException: Failed to lookup any Job for role hint [formula.precache]
        at org.xwiki.job.internal.DefaultJobExecutor.createJob(DefaultJobExecutor.java:305)
        at org.xwiki.job.internal.DefaultJobExecutor.execute(DefaultJobExecutor.java:316)
        at org.xwiki.contrib.rendering.formula.internal.FormulaPreCacherListener.onEvent(FormulaPreCacherListener.java:87)
        at org.xwiki.observation.internal.DefaultObservationManager.notify(DefaultObservationManager.java:338)
        at org.xwiki.observation.internal.DefaultObservationManager.notify(DefaultObservationManager.java:303)
        at com.xpn.xwiki.internal.XWikiInitializerJob.runInternal(XWikiInitializerJob.java:117)
        at org.xwiki.job.AbstractJob.runInContext(AbstractJob.java:246)
        at org.xwiki.job.AbstractJob.run(AbstractJob.java:223)
        at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: org.xwiki.component.manager.ComponentLookupException: Failed to lookup component [org.xwiki.contrib.rendering.formula.internal.FormulaPreCachingJob] identified by type [interface org.xwiki.job.Job] and hint [formula.precache]
        at org.xwiki.component.embed.EmbeddableComponentManager.getInstance(EmbeddableComponentManager.java:332)
        at org.xwiki.component.embed.EmbeddableComponentManager.getInstance(EmbeddableComponentManager.java:320)
        at org.xwiki.component.embed.EmbeddableComponentManager.getInstance(EmbeddableComponentManager.java:302)
        at org.xwiki.component.internal.multi.DelegateComponentManager.getInstance(DelegateComponentManager.java:83)
        at org.xwiki.component.internal.multi.DelegateComponentManager.getInstance(DelegateComponentManager.java:83)
        at org.xwiki.component.internal.multi.DelegateComponentManager.getInstance(DelegateComponentManager.java:83)
        at org.xwiki.component.internal.multi.DelegateComponentManager.getInstance(DelegateComponentManager.java:83)
        at org.xwiki.component.internal.multi.DelegateComponentManager.getInstance(DelegateComponentManager.java:83)
        at org.xwiki.job.internal.DefaultJobExecutor.createJob(DefaultJobExecutor.java:303)
        ... 8 common frames omitted
Caused by: org.xwiki.component.manager.ComponentLookupException: Can't find descriptor for the component with type [interface org.xwiki.rendering.macro.Macro] and hint [formula]
        at org.xwiki.component.embed.EmbeddableComponentManager.getInstance(EmbeddableComponentManager.java:304)
        at org.xwiki.component.embed.EmbeddableComponentManager.getDependencyInstance(EmbeddableComponentManager.java:591)
        at org.xwiki.component.embed.EmbeddableComponentManager.createInstance(EmbeddableComponentManager.java:540)
        at org.xwiki.component.embed.EmbeddableComponentManager.getComponentInstance(EmbeddableComponentManager.java:642)
        at org.xwiki.component.embed.EmbeddableComponentManager.getInstance(EmbeddableComponentManager.java:329)
        ... 16 common frames omitted
2024-06-01 00:49:58,808 [com.xpn.xwiki.internal.WikiInitializerJob@6f35b7e0([initialization, wiki, <redacted>])] ERROR r.f.i.FormulaPreCacherListener - Failed to start formula pre-caching job. 
org.xwiki.job.JobException: Failed to lookup any Job for role hint [formula.precache]
        at org.xwiki.job.internal.DefaultJobExecutor.createJob(DefaultJobExecutor.java:305)
        at org.xwiki.job.internal.DefaultJobExecutor.execute(DefaultJobExecutor.java:316)
        at org.xwiki.contrib.rendering.formula.internal.FormulaPreCacherListener.onEvent(FormulaPreCacherListener.java:87)
        at org.xwiki.observation.internal.DefaultObservationManager.notify(DefaultObservationManager.java:338)
        at org.xwiki.observation.internal.DefaultObservationManager.notify(DefaultObservationManager.java:303)
        at com.xpn.xwiki.internal.WikiInitializerJob.runInternal(WikiInitializerJob.java:106)
        at org.xwiki.job.AbstractJob.runInContext(AbstractJob.java:246)
        at org.xwiki.job.AbstractJob.run(AbstractJob.java:223)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
        at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: org.xwiki.component.manager.ComponentLookupException: Failed to lookup component [org.xwiki.contrib.rendering.formula.internal.FormulaPreCachingJob] identified by type [interface org.xwiki.job.Job] and hint [formula.precache]
        at org.xwiki.component.embed.EmbeddableComponentManager.getInstance(EmbeddableComponentManager.java:332)
        at org.xwiki.component.embed.EmbeddableComponentManager.getInstance(EmbeddableComponentManager.java:320)
        at org.xwiki.component.embed.EmbeddableComponentManager.getInstance(EmbeddableComponentManager.java:302)
        at org.xwiki.component.internal.multi.DelegateComponentManager.getInstance(DelegateComponentManager.java:83)
        at org.xwiki.component.internal.multi.DelegateComponentManager.getInstance(DelegateComponentManager.java:83)
        at org.xwiki.component.internal.multi.DelegateComponentManager.getInstance(DelegateComponentManager.java:83)
        at org.xwiki.component.internal.multi.DelegateComponentManager.getInstance(DelegateComponentManager.java:83)
        at org.xwiki.component.internal.multi.DelegateComponentManager.getInstance(DelegateComponentManager.java:83)
        at org.xwiki.job.internal.DefaultJobExecutor.createJob(DefaultJobExecutor.java:303)
        ... 10 common frames omitted
Caused by: org.xwiki.component.manager.ComponentLookupException: Can't find descriptor for the component with type [interface org.xwiki.rendering.macro.Macro] and hint [formula]
        at org.xwiki.component.embed.EmbeddableComponentManager.getInstance(EmbeddableComponentManager.java:304)
        at org.xwiki.component.embed.EmbeddableComponentManager.getDependencyInstance(EmbeddableComponentManager.java:591)
        at org.xwiki.component.embed.EmbeddableComponentManager.createInstance(EmbeddableComponentManager.java:540)
        at org.xwiki.component.embed.EmbeddableComponentManager.getComponentInstance(EmbeddableComponentManager.java:642)
        at org.xwiki.component.embed.EmbeddableComponentManager.getInstance(EmbeddableComponentManager.java:329)
        ... 18 common frames omitted
 
 

2 updates

 
cid:jira-generated-image-avatar-2a452345-37a9-4e2a-8883-f7af20b75ff1 Changes by Anca Luca on 08/Jun/24 13:18
 
Fix Version: 1.1
Assignee: Anca Luca
 
 

2 comments

 
cid:jira-generated-image-avatar-2a452345-37a9-4e2a-8883-f7af20b75ff1 Anca Luca on 08/Jun/24 13:25
 

Since the listener is registered globally and ran on all wikis (because of XCOMMONS-213) , and the job is instantiated in the class loader of the wiki where the pre-cacher is installed, we have multiple ways to fix this:

  • either add the formula macro as a dependency and install one instance of the pre-cacher on each of the wikis on which the formula macro is installed; however, it will run globally on all wikis, because this is how listeners work ( XCOMMONS-213 )
  • either lookup the formula macro dynamically on current wiki for which is the listener is ran and only run the pre-cacher job if the formula macro is available
  • or find a way to execute the macro without using the formula macro.
 
cid:jira-generated-image-avatar-2a452345-37a9-4e2a-8883-f7af20b75ff1 Anca Luca on 08/Jun/24 13:27
 

I went for solution number 2 above, it was easier to implement.

I tried to use the MacroManager to get an instance of the formula macro but didn't manage to make it work as I needed to find a way to setup the context (which ?) in order for the CM used by the MacroManager to be the one corresponding to the current wiki. It's surely possible, I just didn't find how. The drawback in this implementation is that it uses the ComponentManagerManager which is internal, but so far so good.