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

  1. Scale down Magnolia to 0 instances.

    You can stop or scale down directly from the Cockpit.
  2. Open /<CATALINA_HOME>/webapps/<contextPath>/WEB-INF/web.xml in a text editor.

  3. Comment out the filter and filter-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>
    -->
  4. 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>
  1. 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>.
  2. Save the web.xml file.

  3. Start Magnolia.

    You can start Magnolia directly from the Cockpit.
  4. Open a Web browser and access the Groovy Rescue App at http://host/<contextPath>.

    image

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.

  1. Assign Session of config repository to session.

    session = ctx.getJCRSession('config')
  2. Assign the parent node content to root.

    root = session.getNode('/modules/someModule/virtualURIMapping/')
  3. Get and remove the child node untitled.

    root.getNode('untitled').remove()
  4. 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

  1. In the web.xml file, remove the servlet registration lines you added above.

  2. Remove comments from the filter and filter-mapping sections.

  3. Save the web.xml file.

  4. Scale down your instance to 0.

  5. Start Magnolia again.

Feedback