Skip to main content

I am experiencing difficulties trying to share the configuration files from one of my projects (my-common-library) to another (my-employee--api). Inside my-common-library I've got a file called common-error-library.xml that I would like to be able to access from inside my-employee-api.

 

To accomplish this I've configured my projects as follows:

 

my-common-error-library pom.xml

<modelVersion>4.0.0</modelVersion>

<groupId>com.myprojects.mulesoft.api</groupId>

<artifactId>my-common-error-library</artifactId>

<version>3.0.0-SNAPSHOT</version>

<packaging>mule-application</packaging>

<name>my-common-error-library</name>

Inside plugins I have

<plugin>

<groupId>org.mule.tools.maven</groupId>

<artifactId>mule-maven-plugin</artifactId>

<version>${mule.maven.plugin.version}</version>

<extensions>true</extensions>

<configuration>

<classifier>mule-application</classifier>

</configuration>

</plugin>

 

Inside Mule Artifact.json

{

"minMuleVersion": "4.2.0",

"classLoaderModelLoaderDescriptor": {

"id": "mule",

"attributes": {

"exportedResources": [

"com/myprojects/mulesoft/api/my-common-error-library/common-error-library.xml"

]

}

}

}

 

my-employee-api

Inside the pom.xml I include the dependency

<dependency>

<groupId>com.myprojects.mulesoft.api</groupId>

<artifactId>my-common-error-library</artifactId>

<version>3.0.0-SNAPSHOT</version>

<classifier>mule-application</classifier>

<scope>provided</scope>

</dependency>

Inside my flow I import the file

<import doc:name="Import common-error-library.xml" file="common-error-library.xml"

doc:id="ca81e812-5dc6-4356-8cb4-dd936791feb8" />

 

I can look up the flows inside the common error library with no issue but when I run the project I get this error:

org.mule.runtime.deployment.model.api.DeploymentException: Failed to deploy artifact [my-employe-api]

Caused by: org.mule.runtime.api.exception.MuleRuntimeException: org.mule.runtime.deployment.model.api.DeploymentInitException: MuleRuntimeException: Could not find imported resource 'common-error-library.xml'

I tried including the dependency as a shared library but that didn't work.

<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.myprojects.mulesoft.api</groupId>

<artifactId>my-common-error-library</artifactId>

</sharedLibrary>

</sharedLibraries>

</configuration>

</plugin>

I'm really not sure what the issue is especially since I can look up the flows inside my flow reference nodes. I've looked at so many guides online but I just can't seem to get past this error.

9 réponses
  1. 28 oct. 2019, 14:36

    The error I was experiencing was due to multiple factors between the configuration of the external library and the and the referencing API.

     

    I had to ensure the poms were correct for both project by setting the library and the dependency to have the "mule-plugin" classifier. This fixed the scope issues Anypoint Studio had.

     

    Then I had to remove the sharedLibrary elements from the pom as they were unnecessary but still causing issues. I removed all added code to the mule-artifact.json file inside the library as I didn't need to export any resources in the first place.

     

    The import error

    org.mule.runtime.deployment.model.api.DeploymentException: Failed to deploy artifact [my-employe-api]

    Caused by: org.mule.runtime.api.exception.MuleRuntimeException: org.mule.runtime.deployment.model.api.DeploymentInitException: MuleRuntimeException: Could not find imported resource 'common-error-library.xml'

    Was due to a conflict between the naming of the global-configuration.xml file between both projects. After renaming the global configuration xml file inside the library to "error-global-configuration", that solved my issue.

     

    Thank you @Gopal E​ , your answer helped me to get to this conclusion.

0/9000