/ DEVELOPMENT,Documentum,Java Documentum : BOF – SBO (Service based Business Object) – NoSuchMethodException – JAVA reflection

Documentum : BOF – SBO (Service based Business Object) – NoSuchMethodException – JAVA reflection


After my previous post, just a mini post related an error java.lang.NoSuchMethodException which occurs when the use of a SBO’s method whereas it exists. Basically in JAVA, the problem seems concern the type of POJO’s argument used between the SBO and the SBO’s client (like DCTM JOB…), the package or attributes could be different.

try {
IDfService dfService = DfClient.getLocalClientEx().newService("", session.getSessionManager());

Method method = dfService.getClass().getMethod("sendMail",;

method.invoke(dfService, mailMessage);

} catch (Exception e) {
throw new DfException(MessageFormat.format("MailSBO.sendMail({0}, {1})", session, mailMessage), e);

....Caused by: java.lang.NoSuchMethodException:
at java.lang.Class.getMethod(
... 23 more

This error doesn’t concern the presence or not of “serialVersionUID” attribute in a POJO.The Serial Version ID is used when serializing and deserializing an object. Java recognizes if the bytes you want to deserialize match the local class version. If not it will throw an exception. This is important when doing RMI or persisting object structures.

private static final long serialVersionUID = 6512673270706929264L;

However, this error occurs even with a local POJO class totally identical with the POJO class version in SBO (same package, same source), so, a simple solution is the adding of JAR containing the POJO used in SBO in the CLIENT side. Another solution is the use of class loader of remote SBO when the method is loaded/retrieved with the use of JAVA reflection for instantiation for given REMOTE POJO classes.

// #### OLD : ERROR CASE
Method method = dfService.getClass().getMethod("sendMail",;

// #### NEW : with use of SBO class loader
Method method = dfService.getClass().getMethod("sendMail", dfService.getClass().getClassLoader().loadClass(""));

Here, a full example using the SBO class loader and JAVA reflection.
So, the local POJO classes (InternetAddress / Mail) are NOT necessary:


// ... import

public class InternetAddress {
private String label;
private String address;
public InternetAddress() {
this(null, null);


// ... import

public class Mail {

private InternetAddress from;
private List<InternetAddress> to;
private List<InternetAddress> cc;
private List<InternetAddress> bcc;
private String subject;
private String body;

public Mail() {

IDfService dfService = DfClient.getLocalClientEx().newService("", session.getSessionManager());

ClassLoader classLoaderOfRemoteService = dfService.getClass().getClassLoader();

Class<?> clazzMail = classLoaderOfRemoteService.loadClass("");

Class<?> clazzInternetAddress = classLoaderOfRemoteService.loadClass("");

Mail objectMail = new Mail();
objectMail = clazzMail.newInstance();

// # setFrom(InternetAddress from)
// objectMail.setFrom(new InternetAddress(SENDER_EMAIL, SENDER_FRIENDLYNAME));
// InternetAddress
Constructor<?> constructorInternetAddress = clazzInternetAddress.getConstructor(new Class[] { String.class, String.class});
Object objectInternetAddress = constructorInternetAddress.newInstance(new Object[] { SENDER_EMAIL, SENDER_FRIENDLYNAME });
Method methodSetFrom = objectMail.getClass().getMethod("setFrom", clazzInternetAddress);
methodSetFrom.invoke(objectMail, objectInternetAddress);

// # setTo(List<InternetAddress> to)
// objectMail.setTo(emailAssignees);
List<Object> listOfAssigneesInternetAddress = new ArrayList<Object>();
for (Iterator<String> emailAssigneesIter = emailAssignees.iterator(); emailAssigneesIter.hasNext();) {
String emailAssigneeStr =;
// InternetAddress
Constructor<?> constructorInternetAddress = clazzInternetAddress.getConstructor(new Class[] { String.class});
Object objectInternetAddress = constructorInternetAddress.newInstance(new Object[] { emailAssigneeStr });

Method methodSetTo = objectMail.getClass().getMethod("setTo", List.class);
methodSetTo.invoke(objectMail, listOfAssigneesInternetAddress);

// # setSubject(String subject)
// objectMail.setSubject("SUBJECT 123");
Method methodSetSubject = objectMail.getClass().getMethod("setSubject", String.class);
methodSetSubject.invoke(objectMail, "SUBJECT 123");

// # setBody(String body)
// objectMail.setBody(createMailBody());
Method methodSetBody = objectMail.getClass().getMethod("setBody", String.class);
methodSetBody.invoke(objectMail, createMailBody());

Method method = dfService.getClass().getMethod("sendMail", clazzMail);
method.invoke(dfService, objectMail);

Best regards


Leave a Reply

Your email address will not be published.

Time limit is exhausted. Please reload CAPTCHA.

Related Post