You have an application and you are using the Java component to invoke methods or create instances of classes, and you receive an error that contains "JAVA: CLASS_NOT_FOUND" as shown here:
org.mule.runtime.core.internal.exception.OnErrorPropagateHandler: ******************************************************************************** Message : Failed to load Class with name [com.mycompany.MyClass]. Class not found. Error type : JAVA:CLASS_NOT_FOUND Element : testFlow1/processors/0 @ test:test.xml:43 (New) Element XML : <java:new doc:name="New" doc:id="df09b56d-3d86-4a60-aa52-f421393d82a7" class="com.mycompany.MyClass" constructor="DateTime()"></java:new> (set debug level logging or '-Dmule.verbose.exceptions=true' for everything) ********************************************************************************
Mule 4 introduced class-loading isolation, which means that unless the resources have been shared, they won't be available to be used by the connectors. This includes drivers, external libraries, and Java code included in the project. You can find more information on this feature in the Help on Class Loading Isolation.
Depending on where the class is packaged, there are different alternatives to address this error.
In this case, you need to follow the steps mentioned in the Help on How to Export Java Classes.
In this case, you need to add the dependency to your project and then share it using the mule-maven plugin. For example, if I have the class com.mycompany.MyClass in a mavenized jar, then I will need to do as follows:
<dependencies>
<!-- more dependencies -->
<dependency>
<groupId>com.mycompany</groupId>
<artifactId>my-library</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
<plugin>
<groupId>org.mule.tools.maven</groupId>
<artifactId>mule-maven-plugin</artifactId>
<version>${mule.maven.plugin.version}</version>
<extensions>true</extensions>
<configuration>
<sharedLibraries>
<!-- other shared libraries -->
<sharedLibrary>
<groupId>com.mycompany</groupId>
<artifactId>my-library</artifactId>
</sharedLibrary>
</sharedLibraries>
</configuration>
</plugin>
001118381

We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings.
Privacy Statement
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.