0

I created a plugin on my own that uses a JSON library. The project builds, runs and tests in IntelliJ and on the console.

When I import my plugin to Anypoint Studio I'm getting this error:

ERROR 2021-06-04 06:41:34,587 [[MuleRuntime].uber.01: [p-buchzentrum].get:\delays:p-buchzentrum-config.BLOCKING @2eb68d5] [processor: p-buchzentrum-implementationSub_Flow1/processors/4; event: 23dce8c1-c4ef-11eb-96c7-00e04c682392] org.mule.runtime.core.internal.exception.OnCriticalErrorHandler: 
********************************************************************************
Message               : java.lang.NoClassDefFoundError: org/json/JSONObject
Element               : p-buchzentrum-implementationSub_Flow1/processors/4 @ p-buchzentrum:p-buchzentrum-implementation.xml:22 (Write)
Element DSL           : <bookit:write doc:name="Write" doc:id="1b4c08ce-1f90-459b-821d-78ad2a4f0f19" payload="#[payload]"></bookit:write>
Error type            : MULE:FATAL_JVM_ERROR
FlowStack             : at p-buchzentrum-implementationSub_Flow1(p-buchzentrum-implementationSub_Flow1/processors/4 @ p-buchzentrum:p-buchzentrum-implementation.xml:22 (Write))
at get:\delays:p-buchzentrum-config(get:\delays:p-buchzentrum-config/processors/0 @ p-buchzentrum:p-buchzentrum.xml:130 (Flow Reference))
at p-buchzentrum-main(p-buchzentrum-main/processors/0 @ p-buchzentrum:p-buchzentrum.xml:17)

  (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
********************************************************************************

ERROR 2021-06-04 06:41:34,597 [[MuleRuntime].uber.01: [p-buchzentrum].get:\delays:p-buchzentrum-config.BLOCKING @2eb68d5] [processor: p-buchzentrum-implementationSub_Flow1/processors/4; event: 23dce8c1-c4ef-11eb-96c7-00e04c682392] org.mule.runtime.core.internal.exception.OnCriticalErrorHandler: 
********************************************************************************
Message               : java.lang.NoClassDefFoundError: org/json/JSONObject
Element               : (None)
Element DSL           : (None)
Error type            : MULE:FATAL_JVM_ERROR
FlowStack             : (None)

Both my plugin and my Anypoint studio project contain the library:

<dependency>
    <groupId>com.googlecode.json-simple</groupId>
    <artifactId>json-simple</artifactId>
    <version>1.1.1</version>
</dependency>

My Operations class does not expose any methods that take or return any JSONObjects:

public class BookitOperations {  

    @MediaType(value = ANY, strict = false)    
    public String read(String payload) {    
      return FileHandler.read(payload);    
    }  

    @MediaType(value = ANY, strict = false)    
    public String write(String payload) {    
      return FileHandler.write(payload);    
    }    
}

I tried packing the maven dependency with the assembly-plugin:

<plugin>    
    <artifactId>maven-assembly-plugin</artifactId>    
    <version>3.0.0</version>    
    <configuration>    
        <descriptorRefs>    
            <descriptorRef>jar-with-dependencies</descriptorRef>    
        </descriptorRefs>    
    </configuration>    
</plugin>

But unpacking the plugin with:

jar xf {my-connector.jar}

Shows that this has not worked.

Any help would be appriciated!

Cheers

Peter
  • 1,844
  • 2
  • 31
  • 55
  • 1
    Does this answer your question? [NoClassDefFoundError when running application with custom module](https://stackoverflow.com/questions/67023295/noclassdeffounderror-when-running-application-with-custom-module) – aled Jun 04 '21 at 12:57
  • It helped me in a sense, that I can build the jar with org.json now, but MuleSoft still can't run it. – Peter Jun 07 '21 at 20:20
  • Did you update the version of the library? – aled Jun 07 '21 at 21:31
  • Yes I did, updated to plugin to 1.1.0 and dependency com.google.code.gson gson in version 2.8.6 – Peter Jun 10 '21 at 12:13
  • How were not able to build the module before but you still were able to execute the application? – aled Jun 10 '21 at 12:33
  • The module could be built in json; I can import into the Anypoint, I can builld the application, I can see that the plugin contains gson, but I get a runtime error when calling a flow – Peter Jun 11 '21 at 08:18
  • Please share the structure of the source project. Ie which Java files in which directory. – aled Jun 11 '21 at 13:57

0 Answers0