1

In my current project using Filenet P8 Content Platform Engine 5.2.1 with WebSphere 8.5.5.3, IBM RAD 9.5 and Apache Maven 3.3.1

I'm trying to deploy a Change Preprocessor linked to a certain document class. Every time a document is added to this class or subclass I would like the CP to change some properties.

I uploaded the action handler's class as a Code Module, the same way I usually do for subscriptions:

Code modules folder

where the Update Document Properties CP object Content Elements tab shows as follows:

Code module content elements

and I have properly configured the preprocessor definition using ACCE in the document class Change Preprocessor Definitions tab:

Document class' Change Preprocessor Definition tab

The Javascript implementation of the action works

// Set NumeroContratto property to certain value when a new document is created.
   importClass(Packages.com.filenet.api.action.Create);
   function preprocessObjectChange (sourceObj)
   {
      // Verify that the pending action is a create action.
      var actions = sourceObj.getPendingActions(); 
      for ( var i = 0; i < actions.length; i++ )
      {
         if ( actions[i] instanceof Create ) 
         {
            // Set NumeroContratto property to "777"
            sourceObj.getProperties().putValue("NumeroContratto", "777");
            return true;
         }
      }
      return false;
   }

and this is the Java implementation:

package com.finmeccanica.spc.ecm.filenet.cp.actionhandler;

import com.filenet.api.action.*;
import com.filenet.api.core.IndependentlyPersistableObject;

public class AddPropertiesToObjectCP implements
        com.filenet.api.engine.ChangePreprocessor {
    public boolean preprocessObjectChange(
            IndependentlyPersistableObject sourceObj) {
        try {
            PendingAction actions[] = sourceObj.getPendingActions();
            for (int i = 0; i < actions.length; i++) {
                if (actions[i] instanceof Create) {
                    sourceObj.getProperties()
                            .putValue("NumeroContratto", "777");
                    return true;
                }
            }
            return false;
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
}

What is the problem?
I couldn't get the preprocessor to work implementing it in Java. Despite I fill the fields with the name of the Java class handler and the code module title

Change preprocessor action Java class

when I click to save the change preprocessor action, the system always tells me that it can't find the class:

FNRAC1005E The 'PDGOV CP Add PropertiesToDocument Action' object was not saved.

User response: Refresh the object, reenter your changes, and try again, or contact your system administrator.

Exception details: Unable to load event handler class from either associated code module or system classpath: com.finmeccanica.spc.ecm.filenet.cp.actionhandler.AddPropertiesToObjectCP. Message was: com.finmeccanica.spc.ecm.filenet.cp.actionhandler.AddPropertiesToObjectCP

The jar I uploaded contains the class in the right package and the code module's content is not corrupted.

Am I missing something? Do I have to configure something else?

abarisone
  • 3,707
  • 11
  • 35
  • 54

1 Answers1

3

You are not missing something in your code. I replicated your steps and did receive the same error when I attempted to convert an existing Change Preprocessor Action from a JavaScript type to a Java class type. It could not find the code module.

However, when I created a new Change Preprocessor Action using the same CodeModule, it worked fine. The difference being when you create a new one, you are prompted to Browse for your code module rather than typing its name.

To fix, don't convert your existing action from a JavaScript type. Create a new Change Preprocessor Action instead, selecting Java type from the start.

lkleinow
  • 66
  • 4