I am using Anypoint generated connector to call other apis from my main Mule API.
While running munits by mocking the connectors and using munit:store
to store payload to a key and retrieve from the key to verify, I am getting this error.
An Object Store was already defined for name token-manager-store-tokenManagerConfig-System_API_Config
Could someone explain what might be causing this issue?
Here is the full Error:
INFO 2021-03-10 20:31:36,919 [munit.01] org.mule.munit.runner.remote.api.server.RunnerServer: {} Waiting for client connection
INFO 2021-03-10 20:31:36,919 [munit.01] org.mule.munit.runner.remote.api.server.RunnerServer: {} Client connection received from view-localhost - true
INFO 2021-03-10 20:31:37,082 [munit.01] org.mule.runtime.core.privileged.lifecycle.AbstractLifecycleManager: {} Stopping Bean: org.mule.runtime.module.extension.internal.runtime.config.DynamicConfigurationProvider-Logging_Config_in_Error_Handlers
INFO 2021-03-10 20:31:37,085 [munit.01] org.mule.runtime.core.privileged.lifecycle.AbstractLifecycleManager: {} Disposing Bean: org.mule.runtime.module.extension.internal.runtime.config.DynamicConfigurationProvider-Logging_Config_in_Error_Handlers
INFO 2021-03-10 20:31:37,089 [munit.01] org.mule.runtime.core.privileged.lifecycle.AbstractLifecycleManager: {} Stopping Bean: org.mule.runtime.module.extension.internal.runtime.config.ConfigurationProviderToolingAdapter-system-api-httpreq-config-System_API_Config
INFO 2021-03-10 20:31:37,090 [munit.01] org.mule.runtime.core.privileged.lifecycle.AbstractLifecycleManager: {} Disposing Bean: org.mule.runtime.module.extension.internal.runtime.config.ConfigurationProviderToolingAdapter-system-api-httpreq-config-System_API_Config
INFO 2021-03-10 20:31:37,093 [munit.01] org.mule.runtime.core.privileged.lifecycle.AbstractLifecycleManager: {} Stopping Bean: org.mule.runtime.module.extension.internal.runtime.config.ConfigurationProviderToolingAdapter-Snowflake_E2E_Database_Config
INFO 2021-03-10 20:31:37,093 [munit.01] org.mule.runtime.core.privileged.lifecycle.AbstractLifecycleManager: {} Disposing Bean: org.mule.runtime.module.extension.internal.runtime.config.ConfigurationProviderToolingAdapter-Snowflake_E2E_Database_Config
org.mule.runtime.api.exception.MuleRuntimeException: org.mule.runtime.api.lifecycle.LifecycleException: Failed to invoke lifecycle phase "initialise" on object: org.mule.extension.oauth2.api.tokenmanager.TokenManagerConfig$$EnhancerByCGLIB$$edc0e215@748b8fa2
Caused by: org.mule.runtime.api.lifecycle.LifecycleException: Failed to invoke lifecycle phase "initialise" on object: org.mule.extension.oauth2.api.tokenmanager.TokenManagerConfig$$EnhancerByCGLIB$$edc0e215@748b8fa2
Caused by: java.lang.IllegalArgumentException: An Object Store was already defined for name token-manager-store-tokenManagerConfig-System_API_Config
at org.mule.runtime.core.internal.util.store.MuleObjectStoreManager.createObjectStore(MuleObjectStoreManager.java:127)
at org.mule.extension.oauth2.api.tokenmanager.TokenManagerConfig.initialise(TokenManagerConfig.java:103)
at org.mule.runtime.core.api.lifecycle.LifecycleUtils.initialiseIfNeeded(LifecycleUtils.java:56)
at org.mule.runtime.core.api.util.func.CheckedConsumer.accept(CheckedConsumer.java:19)
at org.mule.runtime.core.internal.lifecycle.phases.DefaultLifecyclePhase.applyLifecycle(DefaultLifecyclePhase.java:115)
at org.mule.runtime.core.internal.lifecycle.phases.MuleContextInitialisePhase.applyLifecycle(MuleContextInitialisePhase.java:73)
at org.mule.runtime.config.internal.SpringRegistryLifecycleManager$SpringContextInitialisePhase.applyLifecycle(SpringRegistryLifecycleManager.java:128)
at org.mule.runtime.core.internal.lifecycle.RegistryLifecycleManager.doApplyLifecycle(RegistryLifecycleManager.java:175)
at org.mule.runtime.core.internal.lifecycle.RegistryLifecycleManager.applyPhase(RegistryLifecycleManager.java:146)
at org.mule.runtime.config.internal.SpringRegistry.applyLifecycle(SpringRegistry.java:289)
at org.mule.runtime.core.internal.registry.MuleRegistryHelper.applyLifecycle(MuleRegistryHelper.java:339)
at org.mule.runtime.config.internal.LazyMuleArtifactContext.initializeComponents(LazyMuleArtifactContext.java:285)
at org.mule.runtime.config.internal.LazyMuleArtifactContext.lambda$applyLifecycle$4(LazyMuleArtifactContext.java:248)
at org.mule.runtime.core.internal.context.DefaultMuleContext.withLifecycleLock(DefaultMuleContext.java:531)
at org.mule.runtime.config.internal.LazyMuleArtifactContext.applyLifecycle(LazyMuleArtifactContext.java:246)
at org.mule.runtime.config.internal.LazyMuleArtifactContext.initializeComponents(LazyMuleArtifactContext.java:327)
at org.mule.runtime.config.internal.LazyMuleArtifactContext.initializeComponents(LazyMuleArtifactContext.java:315)
at org.mule.munit.runner.config.TestComponentLocator.initializeComponents(TestComponentLocator.java:63)
at org.mule.munit.runner.model.builders.SuiteBuilder.build(SuiteBuilder.java:78)
at org.mule.munit.runner.remote.api.server.RunMessageHandler.buildSuite(RunMessageHandler.java:108)
at org.mule.munit.runner.remote.api.server.RunMessageHandler.parseSuiteMessage(RunMessageHandler.java:94)
at org.mule.munit.runner.remote.api.server.RunMessageHandler.parseAndRun(RunMessageHandler.java:81)
at org.mule.munit.runner.remote.api.server.RunMessageHandler.handle(RunMessageHandler.java:75)
at org.mule.munit.runner.remote.api.server.RunnerServer.handleClientMessage(RunnerServer.java:145)
at org.mule.munit.runner.remote.api.server.RunnerServer.run(RunnerServer.java:91)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at org.mule.service.scheduler.internal.AbstractRunnableFutureDecorator.doRun(AbstractRunnableFutureDecorator.java:111)
at org.mule.service.scheduler.internal.RunnableFutureDecorator.run(RunnableFutureDecorator.java:54)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Update: Here are some screenshots of the Munit Test and the generated connector api module xml file. Basically I am trying to store the payload passed to the connector(passed via a transform message) in a objectstore key using the munit-tools:store
. The generated connector endpoint has a section output as shown below
I am taking the value stored in this variable and store it into this munit-tools:store
key as shown below.
I am not encountering this problem if I ran my Munit Test suite one at a time. But when ran all together in a single go, It fails.
Now look at this screenshot of the generated connector module xml.
It is possible that the error is happening due to the oauth config in line number 38 and 54. I believe that an Oauth call is happening to the connector before the mock, and it is storing a token value into the shown token manager config for each test suite. Since it already created and stored some value for the given token configuration, it is not allowing an objectstore create for the second time. But one thing is for sure, we cannot edit any generated connector xmls.
Here is how the generated xml and the munit test case looks in studio. Sorry, I cannot paste the source code here.
munit-tools:store
which is separate from an actual objectstore connector. So there is no pom dependency available by default. I even tried applying a dependency for the sake of having it. Tried clearing the store usingmunit-tools:clear-stored-data
. But nothing works. I will update the question with a Snapshot. – Thinker-101