Rescue App
The MgnlGroovyRescueApp
is a special Vaadin app that can be used to bypass the Magnolia filter chain. This is useful when you need to perform rescue operations on a corrupted Magnolia instance or when the Magnolia UI is not loading. To enable the servlet you must explicitly comment out the Magnolia filter chain in the web.xml
file and register the Groovy Rescue App.
All operations performed in the Groovy Rescue App are executed in system context, meaning no security restrictions are enforced. This might expose your data to risk of irreversible damages if you are not aware of what you are doing. In other words, use it at your own risk. |
There are three steps to using the Rescue App:
Register the Groovy Rescue App
-
Scale down Magnolia to
0
instances.You can stop or scale down directly from the Cockpit. -
Open
/<CATALINA_HOME>/webapps/<contextPath>/WEB-INF/web.xml
in a text editor. -
Comment out the
filter
andfilter-mapping
sections as shown in the example below:<!-- <filter> <display-name>Magnolia global filters</display-name> <filter-name>magnoliaFilterChain</filter-name> <filter-class>info.magnolia.cms.filters.MgnlMainFilter</filter-class> </filter> <filter-mapping> <filter-name>magnoliaFilterChain</filter-name> <url-pattern>*</url-pattern> <dispatcher>REQUEST</dispatcher> <dispatcher>FORWARD</dispatcher> <dispatcher>ERROR</dispatcher> </filter-mapping> -->
-
Add the following lines to the
web.xml
file in order to register the Groovy Rescue App:<servlet> <servlet-name>Vaadin</servlet-name> <servlet-class>com.vaadin.server.VaadinServlet</servlet-class> <init-param> <description>Groovy Rescue App</description> <param-name>UI</param-name> <param-value>info.magnolia.module.groovy.rescue.MgnlGroovyRescueApp</param-value> </init-param> <init-param> <param-name>widgetset</param-name> <!-- <param-value>info.magnolia.widgetset.MagnoliaWidgetSet</param-value> --> <!-- <param-value>info.magnolia.widgetset.MagnoliaProWidgetSet</param-value> --> </init-param> </servlet> <servlet-mapping> <servlet-name>Vaadin</servlet-name> <url-pattern>/*</url-pattern> </servlet-mapping>
-
Uncomment the following line:
<init-param> <param-name>widgetset</param-name> <!-- <param-value>info.magnolia.widgetset.MagnoliaWidgetSet</param-value> --> <!-- <param-value>info.magnolia.widgetset.MagnoliaProWidgetSet</param-value> --> (1) </init-param>
1 Uncomment <param-value>info.magnolia.widgetset.MagnoliaProWidgetSet</param-value>
. -
Save the
web.xml file
. -
Start Magnolia.
You can start Magnolia directly from the Cockpit. -
Open a Web browser and access the Groovy Rescue App at
http://host/<contextPath>
.
Make the required changes
Use Groovy commands to navigate to the data you want to change.
Example 1: Deleting an erroneous configuration node untitled
from /config/modules/someModule/virtualURIMapping
.
-
Assign
Session
ofconfig
repository tosession
.session = ctx.getJCRSession('config')
-
Assign the parent node content to
root
.root = session.getNode('/modules/someModule/virtualURIMapping/')
-
Get and remove the child node
untitled
.root.getNode('untitled').remove()
-
Save the session.
session.save()
Always remember to save the session after modifying a node.
Example 2: Disabling the I18nContentSupportFilter
filter.
mgnl> session = ctx.getJCRSession('config')
====> session-admin-213
mgnl> root = session.getNode('/server/filters/i18n') (1)
====> node /server/filters/i18n
mgnl> root.getProperty('enabled').getString() (2)
====> true
mgnl> root.setProperty('enabled', 'false') (3)
====> property /server/filters/i18n/enabled
mgnl> root.getProperty('enabled').getString() (4)
====> false
mgnl> session.save() (5)
1 | Assign the content of the /server/filters/i18n node to root . |
2 | Check the current setting of the enabled property. |
3 | Set the property to false . |
4 | Verify that the configuration has been changed. |
5 | Save the session. |
Example 3: Reset superuser password.
session = MgnlContext.getJCRSession('users')
superuser = session.getNode('/system/superuser')
superuser.pswd = info.magnolia.cms.security.SecurityUtil.getBCrypt('superuser')
session.save()
Deregister the Groovy Rescue App
-
In the
web.xml
file, remove the servlet registration lines you added above. -
Remove comments from the filter and filter-mapping sections.
-
Save the
web.xml
file. -
Scale down your instance to
0
. -
Start Magnolia again.