groovymulemule-studiocloudhubgroovyclassloader

Groovy unable to resolve class in CloudHub


Have the following errors for the following scripts in a Mule flow when I run the application in CloudHub. When I run it on Anypoint studio, there's no issues.

I checked the deployed application archive file and in the classes folder is the compiled company.cloudtools.util.Utilities class. I am not sure why the CloudHub server cannot locate the class file as defined by the error.

Error:

org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
Script16.groovy: 1: unable to resolve class company.cloudtools.util.Utilities
 @ line 1, column 1.
   import company.cloudtools.util.Utilities
   ^

1 error

    at org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:302)
    at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:858)
    at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:548)
    at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:497)
    at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:306)
    at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:287)
    at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:267)
    at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:214)
    at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.getScriptClass(GroovyScriptEngin

Script in Mule flow:

<scripting:transformer doc:name="parse record type">
                    <scripting:script engine="Groovy"><![CDATA[import company.cloudtools.util.Utilities
        import com.netsuite.webservices.platform.core.types.RecordType
        import org.mule.module.netsuite.RecordTypeEnum

        // flowVars[ns_record_type] is used for the "get-record" operation
        flowVars["ns_record_type"] = Utilities.findRecordType(payload["ns_record_type"], Arrays.asList(RecordType.values()), 0)
        // flowVars[ns_record_type_enum] is used for the "update record" operation?
        flowVars["ns_record_type_enum"] = Utilities.findRecordTypeEnum(payload["ns_record_type"], Arrays.asList(RecordTypeEnum.values()), 0)

        return payload]]></scripting:script>
                </scripting:transformer>

Utilities Class:

package company.cloudtools.util;

import com.netsuite.webservices.platform.core.types.RecordType;
import org.mule.module.netsuite.RecordTypeEnum;
import java.util.*;

public class Utilities {

    //initial call... findRecordType("downloaditem", RecordType.values(), 0)
    public static RecordType findRecordType(String bad_name, List<RecordType> available_enums, Integer current_character) {}

    //initial call... findRecordTypeEnum("downloaditem", RecordTypeEnum.values(), 0)
    public static RecordTypeEnum findRecordTypeEnum(String bad_name, List<RecordTypeEnum> available_enums, Integer current_character) {}
}

Solution

  • The issue is that CloudHub only supports JRE 1.6 for the version of Mule I am using, Mule 3.5.0. Mule workers that are 3.5.1 above uses the currently supported JRE 1.7. Had the change my applications JRE to get it to work.

    As a later task, I will find out how to make it work with JRE 1.7 (probably have to update the runtime environment to 3.5.1 or above).

    See the Technical / Troubleshooting section at Mulesoft - http://www.mulesoft.org/documentation/display/current/FAQ