Error Renaming A Page

Still need help?

The Atlassian Community is here for you.

Ask the community

Symptoms

When renaming a page in Confluence you get the following exception -


2008-12-22 17:36:20,747 ERROR [http-80-Processor7] [com.opensymphony.xwork.ActionSupport] doSaveEditPageBean An error occured while storing the requested page!
 -- url: /pages/doeditpage.action | userName: adminxiei | action: doeditpage | page: 61178183 | referrer: http://localhost/pages/editpage.action?pageId=61178183
java.lang.NullPointerException
	at com.atlassian.confluence.util.AttachmentLinkRenamingBean.getReplacingLinkPageTitle(AttachmentLinkRenamingBean.java:120)
	at com.atlassian.confluence.util.AttachmentLinkRenamingBean.<init>(AttachmentLinkRenamingBean.java:62)
	at com.atlassian.confluence.links.DefaultLinkManager.getContentWithRenamedLinks(DefaultLinkManager.java:151)
        .........
	at $Proxy9.getContentWithRenamedLinks(Unknown Source)
	at com.atlassian.confluence.core.DefaultContentEntityManager.updateSingleContentLinkinTo(DefaultContentEntityManager.java:212)
	at com.atlassian.confluence.core.DefaultContentEntityManager.updateContentLinkingTo(DefaultContentEntityManager.java:197)

While Renaming a page Confluence will update links on a given page to reflect a change to an attachment links, the AttachmentLinkRenamingBean is responsible for updating the Page name -


private String getReplacingLinkPageTitle(ContentEntityObject referringContent, String spaceKey, String pageTitle)
    {
        if (referringContent instanceof SpaceContentEntityObject)
        {
            if (!((SpaceContentEntityObject) referringContent).getSpaceKey().equals(spaceKey))
            {
                return spaceKey + ":" + pageTitle;
            }
        }

        return StringUtils.equals(referringContent.getTitle(), pageTitle) ? "" : pageTitle;
    }

The line throwing the NPE is:


if (!((SpaceContentEntityObject) referringContent).getSpaceKey().equals(spaceKey))

The getSpaceKey() method is returning null - because there is a link (on a page with nospace) to an attachment on the page being renamed.

Cause

The root cause us that in a previous version the page or attachment was in a Space which no longer exists. The page was moved from another space, and when the original space was deleted, Confluence updated references to the space with null values.

Resolution

Since its is not possible to delete the page version history of a page at this siage - the only option here is to find the attachment causing the exception by enabling SQL logging, delete the attachment on that page and reattach it after performing the rename.

If deleting the attachment does not work, you can try to find the offending link from the database:


select * from links where destpagetitle='faulty page title' and destspacekey = 'the space key of the faulty page';
delete from links where linkid=<linkid>;

(info) <linkid> is the linkid returned from the select query.


Last modified on Mar 30, 2016

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.