Uploaded image for project: 'Content Tags'
  1. Content Tags
  2. CONTTAGS-131

In a Public instance, Magnolia Context is not set when publishing tags

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Normal Normal
    • 2.0.5
    • 2.0.4
    • None
    • Yes
    • 3
    • Yes

      When a node is created the MgnlContext is used to find out the current user so that this can be entered in "mgnl:createdBy". Since this EventListener is asynchronous it is detached from the request and there is no MgnlContext. This then leads to the following error:

      2023-02-23 12:17:32,611 ERROR info.magnolia.context.MgnlContext : MgnlContext is not initialized. This could happen if the request does not go through the Magnolia default filters.
      java.lang.IllegalStateException: MgnlContext is not set for this thread
      

      Reproduce

      • Open Tour App, edit a tour, add a new tag & save.
      • Publish the tour.
      • Observe the error in the public log.

      Expected
      The tour can be published without creating an error.

      Actual
      Exception thrown in the public log.

      INFO  info.magnolia.publishing.receiver.operation.jcr.JcrPublicationOperation 22.05.2023 13:16:34 -- About to update content under path [/magnolia-travels/Vietnam--Tradition-and-Today].
      INFO  info.magnolia.publishing.transactional.receiver.operation.jcr.JcrTransactionPublicationOperation 22.05.2023 13:16:34 -- 608 User superuser successfully published tours:/magnolia-travels/Vietnam--Tradition-and-Today on ROOT.
      ERROR info.magnolia.context.MgnlContext 22.05.2023 13:16:35 -- MgnlContext is not initialized. This could happen if the request does not go through the Magnolia default filters.
      java.lang.IllegalStateException: MgnlContext is not set for this thread
      	at info.magnolia.context.MgnlContext.getInstance(MgnlContext.java:282) ~[magnolia-core-6.2.34.jar:?]
      	at info.magnolia.context.MgnlContext.getUser(MgnlContext.java:91) ~[magnolia-core-6.2.34.jar:?]
      	at info.magnolia.jcr.wrapper.MgnlPropertySettingContentDecorator.getCurrentUserName(MgnlPropertySettingContentDecorator.java:728) ~[magnolia-core-6.2.34.jar:?]
      	at info.magnolia.jcr.wrapper.MgnlPropertySettingContentDecorator.updateLastModified(MgnlPropertySettingContentDecorator.java:622) ~[magnolia-core-6.2.34.jar:?]
      	at info.magnolia.jcr.wrapper.MgnlPropertySettingContentDecorator.updateLastModified(MgnlPropertySettingContentDecorator.java:627) ~[magnolia-core-6.2.34.jar:?]
      	at info.magnolia.jcr.wrapper.MgnlPropertySettingNodeWrapper.updateLastModified(MgnlPropertySettingNodeWrapper.java:262) ~[magnolia-core-6.2.34.jar:?]
      	at info.magnolia.jcr.wrapper.MgnlPropertySettingNodeWrapper.addNode(MgnlPropertySettingNodeWrapper.java:214) ~[magnolia-core-6.2.34.jar:?]
      	at info.magnolia.jcr.wrapper.DelegateNodeWrapper.addNode(DelegateNodeWrapper.java:129) ~[magnolia-core-6.2.34.jar:?]
      	at info.magnolia.jcr.decoration.ContentDecoratorNodeWrapper.addNode(ContentDecoratorNodeWrapper.java:131) ~[magnolia-core-6.2.34.jar:?]
      	at info.magnolia.audit.MgnlAuditLoggingContentDecoratorNodeWrapper.addNode(MgnlAuditLoggingContentDecoratorNodeWrapper.java:84) ~[magnolia-core-6.2.34.jar:?]
      	at info.magnolia.jcr.wrapper.DelegateNodeWrapper.addNode(DelegateNodeWrapper.java:129) ~[magnolia-core-6.2.34.jar:?]
      	at info.magnolia.jcr.decoration.ContentDecoratorNodeWrapper.addNode(ContentDecoratorNodeWrapper.java:131) ~[magnolia-core-6.2.34.jar:?]
      	at info.magnolia.jcr.wrapper.MagnoliaSessionContentDecorator$1.addNode(MagnoliaSessionContentDecorator.java:67) ~[magnolia-core-6.2.34.jar:?]
      	at info.magnolia.jcr.util.NodeUtil.createPath(NodeUtil.java:637) ~[magnolia-core-6.2.34.jar:?]
      	at info.magnolia.contenttags.manager.TagManager.getOrCreate(TagManager.java:168) ~[magnolia-content-tags-core-2.0.4.jar:?]
      	at info.magnolia.contenttags.manager.TagManager.getOrCreateTag(TagManager.java:162) ~[magnolia-content-tags-core-2.0.4.jar:?]
      	at info.magnolia.contenttags.TagsModule.lambda$null$1(TagsModule.java:142) ~[magnolia-content-tags-core-2.0.4.jar:?]
      	at info.magnolia.observation.DeferringEventListener$ObservationBasedDelayedExecutor$1.run(DeferringEventListener.java:102) [magnolia-core-6.2.34.jar:?]
      	at info.magnolia.cms.util.DelayedExecutor$RunnableWrapper.run(DelayedExecutor.java:103) [magnolia-core-6.2.34.jar:?]
      	at EDU.oswego.cs.dl.util.concurrent.ClockDaemon$RunLoop.run(Unknown Source) [concurrent-1.3.4.jar:?]
      	at java.lang.Thread.run(Thread.java:829) [?:?]
      

      Notes
      Could also be related to CONTTAGS-130

        Acceptance criteria

              ricardo.gonzalez ricardo gonzalez
              rgange Richard Gange
              AuthorX
              Votes:
              2 Vote for this issue
              Watchers:
              7 Start watching this issue

                Created:
                Updated:
                Resolved:
                Work Started:

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - Not Specified
                  Not Specified
                  Logged:
                  Time Spent - 0.25d
                  0.25d