Mule Groovy脚本文件位置在Studio中工作,但不是独立的

时间:2014-02-12 21:17:54

标签: mule mule-studio

我有一个groovy脚本转换器,它存放在src \ main \ resources下的文件中     <scripting:transformer doc:name="myXform">
<scripting:script engine="Groovy" file="src\main\resources\myTransform.groovy">
</scripting:script>
</scripting:transformer>

我的项目在Mule Studio中按预期工作。当我将它部署到独立的Mule服务器时,它无法部署,因为它找不到相对文件位置 无法从类路径或文件系统加载“src \ main \ resources \ myTransform.groovy”

我有几个问题:
- 这是保持我的常规变换的合适位置吗? - 如何解决问题,因为在部署版本中,src \ main \ resources存在于META-INF下? - 如果是类路径设置,那么我应该更改什么来修复它(.classpath,独立服务器上的系统变量等)?

谢谢。

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
好的,我重新安装了Mule Studio(版本:3.5.0 Build Id:201312091746)并从头开始构建(使用Maven)一个vanilla项目:
    `

<mule xmlns:scripting="http://www.mulesoft.org/schema/mule/scripting" xmlns:file="http://www.mulesoft.org/schema/mule/file" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
    xmlns:spring="http://www.springframework.org/schema/beans" version="EE-3.4.1"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd
http://www.mulesoft.org/schema/mule/scripting http://www.mulesoft.org/schema/mule/scripting/current/mule-scripting.xsd">
    <flow name="gpFlow1" doc:name="gpFlow1">
        <file:inbound-endpoint path="H:\DCH_ESB_Test\InMuleTest" responseTimeout="10000" doc:name="FileIn"/>
        <byte-array-to-string-transformer doc:name="Byte Array to String"/>
        <scripting:transformer doc:name="Groovy">
            <scripting:script engine="Groovy" file="myTransform.groovy"/>
        </scripting:transformer>
        <file:outbound-endpoint path="H:\DCH_ESB_Test\OutMuleTest" responseTimeout="10000" doc:name="FileOut"/>
    </flow>
</mule>`  

myTransform.groovy只包含return payload.toUpperCase()
  我看到的第一件事是Studio不喜欢非pathed文件并在脚本转换器上标记错误:“路径不存在”。
但是,当我在Studio中运行项目时,它可以工作 部署后,我仍然得到:
'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +++++++++++
    +新应用'gp'+
    ++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++
    INFO 2014-02-13 10:05:47,282 [Mule.app.deployer.monitor.1.thread.1] org.mule.module.launcher.MuleApplicationClassLoader:[gp]加载以下罐子:
    =============================
    文件:/ C:/mule-enterprise-standalone-3.3.0/apps/gp/lib/asm-3.1.jar
    文件:/ C:/mule-enterprise-standalone-3.3.0/apps/gp/lib/cloveretl-engine-3.4.1.jar
    文件:/ C:/mule-enterprise-standalone-3.3.0/apps/gp/lib/commons-logging-1.1.1.jar
    文件:/ C:/mule-enterprise-standalone-3.3.0/apps/gp/lib/ftplet-api-1.0.2.jar
    文件:/ C:/mule-enterprise-standalone-3.3.0/apps/gp/lib/ftpserver-core-1.0.2.jar
    文件:/ C:/mule-enterprise-standalone-3.3.0/apps/gp/lib/jaxb-impl-2.1.5.jar
    文件:/ C:/mule-enterprise-standalone-3.3.0/apps/gp/lib/jaxb-xjc-2.2.5.1.jar
    文件:/ C:/mule-enterprise-standalone-3.3.0/apps/gp/lib/jcl-over-slf4j-1.6.1.jar
    文件:/ C:/mule-enterprise-standalone-3.3.0/apps/gp/lib/jsch-0.1.42.jar
    文件:/ C:/mule-enterprise-standalone-3.3.0/apps/gp/lib/mina-core-2.0.0-M6.jar
    文件:/ C:/mule-enterprise-standalone-3.3.0/apps/gp/lib/mockito-all-1.9.0.jar
    文件:/ C:/mule-enterprise-standalone-3.3.0/apps/gp/lib/mockobjects-core-0.09.jar
    文件:/ C:/mule-enterprise-standalone-3.3.0/apps/gp/lib/mule-core-ee-3.4.1.jar
    文件:/ C:/mule-enterprise-standalone-3.3.0/apps/gp/lib/mule-module-boot-ee-3.4.1.jar
    文件:/ C:/mule-enterprise-standalone-3.3.0/apps/gp/lib/slf4j-api-1.6.1.jar
    文件:/ C:/mule-enterprise-standalone-3.3.0/apps/gp/lib/slf4j-log4j12-1.6.1.jar
    文件:/ C:/mule-enterprise-standalone-3.3.0/apps/gp/lib/spring-tx-3.0.6.RELEASE.jar
    文件:/ C:/mule-enterprise-standalone-3.3.0/apps/gp/lib/spring-web-3.0.6.RELEASE.jar
    文件:/ C:/mule-enterprise-standalone-3.3.0/apps/gp/lib/sshd-core-0.6.0.jar
    =============================

ERROR 2014-02-13 10:05:49,294 [Mule.app.deployer.monitor.1.thread.1] org.mule.module.launcher.DeploymentService: Failed to deploy application archive: gp.zip  
org.mule.module.launcher.DeploymentInitException: InitialisationException: Failed to load "myTransform.groovy" from classpath or file system  
    at org.mule.module.launcher.application.DefaultMuleApplication.init(DefaultMuleApplication.java:220)  
    at org.mule.module.launcher.application.ApplicationWrapper.init(ApplicationWrapper.java:64)  
    at org.mule.module.launcher.DefaultMuleDeployer.deploy(DefaultMuleDeployer.java:46)  
    at org.mule.module.launcher.DeploymentService.guardedDeploy(DeploymentService.java:398)  
    at org.mule.module.launcher.DeploymentService.deploy(DeploymentService.java:365)  `  

Studio中的.classpath文件如下所示:
    <classpath>
<classpathentry kind="src" path="src/main/app" excluding="**/*.java"/>
<classpathentry kind="src" path="src/main/java"/>
<classpathentry kind="src" path="src/main/resources" excluding="**/*.java"/>
<classpathentry kind="src" path="src/test/java" output="target/test-classes"/>
<classpathentry kind="src" path="src/test/resources" output="target/test-classes" excluding="**/*.java"/>
<classpathentry kind="output" path="target/classes"/>
<classpathentry kind="con" path="MULE_RUNTIME"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="var" path="M2_REPO/asm/asm/3.1/asm-3.1.jar"/>
<classpathentry kind="var" path="M2_REPO/com/cloveretl/cloveretl-engine/3.4.1/cloveretl-engine-3.4.1.jar"/>
<classpathentry kind="var" path="M2_REPO/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar"/>
<classpathentry kind="var" path="M2_REPO/org/apache/ftpserver/ftplet-api/1.0.2/ftplet-api-1.0.2.jar"/>
<classpathentry kind="var" path="M2_REPO/org/apache/ftpserver/ftpserver-core/1.0.2/ftpserver-core-1.0.2.jar"/>
<classpathentry kind="var" path="M2_REPO/com/sun/xml/bind/jaxb-impl/2.1.5/jaxb-impl-2.1.5.jar"/>
<classpathentry kind="var" path="M2_REPO/com/sun/xml/bind/jaxb-xjc/2.2.5.1/jaxb-xjc-2.2.5.1.jar"/>
<classpathentry kind="var" path="M2_REPO/org/slf4j/jcl-over-slf4j/1.6.1/jcl-over-slf4j-1.6.1.jar"/>
<classpathentry kind="var" path="M2_REPO/com/jcraft/jsch/0.1.42/jsch-0.1.42.jar"/>
<classpathentry kind="var" path="M2_REPO/org/apache/mina/mina-core/2.0.0-M6/mina-core-2.0.0-M6.jar"/>
<classpathentry kind="var" path="M2_REPO/org/mockito/mockito-all/1.9.0/mockito-all-1.9.0.jar"/>
<classpathentry kind="var" path="M2_REPO/mockobjects/mockobjects-core/0.09/mockobjects-core-0.09.jar"/>
<classpathentry kind="var" path="M2_REPO/com/mulesoft/muleesb/mule-core-ee/3.4.1/mule-core-ee-3.4.1.jar"/>
<classpathentry kind="var" path="M2_REPO/com/mulesoft/muleesb/modules/mule-module-boot-ee/3.4.1/mule-module-boot-ee-3.4.1.jar"/>
<classpathentry kind="var" path="M2_REPO/org/slf4j/slf4j-api/1.6.1/slf4j-api-1.6.1.jar"/>
<classpathentry kind="var" path="M2_REPO/org/slf4j/slf4j-log4j12/1.6.1/slf4j-log4j12-1.6.1.jar"/>
<classpathentry kind="var" path="M2_REPO/org/springframework/spring-tx/3.0.6.RELEASE/spring-tx-3.0.6.RELEASE.jar"/>
<classpathentry kind="var" path="M2_REPO/org/springframework/spring-web/3.0.6.RELEASE/spring-web-3.0.6.RELEASE.jar"/>
<classpathentry kind="var" path="M2_REPO/org/apache/sshd/sshd-core/0.6.0/sshd-core-0.6.0.jar"/>
</classpath>

在导出zip文件中,myTransform.groovy位于:
gp.zip \ META-INF \ SRC \主\资源\
我没有重新安装我的独立。

谢谢, - 唐

3 个答案:

答案 0 :(得分:4)

我遇到了类似的问题,我可以责怪骡子的例子,我试图使用解析模板在mule studio上部署好但是当我独自尝试时。该示例在/src/main/resources/responseXml.template上的模板的xml中设置位置,该工具在mule studio上正常工作。但是单独站立mule无法找到模板并且无法部署。我发现这是 PROJECT&S结构相关问题,而不是mule的问题(google io exception / src / main / resource)。似乎当一个生成可部署文件资源文件移动到项目的根目录,并且位置应该只是responseXml.template(或whateverresource.file)而没有路径时,这对我在studio和standalone上工作。 刚刚在工作室的groovy上成功测试过,我创建了

/src/main/resources/example.groovy

和xml:

<scripting:script engine="Groovy" file="example.groovy"/>

在几个小时内我会用独立的groovy来测试....

答案 1 :(得分:0)

您有正确的文件夹来放置Mule脚本,但您不应该包含该文件夹的路径,只需“myTransform.groovy”。在Studio中右键单击该项目,然后查看属性 - &gt; Java构建路径 - &gt;源,然后查看Mule Standalone中已部署应用程序的结构。这应该让你知道它是如何工作的。

编辑:

您的问题似乎是,您的资源未包含在您的zip的“classes”文件夹中。你需要它们,而不是META-INF子文件夹。我只能重现一个失败的场景:如果你在Mule Studio中创建一个项目并导出它而不先运行它或用命令行Maven构建它,那么项目可能不会在导出之前自动构建,而zip将不包括应该是资源的类文件夹。在导出zip之前,尝试使用Maven Run with Mule Application运行应用程序。如果这没有帮助,请尝试使用mvn package在命令行中构建应用程序。命令行Maven将在您的应用程序的“target”文件夹中创建zip。

答案 2 :(得分:0)

这是我出错的地方,我将myTransform.groovy文件放入src / main / resources而不是通过用户界面导入。
导入文件后,它被部署在classes文件夹中 啊。

真诚地感谢您的提示。
- 唐