Skip to main content
13-Aquamarine
September 30, 2026
Question

Unable to use java class on Method Server

  • September 30, 2026
  • 4 replies
  • 52 views

I'm using the Windchill13.1.4.0Rev01 Virtual Machine and I'm trying to run a java class that extracts the list of users configured in windchil on the server. At Run time however I get the following error Error while running locally in the Shell:
"(wt.fc.fcResource/0) wt.util.WTException: The operation: "findLikeUsers" failed.
Nested exception is: wt.util.WTRemoteException: Unable to invoke remote method; nested exception is: 
java.rmi.ServerRuntimeException: Server exception; nested exception is: 
java.lang.NullPointerException: Cannot invoke "java.lang.Throwable.fillInStackTrace()" because "<local18>" is null 
at wt.method.RemoteMethodServer.invoke(RemoteMethodServer.java:851) 
at wt.services.ServiceFactory$ClientInvocationHandler.invoke(ServiceFactory.java:349) 
at jdk.proxy2/jdk.proxy2.$Proxy11.findLikeUsers(Unknown Source) 
at com.custom.getallusers.GetAllUsers_4.runExtraction(GetAllUsers_4.java:34) 
at com.custom.getallusers.GetAllUsers_4.main(GetAllUsers_4.java:24)
Caused by: java.lang.NullPointerException: Cannot invoke "java.lang.Throwable.fillInStackTrace()" because "<local18>" is null" Can anyone help me, I would like to extract users using the method server. Thanks
Dimitri

4 replies

OlcaytoK
7-Bedrock
September 30, 2026

Hello dBologna, what is the method you are doing the this extraction process? 

dbologna13-AquamarineAuthor
13-Aquamarine
October 1, 2026

Hello Olcaytok, 

I am using the following code

package com.custom.getallusers;

import java.util.Enumeration;
import wt.util.WTContext;
import wt.session.SessionHelper;
import wt.org.OrganizationServicesHelper;
import wt.org.WTUser;
import wt.util.WTException;

public class GetAllUsers_4 {

    public static void main(String[] args) {
        WTContext context = null;
        try {
            System.out.println("--- AVVIO ESTRAZIONE DIRETTA (SHELL CONTEXT) ---");
            
            // Inizializza il contesto Windchill locale nella JVM della Shell
            context = WTContext.getContext();
            
            // Eleva i privilegi ad Amministratore nel thread corrente della Shell
            SessionHelper.manager.setAdministrator();
            
            // Esegue l'estrazione
            runExtraction();
            
        } catch (Exception e) {
            System.err.println("Errore durante l'esecuzione locale nella Shell:");
            e.printStackTrace();
        }
    }

    private static void runExtraction() throws WTException {
        // Interroga direttamente il provider LDAP/DB interno di Windchill
        Enumeration usersEnum = OrganizationServicesHelper.manager.findLikeUsers(null, null);
        
        int count = 0;
        System.out.println("----------------------------------------------------------------------");
        System.out.printf("%-25s | %-40s%n", "USERNAME", "NOME COMPLETO");
        System.out.println("----------------------------------------------------------------------");
        
        while (usersEnum.hasMoreElements()) {
            Object obj = usersEnum.nextElement();
            if (obj instanceof WTUser) {
                WTUser user = (WTUser) obj;
                
                // Salta gli utenti disabilitati
                if (user.isDisabled()) {
                    continue; 
                }
                
                System.out.printf("%-25s | %-40s%n", user.getName(), user.getFullName());
                count++;
            }
        }
        System.out.println("----------------------------------------------------------------------");
        System.out.println("--- FINE ESTRAZIONE. Totale utenti attivi estratti: " + count + " ---");
    }
}
BR

Dimitri

Fadel
23-Emerald II
October 1, 2026

this could be caused by picky java version used regarding remote execution ,  try something like below with Queryspec :

package ext.ts;

import wt.org.WTUser;
import wt.fc.QueryResult;
import wt.query.QuerySpec;
import wt.fc.PersistenceHelper;
import wt.util.WTException;

public class GetAllUsers_4 {

    public static void main(String[] args) {
       
        try {
          

QuerySpec qs = new QuerySpec(WTUser.class);
QueryResult qr =PersistenceHelper.manager.find(qs);
while (qr.hasMoreElements()) {
WTUser user = (WTUser) qr.nextElement();
if (!user.isDisabled()) {
System.out.println(
user.getName() + " | " + user.getFullName());
}
}
            
        } catch (Exception e) {
            System.err.println("Errore durante l'esecuzione locale nella Shell:");
            e.printStackTrace();
        }
    }


}

 

 

Buiꓘa
13-Aquamarine
October 4, 2026

​@dbologna add the “implements RemoteAccess” to your class declaration:  public class GetAllUsers_4 implements RemoteAccess {