当我在 CloudHub 中运行应用程序时,Mule 流中的以下脚本出现以下错误。当我在 Anypoint Studio 上运行它时,没有任何问题。
我检查了部署的应用程序存档文件,在 classes 文件夹中是已编译的 company.cloudtools.util.Utilities 类。我不确定为什么 CloudHub 服务器无法找到错误定义的类文件。
错误:
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
Mule流程中的脚本:
<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>
实用程序类:
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) {}
}