[xwiki-users] Error: The Context Component Manager should only be used for read access.
I tried to follow the example code given in: http://extensions.xwiki.org/xwiki/bin/view/Extension/Create+a+component+usin... Saving and Viewing a page with the code without changes, I got a Groovy macro error with the following exception in the stack trace: java.lang.RuntimeException: The Context Component Manager should only be used for read access. Write operations should be done against specific Component Managers. Could anyone explain what this means, and why this error now appears? I'm using 6.3. I notice that the same error also currently shows up at http://platform.xwiki.org/xwiki/bin/view/SRD/ running 6.2.2 Thanks, Bryn
Hi Bryn, Apparently we broke backward compat and this is bad… We used to return the root Component Manager when calling Utils.getComponentManager() But it’s been modified and deprecated in XWiki 6.1M1 (http://jira.xwiki.org/browse/XWIKI-10352) to return the Context Component Manager. Now, the new way of registering components has been to use the Component Manager script service introduced in XWiki 4.1M2 (see http://extensions.xwiki.org/xwiki/bin/view/Extension/Component+Module#HAcces...). However I’ve just noticed that it’s also been modified to return the Context CM instead of the Root CM. This means there’s now no way to dynamically register a new component from Groovy without using a deprecated API… So right now the only workaround is to use the deprecated method: Utils.getRootComponentManager() I’ve created http://jira.xwiki.org/browse/XWIKI-11716 Thanks -Vincent On 27 Jan 2015 at 11:34:04, Bryn Jeffries ([email protected](mailto:[email protected])) wrote:
I tried to follow the example code given in: http://extensions.xwiki.org/xwiki/bin/view/Extension/Create+a+component+usin...
Saving and Viewing a page with the code without changes, I got a Groovy macro error with the following exception in the stack trace: java.lang.RuntimeException: The Context Component Manager should only be used for read access. Write operations should be done against specific Component Managers.
Could anyone explain what this means, and why this error now appears? I'm using 6.3. I notice that the same error also currently shows up at http://platform.xwiki.org/xwiki/bin/view/SRD/ running 6.2.2
Thanks,
Bryn
On Tue, Jan 27, 2015 at 11:55 AM, [email protected] <[email protected]> wrote:
Hi Bryn,
Apparently we broke backward compat and this is bad… We used to return the root Component Manager when calling Utils.getComponentManager()
But it’s been modified and deprecated in XWiki 6.1M1 (http://jira.xwiki.org/browse/XWIKI-10352) to return the Context Component Manager.
Now, the new way of registering components has been to use the Component Manager script service introduced in XWiki 4.1M2 (see http://extensions.xwiki.org/xwiki/bin/view/Extension/Component+Module#HAcces...).
However I’ve just noticed that it’s also been modified to return the Context CM instead of the Root CM.
This means there’s now no way to dynamically register a new component from Groovy without using a deprecated API…
You should look at the whole script service not only getComponentManager().
>>>>>>>>>>>>>>>>>>>>>>>>
/** * Retrieves the component manager associated with a specific namespace. The namespace is generally of the form * <code>prefix:subid</code> where <code>prefix</code> is used to find the proper factory. <code>:</code> can be * escaped using <code>\</code> and <code>\</code> need to be escaped as well. There is a namespace for each * document, space, wiki and user. E.g. 'wiki:drafts' is the namespace corresponding to the 'drafts' wiki. * Namespaces can be nested in which case they inherit from the parent namespace. E.g. the component manager for a * specific document has access to the components registered specifically for that document or for any of its * namespace ancestors (space, wiki, root). The root (top level) component manager is returned if you pass * {@code null}. * * @param namespace a namespace or {@code null} for the root {@link ComponentManager} * @return the component manager associated with the specified namespace, if any, {@code null otherwise} */ public ComponentManager getComponentManager(String namespace) <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< I.e. enforcing the best practice to explicitly indicate where exactly you want to register your component since most of the time you don't really want or need to register it from the whole farm.
So right now the only workaround is to use the deprecated method:
Utils.getRootComponentManager()
I’ve created http://jira.xwiki.org/browse/XWIKI-11716
Thanks -Vincent
On 27 Jan 2015 at 11:34:04, Bryn Jeffries ([email protected](mailto:[email protected])) wrote:
I tried to follow the example code given in: http://extensions.xwiki.org/xwiki/bin/view/Extension/Create+a+component+usin...
Saving and Viewing a page with the code without changes, I got a Groovy macro error with the following exception in the stack trace: java.lang.RuntimeException: The Context Component Manager should only be used for read access. Write operations should be done against specific Component Managers.
Could anyone explain what this means, and why this error now appears? I'm using 6.3. I notice that the same error also currently shows up at http://platform.xwiki.org/xwiki/bin/view/SRD/ running 6.2.2
Thanks,
Bryn
users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
-- Thomas Mortagne
Thanks Vincent, Using Utils.getRootComponentManager() worked for me, so many thanks. Even using a deprecated method lets me progress with the task. Bryn ________________________________ From: Vincent Massol [[email protected]] on behalf of [email protected] [[email protected]] Sent: 27 January 2015 21:55 To: XWiki Users Cc: Bryn Jeffries Subject: Re: [xwiki-users] Error: The Context Component Manager should only be used for read access. Hi Bryn, Apparently we broke backward compat and this is bad… We used to return the root Component Manager when calling Utils.getComponentManager() But it’s been modified and deprecated in XWiki 6.1M1 (http://jira.xwiki.org/browse/XWIKI-10352) to return the Context Component Manager. Now, the new way of registering components has been to use the Component Manager script service introduced in XWiki 4.1M2 (see http://extensions.xwiki.org/xwiki/bin/view/Extension/Component+Module#HAcces...). However I’ve just noticed that it’s also been modified to return the Context CM instead of the Root CM. This means there’s now no way to dynamically register a new component from Groovy without using a deprecated API… So right now the only workaround is to use the deprecated method: Utils.getRootComponentManager() I’ve created http://jira.xwiki.org/browse/XWIKI-11716 Thanks -Vincent
On 27 Jan 2015 at 12:02:01, Thomas Mortagne ([email protected](mailto:[email protected])) wrote:
On Tue, Jan 27, 2015 at 11:55 AM, [email protected] wrote:
Hi Bryn,
Apparently we broke backward compat and this is bad… We used to return the root Component Manager when calling Utils.getComponentManager()
But it’s been modified and deprecated in XWiki 6.1M1 (http://jira.xwiki.org/browse/XWIKI-10352) to return the Context Component Manager.
Now, the new way of registering components has been to use the Component Manager script service introduced in XWiki 4.1M2 (see http://extensions.xwiki.org/xwiki/bin/view/Extension/Component+Module#HAcces...).
However I’ve just noticed that it’s also been modified to return the Context CM instead of the Root CM.
This means there’s now no way to dynamically register a new component from Groovy without using a deprecated API…
You should look at the whole script service not only getComponentManager().
Indeed by bad, I checked but missed it.. Sorry about that. I’ve now documented it at: http://extensions.xwiki.org/xwiki/bin/view/Extension/Component+Module#HAcces... A real pity that issue http://jira.xwiki.org/browse/XWIKI-10352 has put N/A in the documentation field! That’s bad, it should have been documented at http://extensions.xwiki.org/xwiki/bin/view/Extension/Component+Module#HAcces... We still have broken some pretty important and used API. Thanks -Vincent
>>>>>>>>>>>>>>>>>>>>>>>>>
/** * Retrieves the component manager associated with a specific namespace. The namespace is generally of the form * prefix:subid where prefix is used to find the proper factory. : can be * escaped using \ and \ need to be escaped as well. There is a namespace for each * document, space, wiki and user. E.g. 'wiki:drafts' is the namespace corresponding to the 'drafts' wiki. * Namespaces can be nested in which case they inherit from the parent namespace. E.g. the component manager for a * specific document has access to the components registered specifically for that document or for any of its * namespace ancestors (space, wiki, root). The root (top level) component manager is returned if you pass * {@code null}. * * @param namespace a namespace or {@code null} for the root {@link ComponentManager} * @return the component manager associated with the specified namespace, if any, {@code null otherwise} */ public ComponentManager getComponentManager(String namespace)
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
I.e. enforcing the best practice to explicitly indicate where exactly you want to register your component since most of the time you don't really want or need to register it from the whole farm.
So right now the only workaround is to use the deprecated method:
Utils.getRootComponentManager()
I’ve created http://jira.xwiki.org/browse/XWIKI-11716
Thanks -Vincent
On 27 Jan 2015 at 11:34:04, Bryn Jeffries ([email protected](mailto:[email protected])) wrote:
I tried to follow the example code given in: http://extensions.xwiki.org/xwiki/bin/view/Extension/Create+a+component+usin...
Saving and Viewing a page with the code without changes, I got a Groovy macro error with the following exception in the stack trace: java.lang.RuntimeException: The Context Component Manager should only be used for read access. Write operations should be done against specific Component Managers.
Could anyone explain what this means, and why this error now appears? I'm using 6.3. I notice that the same error also currently shows up at http://platform.xwiki.org/xwiki/bin/view/SRD/ running 6.2.2
Thanks,
Bryn
users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
-- Thomas Mortagne _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
On 27 Jan 2015 at 12:14:28, Bryn Jeffries ([email protected](mailto:[email protected])) wrote:
Thanks Vincent,
Using Utils.getRootComponentManager() worked for me, so many thanks. Even using a deprecated method lets me progress with the task.
The recommended way is the one I’ve now documented at http://extensions.xwiki.org/xwiki/bin/view/Extension/Component+Module#HAcces... Thanks -Vincent
Bryn
From: Vincent Massol [[email protected]] on behalf of [email protected] [[email protected]] Sent: 27 January 2015 21:55 To: XWiki Users Cc: Bryn Jeffries Subject: Re: [xwiki-users] Error: The Context Component Manager should only be used for read access.
Hi Bryn,
Apparently we broke backward compat and this is bad… We used to return the root Component Manager when calling Utils.getComponentManager()
But it’s been modified and deprecated in XWiki 6.1M1 (http://jira.xwiki.org/browse/XWIKI-10352) to return the Context Component Manager.
Now, the new way of registering components has been to use the Component Manager script service introduced in XWiki 4.1M2 (see http://extensions.xwiki.org/xwiki/bin/view/Extension/Component+Module#HAcces...).
However I’ve just noticed that it’s also been modified to return the Context CM instead of the Root CM.
This means there’s now no way to dynamically register a new component from Groovy without using a deprecated API…
So right now the only workaround is to use the deprecated method:
Utils.getRootComponentManager()
I’ve created http://jira.xwiki.org/browse/XWIKI-11716
Thanks -Vincent
Vincent said:
Using Utils.getRootComponentManager() worked for me, so many thanks. Even using a deprecated method lets me progress with the task.
The recommended way is the one I’ve now documented at http://extensions.xwiki.org/xwiki/bin/view/Extension/Component+Module#HAcces...
Thanks very much. Using services.component.getComponentManager(null) worked fine. FWIW I see that the the related problem I observed on your website http://platform.xwiki.org/xwiki/bin/view/SRD/ was down to Utils.getComponentManager() being called from AppWithinMinutes.DynamicMessageTool, which has since been updated in XWiki 6.3. It might be worth backporting a fix so that we can access the mentioned page. Again, many thanks for the prompt help and responses. Bryn
Hi Bryn, On 27 Jan 2015 at 19:34:14, Bryn Jeffries ([email protected](mailto:[email protected])) wrote:
Vincent said:
Using Utils.getRootComponentManager() worked for me, so many thanks. Even using a deprecated method lets me progress with the task.
The recommended way is the one I’ve now documented at http://extensions.xwiki.org/xwiki/bin/view/Extension/Component+Module#HAcces...
Thanks very much. Using services.component.getComponentManager(null) worked fine. FWIW I see that the the related problem I observed on your website http://platform.xwiki.org/xwiki/bin/view/SRD/ was down to Utils.getComponentManager() being called from AppWithinMinutes.DynamicMessageTool, which has since been updated in XWiki 6.3. It might be worth backporting a fix so that we can access the mentioned page.
Fixed, thanks -Vincent
Again, many thanks for the prompt help and responses.
Bryn
participants (3)
-
Bryn Jeffries -
Thomas Mortagne -
vincent@massol.net