执行com.cerner.clinicaldev时出现类型不兼容:gatling-plugin:1.0.0-SNAPSHOT:run:org.slf4j.impl.SimpleLoggerFactory无法强制转换为ch.qos.logback.classic.LoggerContext
我正在编写一个maven mojo,用于旋转Jetty实现并以编程方式运行Gatling。我已经尝试从io.gatling:gatling-app:2.2.5中排除slf4j并将maven-enforcer-plugin包含在禁止的依赖项中,这一切都没有用。
我无法在依赖关系树中看到包含它的任何其他位置;
+- io.gatling:gatling-app:jar:2.2.5:compile
| +- io.gatling:gatling-core:jar:2.2.5:compile
| | +- io.gatling:gatling-commons:jar:2.2.5:compile
| | | +- com.typesafe:config:jar:1.3.1:compile
| | | +- com.dongxiguo:fastring_2.11:jar:0.2.4:compile
| | | +- com.softwaremill.quicklens:quicklens_2.11:jar:1.4.8:compile
| | | +- org.asynchttpclient:async-http-client-netty-utils:jar:2.0.29:compile
| | | +- com.typesafe.scala-logging:scala-logging_2.11:jar:3.5.0:compile
| | | \- ch.qos.logback:logback-classic:jar:1.1.7:compile
| | | \- ch.qos.logback:logback-core:jar:1.1.7:compile
| | +- com.typesafe.akka:akka-actor_2.11:jar:2.4.12:compile
| | +- com.typesafe.akka:akka-slf4j_2.11:jar:2.4.12:compile
| | +- com.fasterxml.jackson.dataformat:jackson-dataformat-csv:jar:2.8.4:compile
| | | +- com.fasterxml.jackson.core:jackson-core:jar:2.8.4:compile
| | | \- com.fasterxml.jackson.core:jackson-annotations:jar:2.8.0:compile
| | +- me.chrons:boopickle_2.11:jar:1.2.4:compile
| | +- org.scala-lang.modules:scala-java8-compat_2.11:jar:0.8.0-RC7:compile
| | +- com.github.ben-manes.caffeine:caffeine:jar:2.3.5:compile
| | +- com.github.scopt:scopt_2.11:jar:3.5.0:compile
| | +- io.gatling:jsonpath_2.11:jar:0.6.8:compile
| | +- com.fasterxml.jackson.core:jackson-databind:jar:2.8.4:compile
| | +- io.advantageous.boon:boon-json:jar:0.6.6:compile
| | | \- io.advantageous.boon:boon-reflekt:jar:0.6.6:compile
| | +- net.sf.saxon:Saxon-HE:jar:9.7.0-10:compile
| | \- org.jodd:jodd-lagarto:jar:3.8.0:compile
| | +- org.jodd:jodd-core:jar:3.8.0:compile
| | \- org.jodd:jodd-log:jar:3.8.0:compile
| +- io.gatling:gatling-http:jar:2.2.5:compile
| | +- org.asynchttpclient:async-http-client:jar:2.0.29:compile
| | | +- io.netty:netty-codec-http:jar:4.0.44.Final:compile
| | | | +- io.netty:netty-codec:jar:4.0.44.Final:compile
| | | | \- io.netty:netty-handler:jar:4.0.44.Final:compile
| | | +- org.asynchttpclient:netty-resolver-dns:jar:2.0.29:compile
| | | | +- org.asynchttpclient:netty-resolver:jar:2.0.29:compile
| | | | \- org.asynchttpclient:netty-codec-dns:jar:2.0.29:compile
| | | +- org.reactivestreams:reactive-streams:jar:1.0.0:compile
| | | +- com.typesafe.netty:netty-reactive-streams:jar:1.0.8:compile
| | | \- org.javassist:javassist:jar:3.21.0-GA:compile
| | \- io.netty:netty-transport-native-epoll:jar:linux-x86_64:4.0.44.Final:compile
| | +- io.netty:netty-common:jar:4.0.44.Final:compile
| | +- io.netty:netty-buffer:jar:4.0.44.Final:compile
| | \- io.netty:netty-transport:jar:4.0.44.Final:compile
| +- io.gatling:gatling-jms:jar:2.2.5:compile
| | \- org.apache.geronimo.specs:geronimo-jms_1.1_spec:jar:1.1.1:compile
| +- io.gatling:gatling-jdbc:jar:2.2.5:compile
| +- io.gatling:gatling-redis:jar:2.2.5:compile
| | \- net.debasishg:redisclient_2.11:jar:3.2:compile
| +- io.gatling:gatling-metrics:jar:2.2.5:compile
| | \- org.hdrhistogram:HdrHistogram:jar:2.1.9:compile
| \- io.gatling:gatling-charts:jar:2.2.5:compile
| \- com.tdunning:t-digest:jar:3.1:compile
+- io.spray:spray-json_2.11:jar:1.3.3:compile
+- javax.ws.rs:javax.ws.rs-api:jar:2.0.1:compile
+- javax.ws.rs:jsr311-api:jar:1.1.1:compile
+- org.apache.maven:maven-plugin-api:jar:3.5.0:compile
| +- org.apache.maven:maven-model:jar:3.5.0:compile
| | +- org.codehaus.plexus:plexus-utils:jar:3.0.24:compile
| | \- org.apache.commons:commons-lang3:jar:3.5:compile
| +- org.apache.maven:maven-artifact:jar:3.5.0:compile
| \- org.eclipse.sisu:org.eclipse.sisu.plexus:jar:0.3.3:compile
| +- javax.enterprise:cdi-api:jar:1.0:compile
| | +- javax.annotation:jsr250-api:jar:1.0:compile
| | \- javax.inject:javax.inject:jar:1:compile
| +- org.eclipse.sisu:org.eclipse.sisu.inject:jar:0.3.3:compile
| +- org.codehaus.plexus:plexus-component-annotations:jar:1.5.5:compile
| \- org.codehaus.plexus:plexus-classworlds:jar:2.5.2:compile
+- org.eclipse.jetty.aggregate:jetty-all-server:jar:8.2.0.v20160908:compile
| +- org.eclipse.jetty.orbit:javax.servlet:jar:3.0.0.v201112011016:compile
| +- org.eclipse.jetty.orbit:javax.security.auth.message:jar:1.0.0.v201108011116:compile
| +- org.eclipse.jetty.orbit:javax.mail.glassfish:jar:1.4.1.v201005082020:compile
| +- org.eclipse.jetty.orbit:javax.activation:jar:1.1.0.v201105071233:compile
| \- org.eclipse.jetty.orbit:javax.annotation:jar:1.1.0.v201108011116:compile
+- org.scala-lang:scala-library:jar:2.11.8:compile
+- org.apache.maven.plugin-tools:maven-plugin-annotations:jar:3.5:provided
+- org.scalatest:scalatest_2.11:jar:3.0.3:test
| +- org.scalactic:scalactic_2.11:jar:3.0.3:test
| +- org.scala-lang:scala-reflect:jar:2.11.8:compile
| +- org.scala-lang.modules:scala-xml_2.11:jar:1.0.5:compile
| \- org.scala-lang.modules:scala-parser-combinators_2.11:jar:1.0.4:compile
\- org.specs2:specs2-core_2.11:jar:2.5:test
\- org.specs2:specs2-matcher_2.11:jar:2.5:test
\- org.specs2:specs2-common_2.11:jar:2.5:test
+- org.scalaz:scalaz-core_2.11:jar:7.2.0:test
\- org.scalaz:scalaz-concurrent_2.11:jar:7.2.0:test
\- org.scalaz:scalaz-effect_2.11:jar:7.2.0:test
我已经尝试了3天来解决这个问题。
添加......这是JDK1.8和Maven 3.3.9。
帮助!?!
EDIT ::
如果我在mojo类的头部显式实例化一个记录器,我得到以下堆栈跟踪:
com.google.inject.ProvisionException:无法配置,请参阅以下错误:
1)注入构造函数时出错,java.lang.ClassCastException: org.slf4j.impl.SimpleLoggerFactory无法强制转换为 ch.qos.logback.classic.LoggerContext at com.cerner.clinicaldev.gatlingplugin.GatlingPlugin。(未知 来源)同时定位 com.cerner.clinicaldev.gatlingplugin.GatlingPlugin
1错误 com.google.inject.internal.InjectorImpl $ 2.注册(InjectorImpl.java:1025) 在 com.google.inject.internal.InjectorImpl.getInstance(InjectorImpl.java:1051) 在 org.eclipse.sisu.space.AbstractDeferredClass.get(AbstractDeferredClass.java:48) 在 com.google.inject.internal.ProviderInternalFactory.provision(ProviderInternalFactory.java:81) 在 com.google.inject.internal.InternalFactoryToInitializableAdapter.provision(InternalFactoryToInitializableAdapter.java:53) 在 com.google.inject.internal.ProviderInternalFactory $ 1.call(ProviderInternalFactory.java:65) 在 com.google.inject.internal.ProvisionListenerStackCallback $ Provision.provision(ProvisionListenerStackCallback.java:115) 在 org.eclipse.sisu.bean.BeanScheduler $ Activator.onProvision(BeanScheduler.java:176) 在 com.google.inject.internal.ProvisionListenerStackCallback $ Provision.provision(ProvisionListenerStackCallback.java:126) 在 com.google.inject.internal.ProvisionListenerStackCallback.provision(ProvisionListenerStackCallback.java:68) 在 com.google.inject.internal.ProviderInternalFactory.circularGet(ProviderInternalFactory.java:63) 在 com.google.inject.internal.InternalFactoryToInitializableAdapter.get(InternalFactoryToInitializableAdapter.java:45) 在 com.google.inject.internal.InjectorImpl $ 2 $ 1.call(InjectorImpl.java:1016) 在 com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1092) 在 com.google.inject.internal.InjectorImpl $ 2.注册(InjectorImpl.java:1012) 在org.eclipse.sisu.inject.Guice4 $ 1.get(Guice4.java:162)at org.eclipse.sisu.inject.LazyBeanEntry.getValue(LazyBeanEntry.java:81) 在 org.eclipse.sisu.plexus.LazyPlexusBean.getValue(LazyPlexusBean.java:51) 在 org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:263) 在 org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:255) 在 org.apache.maven.plugin.internal.DefaultMavenPluginManager.getConfiguredMojo(DefaultMavenPluginManager.java:517) 在 org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:121) 在 org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207) 在 org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153) 在 org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145) 在 org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116) 在 org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80) 在 org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51) 在 org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128) 在org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)at at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)at at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)at at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)at at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)at at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 在 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 在java.lang.reflect.Method.invoke(Method.java:498)at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289) 在 org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229) 在 org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415) 在 org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356) 引起:java.lang.ClassCastException: org.slf4j.impl.SimpleLoggerFactory无法强制转换为 ch.qos.logback.classic.LoggerContext at 。com.cerner.clinicaldev.gatlingplugin.GatlingPlugin(GatlingPlugin.scala:20) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native 方法)at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) 在 sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:423) 在 com.google.inject.internal.DefaultConstructionProxyFactory $ 1.newInstance(DefaultConstructionProxyFactory.java:86) 在 com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:105) 在 com.google.inject.internal.ConstructorInjector.access $ 000(ConstructorInjector.java:32) 在 com.google.inject.internal.ConstructorInjector $ 1.call(ConstructorInjector.java:89) 在 com.google.inject.internal.ProvisionListenerStackCallback $ Provision.provision(ProvisionListenerStackCallback.java:115) 在 com.google.inject.internal.ProvisionListenerStackCallback $ Provision.provision(ProvisionListenerStackCallback.java:133) 在 com.google.inject.internal.ProvisionListenerStackCallback.provision(ProvisionListenerStackCallback.java:68) 在 com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:87) 在 com.google.inject.internal.ConstructorBindingImpl $ Factory.get(ConstructorBindingImpl.java:267) 在 com.google.inject.internal.InjectorImpl $ 2 $ 1.call(InjectorImpl.java:1016) 在 com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1103) 在 com.google.inject.internal.InjectorImpl $ 2.注册(InjectorImpl.java:1012)
答案 0 :(得分:0)
尝试添加包含logback-classic
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.7</version>
</dependency>
它包含在
中<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.1.3</version>
</dependency>
将您的记录器初始化为您的课程: -
private static final Logger logger = LoggerFactory.getLogger(DemoClass.class)
答案 1 :(得分:0)
最后,我将maven-plugin和gatling项目分开,并将slfj排除在其他依赖项之外。
答案 2 :(得分:0)
我在Play框架中遇到了类似的问题:
我唯一要做的就是将Provided
添加到依赖项中。
这是我的 SBT 案:
libraryDependencies += "org.slf4j" % "slf4j-simple" % "1.7.26" % Provided,
答案 3 :(得分:0)
我的stderr有:
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/Users/wf/.m2/repository/org/slf4j/slf4j-simple/1.7.21/slf4j-simple-1.7.21.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/Users/wf/.m2/repository/ch/qos/logback/logback-classic/1.1.5/logback-classic-1.1.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.SimpleLoggerFactory]
指向http://www.slf4j.org/codes.html#multiple_bindings,建议将排除项添加到不需要的绑定中。所以我做了
mvn dependency:tree | grep -B1 -C1 logback
显示例如
[INFO] +- nl.vaneijndhoven.dukes:rc-watchdog:jar:0.0.2:compile
[INFO] \- ch.qos.logback:logback-classic:jar:1.1.5:compile
[INFO] +- ch.qos.logback:logback-core:jar:1.1.5:compile
[INFO] \- org.slf4j:slf4j-api:jar:1.7.16:compile
,同时有较新版本的logback-classic:
https://mvnrepository.com/artifact/ch.qos.logback/logback-classic/1.2.3
在我的Eclipse工作区的pomfile中,跟随版本号1.7.25和1.7.21,我发现我直接将vert.x用作从属项目(出于调试目的)。当我从构建路径中删除该项目时,我很好。
因此,一般方法是使用
查看您的依赖项mvn dependency:tree
并将slf4j从冲突的依赖关系中排除,或将其全部删除。