Skip to main content link. Accesskey S
  • Log In
  • Help
  • IBM Logo
  • WebSphere Portal Family wiki
  • All Wikis
  • All Forums
  • Home
  • Product Documentation
  • Community Articles
  • Learning Center
  • IBM Redbooks
Community Articles Product Documentation Learning Center IBM Redbooks This category IBM Redbooks: Building a Sample Website Using IBM Web Content Manager 7.0 IBM Redbooks: Building and Implementing a Social Portal IBM Redbooks: Developing Exceptional Multi-Channel Web Experiences V7: IBM Web Content Manager Product Documentation V7: IBM WebSphere Portal Enable for z/OS Product Documentation V7: IBM WebSphere Portal Express Product Documentation V7: WebSphere Portal Product Documentation V8: IBM Web Content Manager Product Documentation V8: IBM WebSphere Portal Express Product Documentation V8: IBM WebSphere Portal Product Documentation (includes z/OS) Custom Search Scope...
Search
  • New Article
  • Share Show Menu▼
  • Subscribe Show Menu▼

About the Original Author

IBM contributorJohn Rickett
Contribution Summary:
  • Articles authored: 3
  • Articles edited: 2
  • Comments Posted: 7

Recent articles by this author

How to create a servlet to use WCM API to serve File Resource Component Files

Step by Step instructions for creating a servlet to serve WCM File Resource Component Files

Troubleshooting WCM API, How To, and Sample Code

Troubleshooting common issues with the WCM API. Sample code and How To instructions.

Troubleshooting steps and FAQs for Java Content Repository (JCR)

This article answers frequently asked questions (FAQs) and provides troubleshooting tips for Java Content Repository (JCR).

Learning Center articleTroubleshooting WCM API, How To, and Sample Code

Added by John Rickett | Edited by IBM contributor Sunil Bhatnagar on September 7, 2010 | Version 10
expanded Abstract
collapsed Abstract
Troubleshooting common issues with the WCM API. Sample code and How To instructions.
Tags: WCM API Troubleshooting HowTo Sample Code
ShowTable of Contents
HideTable of Contents
  • 1 Troubleshooting WCM API, How To, and Sample Code
    • 1.1 java.lang.NoSuchMethodError
    • 1.2 Custom applications work for Admin or anonymous users only
    • 1.3 Can't get a workspace for the current user in a JSP, have to use getSystemWorkspace
    • 1.4 OutofMemoryError OOM using WCM API
    • 1.5 java.lang.ClassCastException com.ibm.worlplace.wcm.api.WebContentServiceImpl
    • 1.6 How to get the approvers for the current stage in custom workflow
    • 1.7 How to get the URL to the file resource component embedded within a content item
    • 1.8 How to pass a parm parameter argument from html to jsp
    • 1.9 How to purge an item using WCM API
    • 1.10 Considerations using getUserPrinciple
    • 1.11 Quick Start WCM API Sample jsp using findbyname
    • 1.12 How to invoke the WCM API Remotely
    • 1.13 Web sites with sample implementation of WCM API
  • 2 About the author

Troubleshooting WCM API, How To, and Sample Code





java.lang.NoSuchMethodError



The error is most often caused by a failure to run the "update-wcm" task after installing a WCM Fix

Another common cause is the presence of a test fix compiled for a certain release level and left in place when a fix or fixpack is applied.

Another possible cause is a test fix or official APAR Fix that has been compiled with the wrong code base. Uninstall fix/fixes and run update-wcm task to correct.


SOLUTION:

Verify update-wcm task completed BUILD SUCCESSFUL after the last fix was installed or uninstalled

Search for old test fixes (for example an additional "com" directory) in .../websphere/Portalserver/wcm/prereq.wcm/wcm/shared/app

Also search the wcm portlets and wcm.ear directory under /installedApps

Custom applications work for Admin or anonymous users only



Typical symptoms:

-Content renders for Admin users only

-Using WCM API with jsp components. Content will render for anonymous users but not for All Users or All authenticated Users when logged in

-Custom applications work first time only for anonymous users

-IWKPY1015X IWKPY1016X When logged in with User Role on content and using API to access that content IWKPY1015X: Unauthorised access IWKPY1016X: Unauthorised access on Contents by

SOLUTION:

Call the API "workspace.useUserAccess(true)" before calling the workspace.getById() call , otherwise , the default access context is "Contributor".

See technote: http://www-01.ibm.com/support/docview.wss?uid=swg21388943

Can't get a workspace for the current user in a JSP, have to use getSystemWorkspace



The problem has to do with J2EE security basically, that the code that is running (JSP) is running outside of a J2EE security context so the user context can't be validated.

SOLUTION:

Only use initworkspace when a valid user context exists:

OutofMemoryError OOM using WCM API



There are often cases where the OutOfMemoryError is caused by the application processing too much data when using a StrongWorkspaceState.

SOLUTION:

1. Reduce the number of nodes processed per workspace
2. Manually clear the workspace state at an interval that can be handled by the system's memory
3. Use Weak workspace state

java.lang.ClassCastException com.ibm.worlplace.wcm.api.WebContentServiceImpl



This error may occur when creating a custom portlet that uses the WCM API.

May also see this error:

Com.ibm.workplace.wcm.api exceptions ServiceNotAvailableException

SOLUTION:

Need to remove illwcm jar files from the custom portlet

How to get the approvers for the current stage in custom workflow



The getCurrentApprovers() call should be invoked on the content or
document passed in to the custom action in the execute(Document p_document) method.

Only this object would contain the approvers for the current stage. In one case the customer was not using this object. Instead
they are using the object which was retrieved from the repository using the inWorkspace.getById() call (in WorkflowUtil class). The object retrieved from the repository would be the one from the previous save and hence it would contain all information for the first stage.

General process/pseudo code:

Get the docId of the content
Create a new Workspace
Set to use DN
Content myContent =(Content)ws.getById(thisId);
String approvers = myContent.getCurrentApprovers();

How to get the URL to the file resource component embedded within a content item



..
FileComponent myFile =
(FileComponent)content.getComponent(fileComponentName);
workspace.render(yourRenderingContext, myFile);
will return like /wps/wcm/myconnect/path/to/file/file.jpg?MOD=AJPERES
....

How to pass a parm parameter argument from html to jsp



Custom Reject Link

How to purge an item using WCM API



WCM run RemoveVersionHistory.execute(). Normally, to purge an item vi the API, three steps need to be executed:

RepositorRemove, RemoveVersionHistory, and UpdateEventLog.

Runstats on db if server hangs at executing RemoveVersionHistory. All item syndication sends versions by default but the versions can be disabled with a config option. Purging content takes a long time. Should be done off hours.

Considerations using getUserPrinciple



WCM keeps a list of the valid sessions anytime a wcm page has been accessed. For any newly created sessions, the user is taken from the request which is passed in from portal. If it is a portlet request wcm uses:

PortletRequest portletRequest = (PortletRequest) p_request;

user = portletRequest.getUser();

where p_request is a HttpServletRequest if it is a servlet request wcm uses:

Principal principal = p_request.getUserPrincipal();

The PortletRequest.getUserPrincipal() can be invoked directly on each PortletRequest object. There is no HTTP(Servlet)Request anywhere where it's safe to read the user from or cast the object. Inside a JSP e.g. View.jsp included by a portlets doView() method there is a context variable portletrequest after the the init tag was called. This request object also holds the user object.

If getUserPrincipal returns null (when invoking jsp via servlet) see:

http://www.ibm.com/developerworks/forums/thread.jspa?threadID=180190


Quick Start WCM API Sample jsp using findbyname



Create findbyname.jsp to contain the code pasted below. Change to the name of one or your library, authoring template and content items. Copy the file to

...\ibm\WebSphere\wp_profile\installedApps\\wcm.ear\ilwwcm.war\jsp\html

Run the jsp via this url:

http://hostname:port/wps/wcm/jsp/html/findbyname.jsp


JSP Contents:



<%@ page import="com.ibm.workplace.wcm.api.*"%>
<%@ page import="com.ibm.workplace.wcm.api.exceptions.*"%>
<%@ page import="java.util.*,javax.servlet.jsp.JspWriter,java.io.*"%>

<%

 try {

DocumentId docId=null;

DocumentIdIterator itemsIterator=null;

   Workspace myworkspace = WCM_API.getRepository().getSystemWorkspace();
   
   if ( myworkspace == null )    {
      out.println( "Unable to get a valid workspace.<br/>" );
   }
   else {
      out.println("Found workspace<br/>");
   }
   
   myworkspace.login();
 
   //Set the workspace to the correct library.
 
   DocumentLibrary MyLibrary = myworkspace.getDocumentLibrary("Test");
    
   if (MyLibrary == null)
   {
       out.println("Library is null<br/>");

   }
   else {
      
       out.println("<br/>My lib is not null");

       myworkspace.setCurrentDocumentLibrary(MyLibrary);
   }

   itemsIterator = myworkspace.findByName(DocumentTypes.AuthoringTemplate, "JSPAuthoringTemplate");

   docId = (DocumentId) itemsIterator.next();
    
   out.print("<br/><br/>Document id: " + docId.toString());

   itemsIterator = myworkspace.findByName(DocumentTypes.Content, "JSPContent");

   docId = (DocumentId) itemsIterator.next();
    
   out.print("<br/><br/>Document id: " + docId.toString());

   myworkspace.logout();
 }

 catch (Exception e) {

out.println("Exception " + e.getMessage());
e.printStackTrace();
 }

%>



How to invoke the WCM API Remotely



Options for remote invocation of WCM API:

1.The standard method of invoking the WCM API remotely is to configure the Remote Web Content Viewer portlet for JSP Components or related content on the remote WCM Server. The API's are invoked on the remote WCM server via the JSP's.

2.Another more limited option is to use the Remote Action URLs. Please see this section of the Infocenter for a description and samples of this option:
http://publib.boulder.ibm.com/infocenter/wpdoc/v6r1m0/index.jsp?topic=/com.ibm.wp.ent.doc/wcm/wcm_dev_remoteactions.html

3.Implement remote WCM calls using AJAX. See:

http://publib.boulder.ibm.com/infocenter/wasinfo/v6r1/index.jsp?topic=/com.ibm.websphere.ajax.devguide.help/docs/AJAX_Traditional_addcontrols.html

http://www.ibm.com/developerworks/websphere/library/techarticles/0606_bishop/0606_bishop.html

4.Custom Servlet
http://publib.boulder.ibm.com/infocenter/wasinfo/v6r1/index.jsp?topic=/org.eclipse.wst.webtools.doc.user/topics/cwservbn.html


5.Web Services
http://publib.boulder.ibm.com/infocenter/wasinfo/v6r1/index.jsp?topic=/com.ibm.websphere.wsfep.multiplatform.doc/info/ae/ae/welc6tech_wbs.html


6.EJB Client/Server
http://publib.boulder.ibm.com/infocenter/wasinfo/v6r1/index.jsp?topic=/com.ibm.etools.ejb.doc/topics/cearch.html


7.WSRP Services
http://publib.boulder.ibm.com/infocenter/wpdoc/v6r1m0/index.jsp?topic=/com.ibm.wp.ent.doc_v6101/admin/wsrpc_plan.html

If implementing servlet caching, see servlet spec sections SRV8.3 and SRV8.4. An included servlet must explicitly flush
the response to commit a request, this must be done for for a forwarded servlet (flushBuffer() method).

Web sites with sample implementation of WCM API



http://www-10.lotus.com/ldd/portalwiki.nsf/dx/wcm-api-example-allowing-anonymous-users-to-update-comment-field-of-wcm-content

http://www-10.lotus.com/ldd/portalwiki.nsf/dx/wcm-how-to-allow-portal-search-crawler-to-access-wcm-library-file-resource-components

http://www-10.lotus.com/ldd/portalwiki.nsf/dx/Allowing_End_Users_to_Subscribe_to_WCM_Content_To_Be_Alerted_of_Content_Changes

http://www-10.lotus.com/ldd/portalwiki.nsf/dx/wcm-api-example-generating-websphere-portal-navigation-from-wcm

http://www-10.lotus.com/ldd/portalwiki.nsf/dx/Leveraging_JSON_Javascript_to_extend_WCM_Component_Design_

http://www-10.lotus.com/ldd/portalwiki.nsf/dx/wcm-api-example-creating-an-administrative-navigator-component

http://www-10.lotus.com/ldd/portalwiki.nsf/dx/4.3.2-wcm-api-sample-wcm-reports

How to use the WCM API to render a Personalization (PZN) component
http://www-01.ibm.com/support/docview.wss?uid=swg21314741

Retrieving the rendering context within a WCM JSP Component:
http://www-01.ibm.com/support/docview.wss?uid=swg21386533

About the author


John Rickett is a Staff Software Engineer and is currently a WCM API SME for the Web Content Management L2 Team. He holds a Bachelors of Science in Electrical Engineering from the University of Kentucky.. .
expanded Attachments (0)
collapsed Attachments (0)
expanded Versions (27)
collapsed Versions (27)
Version Comparison     
VersionDateChanged by              Summary of changes
27Aug 8, 2012 4:15:53 PMSteven Frank  IBM contributor
26Jul 23, 2012 2:53:30 PMDeAnna Steiner  IBM contributor
25Mar 30, 2011 4:41:35 PMSunil Bhatnagar  IBM contributor
24Jan 27, 2011 5:13:06 PMJohn Rickett  IBM contributor
23Sep 28, 2010 12:17:16 AMJohn Rickett  IBM contributor
22Sep 26, 2010 9:22:03 PMJohn Rickett  IBM contributor
21Sep 24, 2010 3:57:42 PMJohn Rickett  IBM contributor
20Sep 24, 2010 3:00:25 PMJohn Rickett  IBM contributor
19Sep 22, 2010 9:43:41 AMJohn Rickett  IBM contributor
18Sep 22, 2010 9:42:03 AMJohn Rickett  IBM contributor
17Sep 21, 2010 11:09:48 AMJohn Rickett  IBM contributor
16Sep 20, 2010 11:42:44 AMJohn Rickett  IBM contributor
15Sep 20, 2010 11:38:42 AMJohn Rickett  IBM contributor
14Sep 20, 2010 11:28:12 AMJohn Rickett  IBM contributor
13Sep 20, 2010 11:22:18 AMJohn Rickett  IBM contributor
12Sep 20, 2010 11:20:25 AMJohn Rickett  IBM contributor
11Sep 15, 2010 12:23:35 PMJohn Rickett  IBM contributor
This version (10)Sep 7, 2010 12:10:23 PMSunil Bhatnagar  IBM contributor
9Aug 30, 2010 9:26:38 PMJohn Rickett  IBM contributor
8Aug 27, 2010 12:13:23 AMJohn Rickett  IBM contributor
7Aug 26, 2010 11:26:06 PMJohn Rickett  IBM contributor
6Aug 26, 2010 1:23:55 PMJohn Rickett  IBM contributor
5Aug 25, 2010 3:30:52 PMJohn Rickett  IBM contributor
4Aug 25, 2010 3:24:18 PMJohn Rickett  IBM contributor
3Aug 25, 2010 3:20:07 PMJohn Rickett  IBM contributor
2Aug 25, 2010 3:17:58 PMJohn Rickett  IBM contributor
1Aug 25, 2010 3:15:39 PMJohn Rickett  IBM contributor
Copy and paste this wiki markup to link to this article from another article in this wiki.
Go ElsewhereStay ConnectedHelpAbout
  • IBM Collaboration Solutions wikis
  • IBM developerWorks
  • IBM Software support
  • Twitter LinkIBMSocialBizUX on Twitter
  • FacebookIBMSocialBizUX on Facebook
  • ForumsLotus product forums
  • BlogsIBM Social Business UX blog
  • Community LinkIBM Collaboration Solutions
  • Wiki Help
  • Forgot user name/password
  • Wiki design feedback
  • Content feedback
  • About the wiki
  • About IBM
  • Privacy
  • Accessibility
  • IBM Terms of use
  • Wiki terms of use