Weceem

Save HTML node throws NullPointerException

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 0.9
  • Fix Version/s: 0.9.1
  • Component/s: None
  • Labels:
    None
  • Environment:
    CentOs (Linux), MySQL
  • Request Controller:
    Please Select
  • External Supervisor:
    Please select
  • Executing Programmer:
    Please select

Description

Upgraded a production site from 0.8 to 0.9 and edited a lot of templates and HTML content without problem, then suddenly this exception was thrown.
It's isolated to a specific WcmHTMLContent node. I haven't tried to edit all HTML nodes but I know I can edit some of them without problem, but this one is impossible to save.

java.lang.NullPointerException
at org.weceem.content.WcmContent.saveRevision(WcmContent.groovy:269)
at org.weceem.content.WcmContent$saveRevision$2.call(Unknown Source)
at org.weceem.content.WcmContent$saveRevision$1.call(Unknown Source)
at org.weceem.services.WcmContentRepositoryService.updateNode(WcmContentRepositoryService.groovy:865)
at org.weceem.services.WcmContentRepositoryService$updateNode$4.callCurrent(Unknown Source)
at org.weceem.services.WcmContentRepositoryService$updateNode$3.callCurrent(Unknown Source)
at org.weceem.services.WcmContentRepositoryService.updateNode(WcmContentRepositoryService.groovy:833)
at org.weceem.services.WcmContentRepositoryService$$FastClassByCGLIB$$5c4c6ef.invoke(<generated>)
at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
at org.weceem.services.WcmContentRepositoryService$$EnhancerByCGLIB$$9863a455.updateNode(<generated>)
at org.weceem.services.WcmContentRepositoryService$updateNode$1.call(Unknown Source)
at org.weceem.controllers.WcmEditorController$_closure8_closure15.doCall(WcmEditorController.groovy:105)
at $Proxy13.doInTransaction(Unknown Source)
at org.weceem.controllers.WcmEditorController$_closure8.doCall(WcmEditorController.groovy:104)
at org.weceem.controllers.WcmEditorController$_closure8.doCall(WcmEditorController.groovy)

Activity

Hide
Göran Ehrsson added a comment - 27/Jul/10 10:13 PM

I suspected it had something to do with the content of wcm_content_version table not being updated in the same way as wcm_content during upgrade.
(http://www.weceem.org/weceem/documentation/Installation only tell you to update the wcm_content table)
So I updated wcm_content_version using the statements below, but that did not help. Same exception when saving the node.

UPDATE wcm_content_version SET object_class_name = 'org.weceem.blog.WcmBlog' WHERE object_class_name = 'org.weceem.blog.Blog';
UPDATE wcm_content_version SET object_class_name = 'org.weceem.blog.WcmBlogEntry' WHERE object_class_name = 'org.weceem.blog.BlogEntry';
UPDATE wcm_content_version SET object_class_name = 'org.weceem.content.WcmComment' WHERE object_class_name = 'org.weceem.content.Comment';
UPDATE wcm_content_version SET object_class_name = 'org.weceem.content.WcmFolder' WHERE object_class_name = 'org.weceem.content.Folder';
UPDATE wcm_content_version SET object_class_name = 'org.weceem.content.WcmTemplate' WHERE object_class_name = 'org.weceem.content.Template';
UPDATE wcm_content_version SET object_class_name = 'org.weceem.content.WcmVirtualContent' WHERE object_class_name = 'org.weceem.content.VirtualContent';
UPDATE wcm_content_version SET object_class_name = 'org.weceem.content.WcmWidget' WHERE object_class_name = 'org.weceem.content.Widget';
UPDATE wcm_content_version SET object_class_name = 'org.weceem.css.WcmStyleSheet' WHERE object_class_name = 'org.weceem.css.StyleSheet';
UPDATE wcm_content_version SET object_class_name = 'org.weceem.files.WcmContentDirectory' WHERE object_class_name = 'org.weceem.files.ContentDirectory';
UPDATE wcm_content_version SET object_class_name = 'org.weceem.files.WcmContentFile' WHERE object_class_name = 'org.weceem.files.ContentFile';
UPDATE wcm_content_version SET object_class_name = 'org.weceem.html.WcmHTMLContent' WHERE object_class_name = 'org.weceem.html.HTMLContent';
UPDATE wcm_content_version SET object_class_name = 'org.weceem.js.WcmJavaScript' WHERE object_class_name = 'org.weceem.js.JavaScript';
UPDATE wcm_content_version SET object_class_name = 'org.weceem.content.WcmExternalLink' WHERE object_class_name = 'org.weceem.content.ExternalLink';
UPDATE wcm_content_version SET object_class_name = 'org.weceem.wiki.WikiItem' WHERE object_class_name = 'org.weceem.wiki.WcmWikiItem';

Show
Göran Ehrsson added a comment - 27/Jul/10 10:13 PM I suspected it had something to do with the content of wcm_content_version table not being updated in the same way as wcm_content during upgrade. (http://www.weceem.org/weceem/documentation/Installation only tell you to update the wcm_content table) So I updated wcm_content_version using the statements below, but that did not help. Same exception when saving the node. UPDATE wcm_content_version SET object_class_name = 'org.weceem.blog.WcmBlog' WHERE object_class_name = 'org.weceem.blog.Blog'; UPDATE wcm_content_version SET object_class_name = 'org.weceem.blog.WcmBlogEntry' WHERE object_class_name = 'org.weceem.blog.BlogEntry'; UPDATE wcm_content_version SET object_class_name = 'org.weceem.content.WcmComment' WHERE object_class_name = 'org.weceem.content.Comment'; UPDATE wcm_content_version SET object_class_name = 'org.weceem.content.WcmFolder' WHERE object_class_name = 'org.weceem.content.Folder'; UPDATE wcm_content_version SET object_class_name = 'org.weceem.content.WcmTemplate' WHERE object_class_name = 'org.weceem.content.Template'; UPDATE wcm_content_version SET object_class_name = 'org.weceem.content.WcmVirtualContent' WHERE object_class_name = 'org.weceem.content.VirtualContent'; UPDATE wcm_content_version SET object_class_name = 'org.weceem.content.WcmWidget' WHERE object_class_name = 'org.weceem.content.Widget'; UPDATE wcm_content_version SET object_class_name = 'org.weceem.css.WcmStyleSheet' WHERE object_class_name = 'org.weceem.css.StyleSheet'; UPDATE wcm_content_version SET object_class_name = 'org.weceem.files.WcmContentDirectory' WHERE object_class_name = 'org.weceem.files.ContentDirectory'; UPDATE wcm_content_version SET object_class_name = 'org.weceem.files.WcmContentFile' WHERE object_class_name = 'org.weceem.files.ContentFile'; UPDATE wcm_content_version SET object_class_name = 'org.weceem.html.WcmHTMLContent' WHERE object_class_name = 'org.weceem.html.HTMLContent'; UPDATE wcm_content_version SET object_class_name = 'org.weceem.js.WcmJavaScript' WHERE object_class_name = 'org.weceem.js.JavaScript'; UPDATE wcm_content_version SET object_class_name = 'org.weceem.content.WcmExternalLink' WHERE object_class_name = 'org.weceem.content.ExternalLink'; UPDATE wcm_content_version SET object_class_name = 'org.weceem.wiki.WikiItem' WHERE object_class_name = 'org.weceem.wiki.WcmWikiItem';
Hide
Göran Ehrsson added a comment - 27/Jul/10 10:31 PM

Sorry, my fault! (or incomplete upgrade notes)

The offending node was a custom node type derived from WcmHTMLContent.
In 0.9 you must override getContentAsText() and getContentAsHTML() in custom node types. This is commented in the source but I did not find any info in the upgrade notes.

/**

  • Must be overriden by content types that can represent their content as text.
  • Used for search results and versioning
    */
    public String getContentAsText() { ContentUtils.htmlToText(content) }

/**

  • Should be overriden by content types that can represent their content as HTML.
  • Used for wcm:content tag (content rendering)
    */
    public String getContentAsHTML() { content }
Show
Göran Ehrsson added a comment - 27/Jul/10 10:31 PM Sorry, my fault! (or incomplete upgrade notes) The offending node was a custom node type derived from WcmHTMLContent. In 0.9 you must override getContentAsText() and getContentAsHTML() in custom node types. This is commented in the source but I did not find any info in the upgrade notes. /**
  • Must be overriden by content types that can represent their content as text.
  • Used for search results and versioning */ public String getContentAsText() { ContentUtils.htmlToText(content) }
/**
  • Should be overriden by content types that can represent their content as HTML.
  • Used for wcm:content tag (content rendering) */ public String getContentAsHTML() { content }
Hide
Marc Palmer added a comment - 28/Jul/10 8:44 AM

Investigate - we may be missing a null check

Show
Marc Palmer added a comment - 28/Jul/10 8:44 AM Investigate - we may be missing a null check
Hide
Marc Palmer added a comment - 28/Jul/10 11:22 AM

Caused by incorrect extension of WcmHTMLContent class. Added some more robustness to versioning to survive it

Show
Marc Palmer added a comment - 28/Jul/10 11:22 AM Caused by incorrect extension of WcmHTMLContent class. Added some more robustness to versioning to survive it

People

Vote (0)
Watch (0)

Dates

  • Created:
    27/Jul/10 9:48 PM
    Updated:
    28/Jul/10 11:22 AM
    Resolved:
    28/Jul/10 11:22 AM