3
votes

I have a groovy scripting transformer that is in a file stored under src\main\resources.
<scripting:transformer doc:name="myXform">
<scripting:script engine="Groovy" file="src\main\resources\myTransform.groovy">
</scripting:script>
</scripting:transformer>

My project works as expected within Mule Studio. When I deploy it to the standalone Mule server it fails to deploy as it cannot find the relative file location.
Failed to load "src\main\resources\myTransform.groovy" from classpath or file system

I have a couple of questions:
- Is this the appropriate place to keep my groovy transforms?
- How do I fix the problem because in the deployed version the src\main\resources exists under META-INF?
- If it is a classpath setting then what do I change to fix it (.classpath, system variable on standalone server, etc.) ?

Thank you.

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Ok, I reinstalled Mule Studio (Version: 3.5.0 Build Id: 201312091746) and built (using Maven) a vanilla project from scratch:
`

<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 simply contains return payload.toUpperCase()
The first thing I see is Studio does not like the non-pathed file and flags an error on the scripting transformer of: "Path does not exist".
However, when I run the project within Studio it works.
When deployed I still get:
` ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ New app 'gp' +
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
INFO 2014-02-13 10:05:47,282 [Mule.app.deployer.monitor.1.thread.1] org.mule.module.launcher.MuleApplicationClassLoader: [gp] Loading the following jars:
=============================
file:/C:/mule-enterprise-standalone-3.3.0/apps/gp/lib/asm-3.1.jar
file:/C:/mule-enterprise-standalone-3.3.0/apps/gp/lib/cloveretl-engine-3.4.1.jar
file:/C:/mule-enterprise-standalone-3.3.0/apps/gp/lib/commons-logging-1.1.1.jar
file:/C:/mule-enterprise-standalone-3.3.0/apps/gp/lib/ftplet-api-1.0.2.jar
file:/C:/mule-enterprise-standalone-3.3.0/apps/gp/lib/ftpserver-core-1.0.2.jar
file:/C:/mule-enterprise-standalone-3.3.0/apps/gp/lib/jaxb-impl-2.1.5.jar
file:/C:/mule-enterprise-standalone-3.3.0/apps/gp/lib/jaxb-xjc-2.2.5.1.jar
file:/C:/mule-enterprise-standalone-3.3.0/apps/gp/lib/jcl-over-slf4j-1.6.1.jar
file:/C:/mule-enterprise-standalone-3.3.0/apps/gp/lib/jsch-0.1.42.jar
file:/C:/mule-enterprise-standalone-3.3.0/apps/gp/lib/mina-core-2.0.0-M6.jar
file:/C:/mule-enterprise-standalone-3.3.0/apps/gp/lib/mockito-all-1.9.0.jar
file:/C:/mule-enterprise-standalone-3.3.0/apps/gp/lib/mockobjects-core-0.09.jar
file:/C:/mule-enterprise-standalone-3.3.0/apps/gp/lib/mule-core-ee-3.4.1.jar
file:/C:/mule-enterprise-standalone-3.3.0/apps/gp/lib/mule-module-boot-ee-3.4.1.jar
file:/C:/mule-enterprise-standalone-3.3.0/apps/gp/lib/slf4j-api-1.6.1.jar
file:/C:/mule-enterprise-standalone-3.3.0/apps/gp/lib/slf4j-log4j12-1.6.1.jar
file:/C:/mule-enterprise-standalone-3.3.0/apps/gp/lib/spring-tx-3.0.6.RELEASE.jar
file:/C:/mule-enterprise-standalone-3.3.0/apps/gp/lib/spring-web-3.0.6.RELEASE.jar
file:/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)  `  

My .classpath file within Studio looks like:
<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>

In the export zip file, myTransform.groovy is found under:
gp.zip\META-INF\src\main\resources\
I did not reinstall my standalone.

Thanks, -- Don

3

3 Answers

5
votes

I came across a similar issue, and I can blame mule examples, I was trying to use parse template deployed ok on mule studio but when I tried stand alone. The example set the location in the xml of template on /src/main/resources/responseXml.template which works ok on mule studio. However on stand alone mule cannot find the template and fails to deploy. I found this is PROJECT'S STRUCTURE related issue rather than mule's issue (google io exception /src/main/resource). It seems that when one generate the deployable file resource files are move to the project's root, and location should be just responseXml.template (or whateverresource.file) and no path, this worked for me on studio and standalone. Just tested successfully with groovy on studio, I created

/src/main/resources/example.groovy

and on the xml:

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

in a couple of hours I will test it with groovy on standalone....

0
votes

You have the correct folder to put a Mule script, but you should not include the path to the folder, just "myTransform.groovy". Right-click the project in Studio and see Properties ->Java Build Path -> Source, and then look at the structure of the deployed application in Mule Standalone. That should give you an idea of how this works.

EDIT:

Your problem seems to be, that your resources are not included in the "classes" folder of your zip. You need them there, not in the META-INF subfolders. I could reproduce only one failing scenario: if you create a project in Mule Studio and export it without first running it or building it with command line Maven, the project might not be automatically built before the export, and the zip would then not include the classes folder where your resources are supposed to be. Try running your application with Run as Mule Application with Maven before exporting the zip. If that is not helping, try to build your application in command line with mvn package. Command line Maven will create the zip in the "target" folder of your application.

0
votes

Here is where I went wrong, I put the myTransform.groovy file into the src/main/resources rather than importing it through the user interface.
Once I did import the file it was deployed in the classes folder.
Ugh.

Sincere thanks for the tips.
-- Don