'java 11 rmi NoClassDefFoundError

I updated my application to use Java 11 and I am getting the below error when trying to rebind an object over RMI. The application works fine on Java 8.

They say NoClassDefFoundError can occur from a class being missing in the class path or from an error from a static block.

The $Proxy0 class is apparently a class that is created at runtime, so it should not be in the class path, but I am wondering if the rmiregristy knows this.

I don’t see any static blocks of code that may be causing the problem.

Open to any suggestions.

2021-09-21 14:27:18,750 (3019) [main] WARN  org.ets.speechrater.pm.RPMServer [] - Unable to create RMI object Retrying
java.rmi.ServerError: Error occurred in server thread; nested exception is:
        java.lang.NoClassDefFoundError: Could not initialize class org.ets.speechrater.pm.$Proxy0
        at java.rmi/sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:388) ~[?:?]
        at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:200) ~[?:?]
        at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:197) ~[?:?]
        at java.base/java.security.AccessController.doPrivileged(Native Method) ~[?:?]
        at java.rmi/sun.rmi.transport.Transport.serviceCall(Transport.java:196) ~[?:?]
        at java.rmi/sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:562) ~[?:?]
        at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:796) ~[?:?]
        at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:677) ~[?:?]
        at java.base/java.security.AccessController.doPrivileged(Native Method) ~[?:?]
        at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:676) ~[?:?]
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]
        at java.base/java.lang.Thread.run(Thread.java:829) [?:?]
        at java.rmi/sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:303) ~[?:?]
        at java.rmi/sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:279) ~[?:?]
        at java.rmi/sun.rmi.server.UnicastRef.invoke(UnicastRef.java:380) ~[?:?]
        at java.rmi/sun.rmi.registry.RegistryImpl_Stub.rebind(RegistryImpl_Stub.java:158) ~[?:?]
        at java.rmi/java.rmi.Naming.rebind(Naming.java:177) ~[?:?]
        at org.ets.speechrater.pm.RPMServer.main(RPMServer.java:104) ~[SpeechServlet-classes.jar:?]
Caused by: java.lang.NoClassDefFoundError: Could not initialize class org.ets.speechrater.pm.$Proxy0
        at jdk.internal.reflect.GeneratedSerializationConstructorAccessor2.newInstance(Unknown Source) ~[?:?]
        at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490) ~[?:?]
        at java.base/java.io.ObjectStreamClass.lambda$newInstance$0(ObjectStreamClass.java:1097) ~[?:?]
        at java.base/java.security.AccessController.doPrivileged(Native Method) ~[?:?]
        at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85) ~[?:?]
        at java.base/java.io.ObjectStreamClass.newInstance(ObjectStreamClass.java:1105) ~[?:?]
        at java.base/java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2180) ~[?:?]
        at java.base/java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1679) ~[?:?]
        at java.base/java.io.ObjectInputStream.readObject(ObjectInputStream.java:493) ~[?:?]
        at java.base/java.io.ObjectInputStream.readObject(ObjectInputStream.java:451) ~[?:?]
        at java.rmi/sun.rmi.registry.RegistryImpl_Skel.dispatch(RegistryImpl_Skel.java:154) ~[?:?]
        at java.rmi/sun.rmi.server.UnicastServerRef.oldDispatch(UnicastServerRef.java:468) ~[?:?]
        at java.rmi/sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:298) ~[?:?]
        at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:200) ~[?:?]
        at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:197) ~[?:?]
        at java.base/java.security.AccessController.doPrivileged(Native Method) ~[?:?]
        at java.rmi/sun.rmi.transport.Transport.serviceCall(Transport.java:196) ~[?:?]
        at java.rmi/sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:562) ~[?:?]
        at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:796) ~[?:?]
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) ~[?:?]
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) ~[?:?]
        at java.base/java.lang.Thread.run(Thread.java:829) ~[?:?]
package org.ets.speechrater.pm;

import java.io.File;
import java.rmi.Naming;
import java.lang.SecurityManager;
import java.rmi.RemoteException;

import org.ets.research.srater.config.Config;
import org.ets.speechrater.properties.PropertiesAssist;
import org.ets.speechrater.util.ETSLogger;

/**
 * RPMServer
 * 
 * Operational wrapper for RPMImpl, which implements the speech recognition
 * (server) components.
 * 
 * 
 * 
 */
public class RPMServer { // class RPMServer

    static private ETSLogger logger = ETSLogger.getLogger(RPMServer.class
            .getName());

    static RPM rpm;

    // ///////////////////////////////////////////////////////////////////
    //
    // main()
    //
    // ///////////////////////////////////////////////////////////////////

    public static void main(String args[]) throws Throwable { // main()

        try {

            System.setSecurityManager(new SecurityManager());

            String propertyKey = null;
            String bindingName;
            int portNumber;
            String rmiAddr;
            int hostIndex = 0;
            boolean rpmSimMode = false;

            try { // get access to the logger
                PropertiesAssist.initPmProperty(args[0]);
            } // get access to the logger
            catch (Exception e) {
                String msg = "Unable to load properties";
                logger.error(msg);
                throw new RemoteException(msg, e);
            }
            
            try {
                if (args.length > 1)
                    hostIndex = Integer.parseInt(args[1]);
                else
                    hostIndex = 0;

                propertyKey = "rpm" + hostIndex + "BindingName";
                logger.debug("propertyKey " + propertyKey);

                bindingName = PropertiesAssist.getPmPropertyString(propertyKey);
                propertyKey = "rpm" + hostIndex + "Port";
                logger.debug("propertyKey " + propertyKey);
                portNumber = Integer.parseInt(PropertiesAssist
                        .getPmPropertyString(propertyKey));
            } catch (Exception e) {
                String msg = "Unable to get bindingName or port property. "
                        + propertyKey;
                logger.error(msg);

                throw new RemoteException(msg, e);
            }
            try {
                propertyKey = "rpmRMIAddr";
                rmiAddr = PropertiesAssist.getPmPropertyString(propertyKey);
            } catch (Exception e) {
                rmiAddr = null;
            }

            if (args.length > 2) {
                rpmSimMode = Boolean.parseBoolean(args[2]);
                logger.debug("rpmSimMode is " + rpmSimMode);
            }

            rpm = null;
            while (rpm == null) { // Retry until have reference
                try {
                    logger.debug("In server before Object rpm");
                    if (!rpmSimMode)
                        rpm = new RPMImpl(logger, portNumber);
                    else
                        rpm = new RPMImplSim(logger, portNumber);

                    logger.debug("RPM Implementation: " + rpm);
                    logger.debug("In server after Object rpm");
                    if (rmiAddr != null)
                        bindingName = rmiAddr + "/" + bindingName;

                    logger.debug("In server binding to " + bindingName);
                    Naming.rebind(bindingName, rpm);
                    logger.debug("In server after bind rpm to tagRPM");
                } catch (Exception e) { // catch block
                    logger.warn("Unable to create RMI object Retrying",e);
                    String msg = "Is rmiregistry running?";
                    logger.warn(msg);
                    logger.debug(e);
                    try {
                        Thread.sleep(2000);
                    } catch (InterruptedException ex) {
                        ex.printStackTrace();
                    }
                } // catch block
            } // Retry until have reference

            final String killFilename = PropertiesAssist
                    .getPmPropertyString("killFile.server");
            if (killFilename == null || killFilename.length() == 0) {
                logger.warn("Property not found: killFile.server");
            } else {
                final String finalBindingName = bindingName;
                Runnable killFileWatcher = new Runnable() {
                    public void run() {
                        File f = new File(killFilename);
                        while (f == null || !f.exists()) {
                            f = new File(killFilename);
                            try {
                                Thread.sleep(5000);
                            } catch (InterruptedException e) {
                            }
                        }

                        if (f.exists()) {
                            logger.info("Kill file found. Stopping server");
                            try {
                                rpm.shutdown();
                                logger.info("All recognizer instances shut down successfully.");
                                Naming.unbind(finalBindingName);
                                rpm = null;
                                logger.info("(Server) Bye.");
                                System.exit(0);
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                        }
                    }
                };
                killFileWatcher.run();
            }
            logger.debug("RPMServer: End of main().");

        } catch (Throwable t) {
            logger.fatal("RPMServer: Throwable Exception caught " + t.toString(), t);

            throw t;
        }
    } // main()
} // class RPMServer
package org.ets.speechrater.pm;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
import java.util.HashMap;
import java.util.Map;

import org.ets.research.srater.exceptions.RecognizerException;
import org.ets.research.srater.asrfa.FeatureExtractionPipeline;
import org.ets.research.srater.kaldi.KaldiPipeline;
import org.ets.research.srater.htk.HtkPipeline;
import org.ets.research.srater.config.Config;
import org.ets.research.srater.config.ConfigFactory;
import org.ets.research.srater.scoring.CTMData;
import org.ets.research.srater.scoring.SpeechSample;
import org.ets.research.srater.util.Tools;
import org.ets.research.srater.util.os.DirectoryHandler;
import org.ets.speechrater.ScoringRequest;
import org.ets.speechrater.properties.PropertiesAssist;
import org.ets.speechrater.util.ETSLogger;

//######################################################################
//
// class RPMImpl   implements RPM
//
// This object provides a very thin layer between a remote client
//    and a list of local Recognizers.
//
// Errors:
//    A message will be displayed
//       All messages coming from this class will begin with RPM
//    A trace of the trapped exception will be displayed
//    A remote exception will be thrown including the displayed
//       message and the text of the trapped exception.
//
// Errors: all throw RemoteException
//
// Client calls LPMRecognizer.extract()
// LPMRecognizer.extract() calls RPM.extract()
// RPM.extract() calls KaldiPipeline.extract()
//
//######################################################################

public class RPMImpl extends UnicastRemoteObject implements RPM { // class
                                                                    // RPMImpl

    static ETSLogger loggerPm;

    // ///////////////////////////////////////////////////////////////////
    //
    // private vars
    //
    // ///////////////////////////////////////////////////////////////////

    private static final long serialVersionUID = 271828182845904523L;

    private Map<String,FeatureExtractionPipeline[]> _RecognizerList;
    private boolean[] busyFlags;

    private int _numEVRecognizer;
    private String _msg; // last error. Keep

    // ///////////////////////////////////////////////////////////////////
    //
    // RPMImpl() constructor
    //
    // Construct an object as an rmi remote target.
    //
    // ///////////////////////////////////////////////////////////////////
    public RPMImpl(ETSLogger logger, int port) throws RemoteException { // RPMImpl()
                                                                        // constructor
        super(port); // Set the port
        _msg = "";
        loggerPm = logger;
        loggerPm.debug("RPMImpl constructed.");
    } // RPMImpl() constructor

    // ///////////////////////////////////////////////////////////////////
    //
    // init()
    //
    // instantiate a list of MultimodalRecognizer objects.
    // instantiate a list of EV Recognizer objects.
    //
    // ///////////////////////////////////////////////////////////////////
    public void init(int inNumEVRecognizer) throws Exception { // init()
        Config configTPO = ConfigFactory.makeConfig(PropertiesAssist.getPmPropertyString("research.tpo.config.name"));  //note it does not matter what config is used, because just basic things are used (e.g. basedir...)
        configTPO.load(PropertiesAssist.getPmPropertyString("research.master.config"));
        Config configNEWORIENTAL = ConfigFactory.makeConfig(PropertiesAssist.getPmPropertyString("research.neworiental.config.name"));  //note it does not matter what config is used, because just basic things are used (e.g. basedir...)
        configNEWORIENTAL.load(PropertiesAssist.getPmPropertyString("research.master.config"));
        Config configTOEFLIBT = ConfigFactory.makeConfig(PropertiesAssist.getPmPropertyString("research.toeflibt.config"));
        configTOEFLIBT.load(PropertiesAssist.getPmPropertyString("research.master.config"));
        
        _numEVRecognizer = inNumEVRecognizer;

        if (PropertiesAssist.getPmPropertyString("Srater.recognizerType")
                .toUpperCase().equals("KALDI")) {
            _RecognizerList = new HashMap<String,FeatureExtractionPipeline[]>();
            _RecognizerList.put(PropertiesAssist.getPmPropertyString("research.tpo.config.name"),new KaldiPipeline[_numEVRecognizer]);
            _RecognizerList.put(PropertiesAssist.getPmPropertyString("research.neworiental.config.name"),new KaldiPipeline[_numEVRecognizer]);
            _RecognizerList.put(PropertiesAssist.getPmPropertyString("research.toeflibt.config"),new KaldiPipeline[_numEVRecognizer]);
            
            loggerPm.debug("HTK Array initiaized");
        } else if (PropertiesAssist.getPmPropertyString("Srater.recognizerType")
                .toUpperCase().equals("HTK")) {
            _RecognizerList = new HashMap<String,FeatureExtractionPipeline[]>();
            _RecognizerList.put(PropertiesAssist.getPmPropertyString("research.tpo.config.name"),new HtkPipeline[_numEVRecognizer]);
            _RecognizerList.put(PropertiesAssist.getPmPropertyString("research.neworiental.config.name"),new HtkPipeline[_numEVRecognizer]);
            _RecognizerList.put(PropertiesAssist.getPmPropertyString("research.toeflibt.config"),new HtkPipeline[_numEVRecognizer]);
            loggerPm.debug("HTK Array initiaized");
        } else {
            throw new Exception("Srater.recognizerType set to unknown type: "
                    + PropertiesAssist.getPmPropertyString(
                            "Srater.recognizerType").toUpperCase());
        }

        busyFlags = new boolean[_numEVRecognizer];

        loggerPm.debug("Ready to create " + _numEVRecognizer + " EVRecognizer");

        // Chi added
        String outputDirName = null;

        try {
            outputDirName = PropertiesAssist.getPmPropertyString("Srater.outputDirName");
        } catch (Exception e) {
            _msg = "Unable to get property MultimodalRecognizer arg";
            loggerPm.error(_msg, e);
            throw new RemoteException(_msg, e);
        }

        loggerPm.debug("Ready to create " + _numEVRecognizer + " EVRecognizer");
        for (int index = 0; index < _numEVRecognizer; index++) {
            try {
                if (PropertiesAssist
                        .getPmPropertyString("Srater.recognizerType")
                        .toUpperCase().equals("KALDI")) {
                    try {
                        _RecognizerList.get(PropertiesAssist.getPmPropertyString("research.tpo.config.name"))[index] = new KaldiPipeline(configTPO);
                        _RecognizerList.get(PropertiesAssist.getPmPropertyString("research.neworiental.config.name"))[index] = new KaldiPipeline(configNEWORIENTAL);
                        _RecognizerList.get(PropertiesAssist.getPmPropertyString("research.toeflibt.config"))[index] = new KaldiPipeline(configTOEFLIBT);
                    } catch (Throwable e) {
                        loggerPm.error("some type of error with recognizer" + e.getMessage());
                        
                        if (e instanceof RecognizerException) {
                            throw new RecognizerException(new Exception(e.getMessage()));
                        }
                        else{
                            throw new Exception(e.getMessage());
                        }
                        
                    }
                            //outputDirName,
                            //"",                           //note that archiving of dat and ctm are handled outside of extract now
                            //config);
                    loggerPm.debug("HTK Array[" + index + "] initiaized");
                } else if (PropertiesAssist
                        .getPmPropertyString("Srater.recognizerType")
                        .toUpperCase().equals("HTK")) {
                    try {
                        _RecognizerList.get("research.tpo.config.name")[index] = new HtkPipeline(configTPO);
                        _RecognizerList.get("research.neworiental.config.name")[index] = new HtkPipeline(configNEWORIENTAL);
                        _RecognizerList.get("research.toeflibt.config")[index] = new HtkPipeline(configTOEFLIBT);
                    } catch (Throwable e) {
                        loggerPm.error("some type of error with recognizer" + e.getMessage());
                        
                        if (e instanceof RecognizerException) {
                            throw new RecognizerException(new Exception(e.getMessage()));
                        }
                        else{
                            throw new Exception(e.getMessage());
                        }
                    }
                            //outputDirName,
                            //"",                           //note that archiving of dat and ctm are handled outside of extract now
                            //config);
                    loggerPm.debug("HTK Array[" + index + "] initiaized");
                } else {
                    throw new Exception(
                            "Srater.recognizerType set to unknown type: "
                                    + PropertiesAssist.getPmPropertyString(
                                            "Srater.recognizerType")
                                            .toUpperCase());
                }

                busyFlags[index] = false;
                loggerPm.debug("MultimodalRecognizer " + index + " Created");
            } catch (Exception e) {
                _msg = "RPM init failed";
                loggerPm.error(_msg, e);
                throw new RemoteException(_msg, e);
            }
        }
    } // init()



    /***
     * Note this saves TPO *.ctm and *.dat to files.
     *
     * @param ctm
     * @throws Exception
     *
     */
    public void generateDatFromCTMandArchiveDATandCTM(CTMData ctm, String fileName) throws Exception {
        String archiveFilenamePathAndPrefix = new File(PropertiesAssist.getPmPropertyString("Srater.dataWarehouseDir"),fileName).getAbsolutePath();

        //create dat file
        File outFile = new File(archiveFilenamePathAndPrefix + ".dat");
        PrintWriter pw = new PrintWriter(new FileWriter(outFile));
        pw.print(ctm.PfHeader());
        pw.print(ctm.getFeatureStr());
        pw.close();

        //create ctm file
        outFile = new File(archiveFilenamePathAndPrefix + ".ctm");
        pw = new PrintWriter(new FileWriter(outFile));
        pw.print(ctm.getCtm());
//      pw.print(ctm.PfHeader());
//      pw.print(ctm.getFeatureStr());
        pw.close();

    }







    // ///////////////////////////////////////////////////////////////////
    //
    // extract()
    //
    // call the specified MultimodalRecognizer in the object list.
    //
    // Client calls LPMRecognizer.extract()
    // LPMRecognizer.extract() calls RPM.extract()
    // RPM.extract() calls KaldiPipeline.extract()
    //
    // ///////////////////////////////////////////////////////////////////
    // public CTM extract( int index, SpeechSample toServ ) throws
    // RemoteException, RecognizerException
    // { // extract()

    public CTMData extract(
            int index,
            SpeechSample toServ,
            ScoringRequest scoringRequest,
            String modelName,
            String configName,
            String masterConfigFileName
            ) throws RemoteException,
            RecognizerException { // extract()
        String ID = toServ.getID();
        loggerPm.debug("RPM Ready to extract Thread " + index + "  DB " + ID);
        boolean saveTmpOnFailure = true;
        DirectoryHandler workingDirHandler = null;

        try {
            busyFlags[index] = true;

            Config config = ConfigFactory.makeConfig(configName);
            config.load(masterConfigFileName);
            loggerPm.warn("masterConfig>>>>:"+masterConfigFileName);

            try{
                saveTmpOnFailure = PropertiesAssist.getPmPropertyString("Srater.saveTempDirOnExtractFailure").equals("true");
            } catch (Exception any) {};


            //TPOv5 version of extract
            String baseDir = PropertiesAssist.getPmPropertyString("tmpPath");
            String dirPrefix = "recognizer_" + scoringRequest.getRequestID().getRequestID().toString() + "_";
//          String workingDir = new File(baseDir, dirPrefix).getAbsolutePath() + index;
            workingDirHandler = new DirectoryHandler(baseDir, dirPrefix);


            CTMData ctm = null;

            //save sound file to disk before extract
            String filenameWithExtension = new File(workingDirHandler.getWorkingDir(), toServ.getID() + "." + toServ.getSampleCodec()).getAbsolutePath() ;
            toServ.saveFile(filenameWithExtension);
            if (PropertiesAssist.getPmPropertyString("Srater.recognizerType")
                    .toUpperCase().equals("KALDI")) {
                ctm = ((KaldiPipeline)_RecognizerList.get(configName)[index]).extract(toServ, workingDirHandler);
            }
            else if (PropertiesAssist.getPmPropertyString("Srater.recognizerType")
                    .toUpperCase().equals("HTK")) {
                ctm = ((HtkPipeline)_RecognizerList.get(configName)[index]).extract(toServ, workingDirHandler);
            }

            ctm.SetSampleID(toServ.getID());
//          generateCdatFromCTM();

            //create dat and ctm files and archive them
            // !!! adding proper file name as a parameter
            generateDatFromCTMandArchiveDATandCTM(ctm,
                    scoringRequest.getRequestID()+"-"+scoringRequest.getClientRequestID());

            //clean up directory
            if(PropertiesAssist.getPmPropertyString("Srater.deleteTempfiles").equals("true")){
                workingDirHandler.deleteWorkingDir();
                
            }
            else{
                loggerPm.debug("not deleting temporary files for: " + scoringRequest.getRequestID().getRequestID().toString() + " , directory: " + workingDirHandler.getWorkingDir().toPath().toAbsolutePath().toString());
            }



//          CTMData ctm = _RecognizerList[index].extract(
//                  toServ,
//                  PropertiesAssist.getPmPropertyString("Srater.deleteOutputfiles").equals("true"),
//                  PropertiesAssist.getPmPropertyString("Srater.deleteTempfiles").equals("true"),
//                  scoringRequest.getRequestID() + "-"+ scoringRequest.getClientRequestID(),
//                  modelName
//                  ,config
//
//          );

            loggerPm.debug("Extract Features Header:" + ctm.PfHeader());
//          loggerPm.debug("Extract Features Values:"
//                  + ctm.PfOutput(""));
            loggerPm.debug("Extract Features Names and Values:"
                    + ctm.getFeatureStr());



            loggerPm.debug("RPM Done extract Thread " + index + "  DB " + ID);
            return (ctm);

        } catch (RecognizerException e) {
            _msg = "RPM extract caught RecognizerException (" + e.getMessage()
                    + ") Thread " + index + "  DB " + ID;
            loggerPm.warn(_msg, e);

            try{
                if(!saveTmpOnFailure && workingDirHandler != null)
                    workingDirHandler.deleteWorkingDir();
            }catch(Exception any){}

            throw e;
        } catch (Throwable t) {
            _msg = "RPM extract failed Thread " + index + "  DB " + ID;
            loggerPm.warn(_msg + t.toString(), t);
            throw new RemoteException(_msg, t);
        }

    } // extract()

    // ///////////////////////////////////////////////////////////////////
    //
    // refresh()
    //
    // One of the recognizers has failed.
    // This method replaces the broken object with a new one.
    //
    // ///////////////////////////////////////////////////////////////////
    public void refresh(int index) throws RemoteException { // refresh()


        // Chi added
        String outputDirName = null;

        try {

            outputDirName = PropertiesAssist
                    .getPmPropertyString("Srater.outputDirName");

        } catch (Exception e) {
            _msg = "Unable to get property MultimodalRecognizer arg";
            loggerPm.error(_msg, e);
            throw new RemoteException(_msg, e);
        }
        try {
//          Config.readMasterConfig(PropertiesAssist.getPmPropertyString("research.master.config"));
//          Config.setCurrentConfig(PropertiesAssist.getPmPropertyString("research.tpo.config.name"));
            Config configTPO = ConfigFactory.makeConfig(PropertiesAssist.getPmPropertyString("research.tpo.config.name"));  //note it does not matter what config is used, because just basic things are used (e.g. basedir...)
            configTPO.load(PropertiesAssist.getPmPropertyString("research.master.config"));
            Config configNEWORIENTAL = ConfigFactory.makeConfig(PropertiesAssist.getPmPropertyString("research.neworiental.config.name"));  //note it does not matter what config is used, because just basic things are used (e.g. basedir...)
            configNEWORIENTAL.load(PropertiesAssist.getPmPropertyString("research.master.config"));
            Config configTOEFLIBT = ConfigFactory.makeConfig(PropertiesAssist.getPmPropertyString("research.toeflibt.config"));
            configTOEFLIBT.load(PropertiesAssist.getPmPropertyString("research.master.config"));


            if (PropertiesAssist.getPmPropertyString("Srater.recognizerType")
                    .toUpperCase().equals("HTK")) {
                try {
                    _RecognizerList.get(PropertiesAssist.getPmPropertyString(PropertiesAssist.getPmPropertyString("research.tpo.config.name")))[index] = new HtkPipeline(configTPO);
                    _RecognizerList.get(PropertiesAssist.getPmPropertyString(PropertiesAssist.getPmPropertyString("research.neworiental.config.name")))[index] = new HtkPipeline(configNEWORIENTAL);                    
                    _RecognizerList.get(PropertiesAssist.getPmPropertyString(PropertiesAssist.getPmPropertyString("research.toeflibt.config")))[index] = new HtkPipeline(configTOEFLIBT);                   
                } catch (Throwable e) {
                    loggerPm.error("some type of error with recognizer" + e.getMessage());
                    
                    if (e instanceof RecognizerException) {
                        throw new RecognizerException(new Exception(e.getMessage()));
                    }
                    else{
                        throw new Exception(e.getMessage());
                    }
                }
                        //outputDirName,
                        //"",                           //note that archiving of dat and ctm are handled outside of extract now
                        //config);
                loggerPm.debug("HTK Array[" + index + "] refreshed");
            } else if (PropertiesAssist
                    .getPmPropertyString("Srater.recognizerType").toUpperCase()
                    .equals("KALDI")) {
                try {
                    _RecognizerList.get(PropertiesAssist.getPmPropertyString("research.tpo.config.name"))[index] = new KaldiPipeline(configTPO);
                    _RecognizerList.get(PropertiesAssist.getPmPropertyString("research.neworiental.config.name"))[index] = new KaldiPipeline(configNEWORIENTAL);
                    _RecognizerList.get(PropertiesAssist.getPmPropertyString("research.toeflibt.config"))[index] = new KaldiPipeline(configTOEFLIBT);
                } catch (Throwable e) {
                    loggerPm.error("some type of error with recognizer" + e.getMessage());
                    
                    if (e instanceof RecognizerException) {
                        throw new RecognizerException(new Exception(e.getMessage()));
                    }
                    else{
                        throw new Exception(e.getMessage());
                    }
                }
                        //outputDirName,
                        //"",                           //note that archiving of dat and ctm are handled outside of extract now
                        //config);
                loggerPm.debug("KALDI Array[" + index + "] refreshed");

            } else {
                throw new Exception(
                        "Srater.recognizerType set to unknown type: "
                                + PropertiesAssist.getPmPropertyString(
                                        "Srater.recognizerType").toUpperCase());
            }


            loggerPm.debug("MultimodalRecognizer " + index + " Refreshed");
        } catch (Exception e) {
            _msg = "RPM refresh failed";
            loggerPm.error(_msg, e);
            throw new RemoteException(_msg, e);
        }

    } // refresh()

    // ///////////////////////////////////////////////////////////////////
    //
    // pingRemote()
    //
    // Recovery has been attempted.
    // A reference has been acquired.
    // But is it a stale one that is still in the registry.
    // This method is used to validate.
    // If the reference is stale a remote exception is thrown.
    // If not stale "OK"
    //
    // ///////////////////////////////////////////////////////////////////
    public String pingRemote() throws RemoteException { // pingRemote()
        return ("OK");
    } // pingRemote()



    public void shutdown() {

        for (int i = 0; i < _numEVRecognizer; i++) {
            int retryCount = 0;
            while (busyFlags[i] && retryCount < 60) {
                loggerPm.debug("Recognizer " + (i + 1) + " is busy.");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                }
                retryCount++;
            }
            loggerPm.info("Shutting down recognizer instance " + (i + 1) + ".");

            try {
                _RecognizerList.get(PropertiesAssist.getPmPropertyString("research.tpo.config.name"))[i].close();
                _RecognizerList.get(PropertiesAssist.getPmPropertyString("research.neworiental.config.name"))[i].close();
                _RecognizerList.get(PropertiesAssist.getPmPropertyString("research.toeflibt.config"))[i].close();
            } catch (Exception e) {
                loggerPm.warn("Recognizer close (which removes the temporary directory used for that instance) - failed",e);
            }

            try {
                _RecognizerList.get(PropertiesAssist.getPmPropertyString("research.tpo.config.name"))[i] = null;
                _RecognizerList.get(PropertiesAssist.getPmPropertyString("research.neworiental.config.name"))[i] = null;
                _RecognizerList.get(PropertiesAssist.getPmPropertyString("research.toeflibt.config"))[i] = null;                
            } catch (Exception e) {
                loggerPm.warn("ignoring error when setting recognizer to null, because we are shutting down already");
            }
        }
        loggerPm.info("All recognizers have been shut down.");
    }

    public void setBusy(int index, boolean busy) throws RemoteException {
        loggerPm.debug("RPM recognizer(" + index + ") is "
                + (busy ? "" : "no longer ") + "busy.");
        busyFlags[index] = busy;
    }

} // class RPMImpl


Solution 1:[1]

If I use the rmiregistry executable that comes with the JDK, I have this problem. But using code to create the registry seems to be a good work around.

package org.ets.speechrater.util;

import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.util.concurrent.TimeUnit;

public class RMIregistry {
    static ETSLogger logger = ETSLogger.getLogger(RMIregistry.class
            .getName());
    
    public static void main(String args[]) {
        
        try {
            Registry registry = LocateRegistry.createRegistry(Integer.valueOf(args[0]));
            
            logger.info("Server ready");
            
            while(true) {
                TimeUnit.MINUTES.sleep(1000);
            }
            
        } catch (Exception e) {
            logger.error("Server exception: " + e.toString(),e);
        }
    }
}

Solution 2:[2]

try to add modules (include the NoClassDefFoundError classes) to rmiregistry like:

rmiregistry -J--add-modules=java.sql

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Mr. Mundkowsky
Solution 2 Jacob Ban