问题
When i try to run Mule application I get[1],
Im not using gauva library as dependency in my pom.pacakging is defined as
<packaging>mule-application</packaging>
Why I get this error? How can I overcome? Im using anypoint studio version =7.4.1 which uses mule runtime 4.2.2
[1]
Initializing app 'admin-api-v1' +
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
ERROR 2020-02-04 09:47:08,034 [WrapperListener_start_runner] [event: ] org.mule.runtime.module.deployment.impl.internal.application.DefaultMuleApplication: java.lang.NoClassDefFoundError: com/google/common/cache/CacheLoader
java.lang.ClassNotFoundException: com.google.common.cache.CacheLoader
at java.net.URLClassLoader.findClass(URLClassLoader.java:382) ~[?:1.8.0_242]
at org.mule.runtime.module.artifact.api.classloader.FineGrainedControlClassLoader.findLocalClass(FineGrainedControlClassLoader.java:173) ~[mule-module-artifact-4.2.2.jar:4.2.2]
at org.mule.runtime.module.artifact.api.classloader.FineGrainedControlClassLoader.loadClass(FineGrainedControlClassLoader.java:90) ~[mule-module-artifact-4.2.2.jar:4.2.2]
at org.mule.runtime.module.artifact.api.classloader.MuleArtifactClassLoader.loadClass(MuleArtifactClassLoader.java:255) ~[mule-module-artifact-4.2.2.jar:4.2.2]
at java.lang.ClassLoader.loadClass(ClassLoader.java:352) ~[?:1.8.0_242]
at java.lang.Class.getDeclaredFields0(Native Method) ~[?:1.8.0_242]
at java.lang.Class.privateGetDeclaredFields(Class.java:2583) ~[?:1.8.0_242]
at java.lang.Class.getDeclaredFields(Class.java:1916) ~[?:1.8.0_242]
at org.mule.runtime.module.extension.internal.util.IntrospectionUtils.lambda$getFieldsStream$25(IntrospectionUtils.java:995) ~[mule-module-extensions-support-4.2.2.jar:4.2.2]
at java.util.stream.ReferencePipeline$7$1.accept(ReferencePipeline.java:269) ~[?:1.8.0_242]
at java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:948) ~[?:1.8.0_242]
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:482) ~[?:1.8.0_242]
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472) ~[?:1.8.0_242]
at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708) ~[?:1.8.0_242]
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[?:1.8.0_242]
at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:566) ~[?:1.8.0_242]
at org.mule.runtime.module.extension.internal.util.IntrospectionUtils.getFields(IntrospectionUtils.java:968) ~[mule-module-extensions-support-4.2.2.jar:4.2.2]
at org.mule.runtime.module.extension.internal.loader.java.type.runtime.TypeWrapper.getFields(TypeWrapper.java:120) ~[mule-module-extensions-support-4.2.2.jar:4.2.2]
at org.mule.runtime.module.extension.internal.loader.java.type.runtime.TypeWrapper.getAnnotatedFields(TypeWrapper.java:149) ~[mule-module-extensions-support-4.2.2.jar:4.2.2]
at org.mule.runtime.module.extension.internal.loader.java.type.runtime.ConfigurationWrapper.<init>(ConfigurationWrapper.java:32) ~[mule-module-extensions-support-4.2.2.jar:4.2.2]
at org.mule.runtime.module.extension.internal.loader.java.type.runtime.ExtensionTypeWrapper.lambda$getConfigurations$1(ExtensionTypeWrapper.java:50) ~[mule-module-extensions-support-4.2.2.jar:4.2.2]
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193) ~[?:1.8.0_242]
at java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:948) ~[?:1.8.0_242]
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:482) ~[?:1.8.0_242]
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472) ~[?:1.8.0_242]
at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708) ~[?:1.8.0_242]
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[?:1.8.0_242]
at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:566) ~[?:1.8.0_242]
at org.mule.runtime.module.extension.internal.loader.java.type.runtime.ExtensionTypeWrapper.getConfigurations(ExtensionTypeWrapper.java:51) ~[mule-module-extensions-support-4.2.2.jar:4.2.2]
at org.mule.runtime.module.extension.internal.loader.java.ConfigModelLoaderDelegate.declareConfigurations(ConfigModelLoaderDelegate.java:47) ~[mule-module-extensions-support-4.2.2.jar:4.2.2]
at org.mule.runtime.module.extension.internal.loader.java.DefaultJavaModelLoaderDelegate.declare(DefaultJavaModelLoaderDelegate.java:119) ~[mule-module-extensions-support-4.2.2.jar:4.2.2]
at org.mule.runtime.module.extension.api.loader.AbstractJavaExtensionModelLoader.declareExtension(AbstractJavaExtensionModelLoader.java:186) ~[mule-module-extensions-support-4.2.2.jar:4.2.2]
at org.mule.runtime.extension.api.loader.ExtensionModelLoader.loadExtensionModel(ExtensionModelLoader.java:71) ~[mule-extensions-api-1.2.2.jar:?]
at org.mule.runtime.module.deployment.impl.internal.artifact.ExtensionModelDiscoverer.discoverExtensionThroughJsonDescriber(ExtensionModelDiscoverer.java:125) ~[mule-module-deployment-model-impl-4.2.2.jar:4.2.2]
at org.mule.runtime.module.deployment.impl.internal.artifact.ExtensionModelDiscoverer.lambda$null$0(ExtensionModelDiscoverer.java:76) ~[mule-module-deployment-model-impl-4.2.2.jar:4.2.2]
at java.util.Optional.map(Optional.java:215) ~[?:1.8.0_242]
at org.mule.runtime.module.deployment.impl.internal.artifact.ExtensionModelDiscoverer.lambda$discoverPluginsExtensionModels$1(ExtensionModelDiscoverer.java:76) ~[mule-module-deployment-model-impl-4.2.2.jar:4.2.2]
at java.util.ArrayList.forEach(ArrayList.java:1257) ~[?:1.8.0_242]
at org.mule.runtime.module.deployment.impl.internal.artifact.ExtensionModelDiscoverer.discoverPluginsExtensionModels(ExtensionModelDiscoverer.java:68) ~[mule-module-deployment-model-impl-4.2.2.jar:4.2.2]
at org.mule.runtime.module.deployment.impl.internal.policy.ArtifactExtensionManagerFactory.create(ArtifactExtensionManagerFactory.java:70) ~[mule-module-deployment-model-impl-4.2.2.jar:4.2.2]
at org.mule.runtime.module.deployment.impl.internal.policy.ArtifactExtensionManagerFactory.create(ArtifactExtensionManagerFactory.java:61) ~[mule-module-deployment-model-impl-4.2.2.jar:4.2.2]
at org.mule.runtime.module.deployment.impl.internal.artifact.ArtifactExtensionManagerConfigurationBuilder.doConfigure(ArtifactExtensionManagerConfigurationBuilder.java:48) ~[mule-module-deployment-model-impl-4.2.2.jar:4.2.2]
at org.mule.runtime.core.api.config.builders.AbstractConfigurationBuilder.configure(AbstractConfigurationBuilder.java:53) ~[mule-core-4.2.2.jar:4.2.2]
at org.mule.runtime.core.api.context.DefaultMuleContextFactory$1.configure(DefaultMuleContextFactory.java:65) ~[mule-core-4.2.2.jar:4.2.2]
at org.mule.runtime.core.api.context.DefaultMuleContextFactory.doCreateMuleContext(DefaultMuleContextFactory.java:187) ~[mule-core-4.2.2.jar:4.2.2]
at org.mule.runtime.core.api.context.DefaultMuleContextFactory.createMuleContext(DefaultMuleContextFactory.java:59) ~[mule-core-4.2.2.jar:4.2.2]
at org.mule.runtime.module.deployment.impl.internal.artifact.ArtifactContextBuilder.lambda$build$2(ArtifactContextBuilder.java:499) ~[mule-module-deployment-model-impl-4.2.2.jar:4.2.2]
at org.mule.runtime.core.api.util.ExceptionUtils.tryExpecting(ExceptionUtils.java:227) ~[mule-core-4.2.2.jar:4.2.2]
at org.mule.runtime.core.api.util.ClassUtils.withContextClassLoader(ClassUtils.java:915) ~[mule-core-4.2.2.jar:4.2.2]
at org.mule.runtime.core.api.util.ClassUtils.withContextClassLoader(ClassUtils.java:879) ~[mule-core-4.2.2.jar:4.2.2]
at org.mule.runtime.module.deployment.impl.internal.artifact.ArtifactContextBuilder.build(ArtifactContextBuilder.java:409) ~[mule-module-deployment-model-impl-4.2.2.jar:4.2.2]
at org.mule.runtime.module.deployment.impl.internal.application.DefaultMuleApplication.doInit(DefaultMuleApplication.java:239) ~[mule-module-deployment-model-impl-4.2.2.jar:4.2.2]
at org.mule.runtime.module.deployment.impl.internal.application.DefaultMuleApplication.init(DefaultMuleApplication.java:207) ~[mule-module-deployment-model-impl-4.2.2.jar:4.2.2]
at org.mule.runtime.core.api.util.ClassUtils.lambda$withContextClassLoader$9(ClassUtils.java:860) ~[mule-core-4.2.2.jar:4.2.2]
at org.mule.runtime.core.api.util.ExceptionUtils.tryExpecting(ExceptionUtils.java:227) [mule-core-4.2.2.jar:4.2.2]
at org.mule.runtime.core.api.util.ClassUtils.withContextClassLoader(ClassUtils.java:915) [mule-core-4.2.2.jar:4.2.2]
at org.mule.runtime.core.api.util.ClassUtils.withContextClassLoader(ClassUtils.java:879) [mule-core-4.2.2.jar:4.2.2]
at org.mule.runtime.core.api.util.ClassUtils.withContextClassLoader(ClassUtils.java:859) [mule-core-4.2.2.jar:4.2.2]
at org.mule.runtime.module.deployment.impl.internal.artifact.DeployableArtifactWrapper.executeWithinArtifactClassLoader(DeployableArtifactWrapper.java:140) [mule-module-deployment-model-impl-4.2.2.jar:4.2.2]
at org.mule.runtime.module.deployment.impl.internal.artifact.DeployableArtifactWrapper.init(DeployableArtifactWrapper.java:83) [mule-module-deployment-model-impl-4.2.2.jar:4.2.2]
at org.mule.runtime.module.deployment.internal.DefaultArtifactDeployer.doInit(DefaultArtifactDeployer.java:63) [mule-module-deployment-4.2.2.jar:4.2.2]
at org.mule.runtime.module.deployment.internal.DefaultArtifactDeployer.deploy(DefaultArtifactDeployer.java:28) [mule-module-deployment-4.2.2.jar:4.2.2]
at org.mule.runtime.module.deployment.internal.DefaultArchiveDeployer.deployArtifact(DefaultArchiveDeployer.java:448) [mule-module-deployment-4.2.2.jar:4.2.2]
at org.mule.runtime.module.deployment.internal.DefaultArchiveDeployer.internalDeployPackagedArtifact(DefaultArchiveDeployer.java:530) [mule-module-deployment-4.2.2.jar:4.2.2]
at org.mule.runtime.module.deployment.internal.DefaultArchiveDeployer.deployOrRedeployPackagedArtifact(DefaultArchiveDeployer.java:495) [mule-module-deployment-4.2.2.jar:4.2.2]
at org.mule.runtime.module.deployment.internal.DefaultArchiveDeployer.deployPackagedArtifact(DefaultArchiveDeployer.java:377) [mule-module-deployment-4.2.2.jar:4.2.2]
at org.mule.runtime.module.deployment.internal.DefaultArchiveDeployer.deployPackagedArtifact(DefaultArchiveDeployer.java:53) [mule-module-deployment-4.2.2.jar:4.2.2]
at org.mule.runtime.module.deployment.internal.DeploymentDirectoryWatcher.deployPackedApps(DeploymentDirectoryWatcher.java:241) [mule-module-deployment-4.2.2.jar:4.2.2]
at org.mule.runtime.module.deployment.internal.DeploymentDirectoryWatcher.run(DeploymentDirectoryWatcher.java:312) [mule-module-deployment-4.2.2.jar:4.2.2]
at org.mule.runtime.module.deployment.internal.DeploymentDirectoryWatcher.start(DeploymentDirectoryWatcher.java:153) [mule-module-deployment-4.2.2.jar:4.2.2]
at org.mule.runtime.module.deployment.internal.MuleDeploymentService.start(MuleDeploymentService.java:143) [mule-module-deployment-4.2.2.jar:4.2.2]
at org.mule.runtime.module.launcher.MuleContainer.start(MuleContainer.java:252) [mule-module-launcher-4.2.2.jar:4.2.2]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_242]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_242]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_242]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_242]
at org.mule.runtime.module.reboot.internal.MuleContainerWrapper.start(MuleContainerWrapper.java:49) [mule-module-boot-ee-4.2.2.jar:4.2.2]
at org.tanukisoftware.wrapper.WrapperManager$11.run(WrapperManager.java:4429) [wrapper-3.5.37.jar:3.5.37]
INFO 2020-02-04 09:47:08,041 [WrapperListener_start_runner] [event: ] org.mule.runtime.module.deployment.impl.internal.artifact.AbstractDeployableArtifact: Application 'delwp-api-mule-hr-admin-api-v1' never started, nothing to dispose of
INFO 2020-02-04 09:47:08,041 [WrapperListener_start_runner] org.mule.runtime.core.internal.logging.LogUtil:
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ Disposing application 'admin-api-v1' +
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
INFO 2020-02-04 09:47:08,363 [WrapperListener_start_runner] org.mule.runtime.core.internal.logging.LogUtil:
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ Failed to deploy artifact 'admin-api-v1', +
+ org.mule.runtime.deployment.model.api.DeploymentInitException: +
+ ClassNotFoundException: com.google.common.cache.CacheLoader +
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
ERROR 2020-02-04 09:47:08,363 [WrapperListener_start_runner] org.mule.runtime.module.deployment.internal.DefaultArchiveDeployer: Failed to deploy artifact [delwp-api-mule-hr-admin-api-v1]
org.mule.runtime.deployment.model.api.DeploymentException: Failed to deploy artifact [delwp-api-mule-hr-admin-api-v1]
Caused by: org.mule.runtime.api.exception.MuleRuntimeException: org.mule.runtime.deployment.model.api.DeploymentInitException: ClassNotFoundException: com.google.common.cache.CacheLoader
Caused by: org.mule.runtime.deployment.model.api.DeploymentInitException: ClassNotFoundException: com.google.common.cache.CacheLoader
Caused by: org.mule.runtime.core.api.config.ConfigurationException: java.lang.NoClassDefFoundError: com/google/common/cache/CacheLoader
Caused by: java.lang.RuntimeException: java.lang.NoClassDefFoundError: com/google/common/cache/CacheLoader
EDIT
When i do #mvn dependency:tree -Dverbose
I could not find any dependency for google.common.cache
library. But there are several guava libaray dependencies, which are omitted for conflict
Line 86: [INFO] | | +- com.google.code.gson:gson:jar:2.6.2:compile
Line 88: [INFO] | | +- (com.google.guava:guava:jar:23.5-jre:compile - omitted for duplicate)
Line 98: [INFO] | | +- (com.google.guava:guava:jar:23.5-jre:compile - omitted for duplicate)
Line 115: [INFO] | | +- (com.google.code.gson:gson:jar:2.5:compile - omitted for conflict with 2.6.2)
Line 118: [INFO] | | | +- (com.google.guava:guava:jar:19.0:compile - omitted for conflict with 23.5-jre)
Line 137: [INFO] | +- com.google.guava:guava:jar:23.5-jre:compile
Line 138: [INFO] | | +- (com.google.code.findbugs:jsr305:jar:1.3.9:compile - omitted for conflict with 3.0.0)
Line 140: [INFO] | | +- com.google.errorprone:error_prone_annotations:jar:2.0.18:compile
Line 141: [INFO] | | +- com.google.j2objc:j2objc-annotations:jar:1.1:compile
Line 144: [INFO] | | \- (com.google.guava:guava:jar:15.0:compile - omitted for conflict with 23.5-jre)
Line 159: [INFO] | | \- (com.google.guava:guava:jar:23.5-jre:compile - omitted for duplicate)
Line 165: [INFO] | \- (com.google.guava:guava:jar:25.1-jre:compile - omitted for conflict with 23.5-jre)
Line 184: [INFO] | | | +- com.googlecode.libphonenumber:libphonenumber:jar:8.0.0:compile
Line 193: [INFO] | | \- com.googlecode.juniversalchardet:juniversalchardet:jar:1.0.3:compile
Line 194: [INFO] | +- com.google.code.findbugs:jsr305:jar:3.0.0:compile
Line 195: [INFO] | +- (com.google.guava:guava:jar:25.0-jre:compile - omitted for conflict with 23.5-jre)
Line 201: [INFO] | | | +- com.google.code.findbugs:annotations:jar:3.0.0:compile
Line 205: [INFO] | | +- (com.googlecode.juniversalchardet:juniversalchardet:jar:1.0.3:compile - omitted for duplicate)
Line 211: [INFO] | | +- (com.google.code.findbugs:jsr305:jar:3.0.0:compile - omitted for duplicate)
Line 212: [INFO] | | +- (com.google.guava:guava:jar:25.0-jre:compile - omitted for conflict with 23.5-jre)
Line 220: [INFO] | | +- (com.google.code.findbugs:jsr305:jar:3.0.0:compile - omitted for duplicate)
Line 221: [INFO] | | +- (com.google.guava:guava:jar:25.0-jre:compile - omitted for conflict with 23.5-jre)
Line 227: [INFO] | | \- (com.google.guava:guava:jar:25.0-jre:compile - omitted for conflict with 23.5-jre)
Line 237: [INFO] | +- (com.google.guava:guava:jar:23.5-jre:compile - omitted for duplicate)
Line 246: [INFO] | +- (com.google.guava:guava:jar:23.5-jre:compile - omitted for duplicate)
Line 256: [INFO] | | +- (com.google.guava:guava:jar:19.0:test - omitted for conflict with 23.5-jre)
Line 264: [INFO] | +- (com.google.code.gson:gson:jar:2.6.2:compile - scope updated from test; omitted for duplicate)
Line 283: [INFO] | | \- (com.google.guava:guava:jar:23.5-jre:compile - omitted for duplicate)
Line 286: [INFO] | \- (com.google.guava:guava:jar:25.1-jre:compile - omitted for conflict with 23.5-jre)
回答1:
The error seems to be caused by the json-logger module. It depends on Guava. Guava seems to depend on Google Cache, however it seems to not declare it as a library. Maybe it loads the cache library dynamically, or it is related to some shading. In any case it is a problem with that component and Guava.
来源:https://stackoverflow.com/questions/60033243/mule-application-in-anypoint-studio-throws-caused-by-java-lang-classnotfoundexc