“IWKMU1026X: File not found” error when render WCM components or elements in IBM WCM 6 SOLVED

Today, I spent a lot of time trying to render an ImageComponent using the WCM 6 API, because when I used the method render() from the workspace this error was appearing:

IWKMU1026X: File not found

The thing is, almost all in the web point to a permission issue, but at the end my solution is not necessarily related with that kind of issues. Please, pay attention in next steps in order to solve this error correctly.

1) Of course, the first thing that we need to be sure is that we have permission for reading information from WCM using the API. So, how can we verify that?

Use next way if you have possibility to enable WebSphere logs (if not, just replace LOG.log() by System.out.println()):

// This obtains an HTML Component called "Rendering-An-HTML-Component" to render it later (you can use any other component to test this)
DocumentIdIterator componentIdIterator = workspace.findComponentByName("Rendering-An-HTML-Component");

	DocumentId cmpntId = (DocumentId)componentIdIterator.next();
	LibraryHTMLComponent htmlComponent = (LibraryHTMLComponent) workspace.getById(cmpntId);

		// Here, we verify if we have access to our HTML component
		LOG.log(WsLevel.DETAIL, "-- addImageComponent(): hasUserAccess: "+ workspace.hasUserAccess(cmpntId));
		LOG.log(WsLevel.DETAIL, "-- addImageComponent(): hasContributorAccess: "+ workspace.hasContributorAccess(cmpntId));
		LOG.log(WsLevel.DETAIL, "-- addImageComponent(): hasEditorAccess: "+ workspace.hasEditorAccess(cmpntId));
		LOG.log(WsLevel.DETAIL, "-- addImageComponent(): hasManagerAccess: "+ workspace.hasManagerAccess(cmpntId));

		// Also, we can get the current user profile
		UserProfile userProfile = workspace.getUserProfile();
		if(userProfile != null){
			LOG.log(WsLevel.DETAIL, "-- addImageComponent(): getUsername(): "+ userProfile.getUsername());
			LOG.log(WsLevel.DETAIL, "-- addImageComponent(): UserProfile is NULL.");

A possible output could be something like this:

-- addImageComponent(): hasUserAccess: true
-- addImageComponent(): hasContributorAccess: true
-- addImageComponent(): hasEditorAccess: true
-- addImageComponent(): hasManagerAccess: true
-- addImageComponent(): getUsername(): wps admin

2) The RenderingContext object must be well configured, in my case the path of the content was not well constructed. If you don’t know anything about Rendering Context, maybe this article will be useful: https://wiki.base22.com/display/btg/Understand+rendering+contexts.

So, the configuration that I used was this:

// content is an instance of com.ibm.workplace.wcm.api.Content
String pathContent = workspace.getPathById(content.getId(), true, true);

Method setRenderedContent() is very important because it is used in order to render all Image Components that “live” in the CURRENT piece of content or external components.

3) In my case I needed to render an image loaded as element in a piece of content, so, for rendering that image, following code was necessary:

ImageComponent image = (ImageComponent) content.getComponentByReference("myImageElementInPieceOfContent");
String renderedImage = workspace.render(renderingContext,image);

4) After executing the render() method, we will get a String with the full-image-tag, for example:

<img src="/wcm/myconnect/f5ec6f004174a7c1a3f4a37ca91860da/std_tr270_wide_cover.jpg?MOD=AJPERES&amp;CACHEID=f5ec6f004174a7c1a3f4a37ca91860da" border="0" width="1024" height="330" />

If we want just the image URL, we can create a regular expression to get it. Next code, will obtain a String like: /wcm/myconnect/1d433c004174a7c2a3f8a37ca91860da/std_tr270_small_product_preview.jpg?MOD=AJPERES please don’t remove ?MOD=AJPERES that is required by WCM to render our image given the URL.

Pattern pattern = Pattern.compile("(<img\\s*src=\\s*\")(.*?)(\\&)");
Matcher m = pattern.matcher(renderedImage);
	imageURL = m.group(2); // Gets the URL

5) Be sure your piece of content is PUBLISHED!

6) If after following previous steps, you are getting the same error maybe you forgot the same as me: MAPPINGS between Authoring Templates and Presentation Templates in the site areas that contain the contents that you are using for configuring your Rendering Context object.

So, please go to WCM then look for your site area and check you have mappings well configured (see next image as an example).



That’s it!

Be happy with your code!

One comment on ““IWKMU1026X: File not found” error when render WCM components or elements in IBM WCM 6 SOLVED”

Leave a Reply

Your email address will not be published. Required fields are marked *