
Questions: 23,767 //
Answers: 52,373 //
Contributing Members: 18,028
I am using MULE 4 groovy script where I am getting unable to resolve class org.mule.module.s3.model.KeyVersion. Please let groovy engine recognize this class.
May 17, 2018 at 06:33 PM, ariannaflores answered with:
hi @akchakraborty1,
Thanks for your patience and collaboration.
This problem is because of the Classloading Isolation.
In Mule 3:
"Mule3 basically defined a hierarchical organization of classloaders. Applications are able to see its extensions and the libraries bundled within it and the runtime libraries but can’t access other applications libraries."
And in Mule 4 this change, once APIs are clearly defined we can prevent access to internal classes of the artifact and only make the public API accessible from outside. In order to protect the APIs, we have to build a custom classloading mechanism, so to export java classes use the exportedPackages field of the mule-artifact.json file of your artifact. Have in mind that only complete packages can be exported and not individual classes.
In the next links you have more information:
https://docs.mulesoft.com/mule4-user-guide/v/4.1/about-classloading-isolation
https://docs.mulesoft.com/mule4-user-guide/v/4.1/how-to-export-resources
So, to define a final solution I would like to know why are you using this groovy? Maybe we can find another way to do that using the S3 Connector or other code.
Should you need any further information, please do not hesitate to contact me.
Regards, Arianna.
May 15, 2018 at 05:40 PM, ariannaflores answered with:
Hi @akchakraborty1 ,
Thanks for following up!
Can you provide us the groovy XML and information about what do you need to do?
If you require any further information, feel free to contact me.
Regards, Arianna.
May 16, 2018 at 03:21 PM, akchakraborty1 answered with:
Here is the XML that I am using in MULE 4.
<scripting:code > import org.mule.module.s3.model.KeyVersion
def summeries = payload.getObjectSummaries() def keys = [] summeries.each { if (it.key != "${s3.prefix}") { keys.add(new KeyVersion(it.key))
}
} return keys
I am getting error for import org.mule.module.s3.model.KeyVersion saying class not found.
May 16, 2018 at 03:34 PM, akchakraborty1 answered with:
Also facing the same class loader issue for database connector in MULE 4. using oracle database , But not able to get the driver oracle.jdbc.driver.OracleDriver.
In Mule 3.9 everything run perfectly fine.
Jul 18, 2018 at 01:04 PM, kanishkas answered with:
Did you find a workaround for this issue? I'm facing the same issue when trying to refer to a custom exception class in the Script component.
Jul 18, 2018 at 03:38 AM, kanishkas answered with:
Found the workaround. You can specify the exportedPackages attribute in the mule-artifact.json file where you can list the package of the class you need access to.
Example:
"classLoaderModelLoaderDescriptor": {
"id": "mule",
"attributes": {
"exportedPackages": [
"au.esb.exception"]
}