I'm trying to use a java library on my mule application. Following this tutorial, i successfully imported and invoked the extended StringUtils class in Datawave. But when i do the same for my own library, it fails.
Here the steps o followed from the tutorial:
Add the dependency to my
mylib
artifact:<dependency> <groupId>com.example.shared</groupId> <artifactId>mylib</artifactId> <version>0.0.1-SNAPSHOT</version> </dependency>
configure the maven plugin to use the shared lib:
<plugin> <groupId>org.mule.tools.maven</groupId> <artifactId>mule-maven-plugin</artifactId> <version>${mule.maven.plugin.version}</version> <extensions>true</extensions> <configuration> <sharedLibraries> <sharedLibrary> <groupId>com.example.shared</groupId> <artifactId>mylib</artifactId> </sharedLibrary> </sharedLibraries> </configuration> </plugin>
Add the package
com.example.shared
to the class loader:{ "minMuleVersion": "4.4.0", "classLoaderModelLoaderDescriptor": { "id": "mule", "attributes": { "exportedPackages": [ "com.example.shared" ] } } }
Yet, when i try to call it from Datawave
, in the same way presented by the tutorial:
example: java!com::example::shared::MyUtils::foo()
i get:
Unable to resolve reference of: `com::example::shared::MyUtils::foo`. at 7 : 7" evaluating expression: "%dw 2.0
Note: The Anypoint Studio
shows an error in the Datawave
preview window but it builds and runs successfully.
The same kind of error is present when using StringUtills
from common-lang3
library, that is used on the tutorial example.
Update: Here is the java code:
package com.example.shared;
public class MyUtils {
public static String foo() {
return "I'm here.";
}
}