I have a project which is having multiple modules within it. One of the module, say "main", is having my service class, "MyService.class". Dropwizard has a jar - dropwizard-core. I want this jar in more than one module, so I was thinking of keeping its dependency in parent POM. By doing that, while running my dropwizard service file, I am encountering an exception as follows:
SLF4J: Class path contains multiple SLF4J bindings.<br>
SLF4J: Found binding in [jar:file:/home/username/.m2/repository/org/slf4j/slf4j-simple/1.7.12/slf4j-simple-1.7.12.jar!/org/slf4j/impl/StaticLoggerBinder.class]<br>
SLF4J: Found binding in [jar:file:/home/username/.m2/repository/ch/qos/logback/logback-classic/1.1.3/logback-classic-1.1.3.jar!/org/slf4j/impl/StaticLoggerBinder.class]<br>
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.<br>
SLF4J: Actual binding is of type [org.slf4j.impl.SimpleLoggerFactory]<br><br>
Exception in thread "main" java.lang.IllegalStateException: Unable to acquire the logger context
at io.dropwizard.logging.LoggingUtil.getLoggerContext(LoggingUtil.java:46)
at io.dropwizard.logging.BootstrapLogging.bootstrap(BootstrapLogging.java:45)
at io.dropwizard.logging.BootstrapLogging.bootstrap(BootstrapLogging.java:34)
at io.dropwizard.Application.<init>(Application.java:24)
at my.project.package.MyService.<init>(MyService.java:31)
at my.project.package.MyService.main(MyService.java:38)
This project runs perfectly fine if I put the dependency in the POM of "main" module.
Dropwizard is binding with wrong logger and that is the reason behind this exception. But this binding happens in the background and I have no control over it.
I am also sharing the dependency tree for both the scenarios.
Case 1 : When dropwizard-core is in child POM (main module) :
my.groupId.myProject:myProject-main:jar:1.0-SNAPSHOT<br>
[INFO] +- io.dropwizard:dropwizard-core:jar:0.9.2:compile<br>
[INFO] | +- io.dropwizard:dropwizard-util:jar:0.9.2:compile<br>
[INFO] | | +- com.fasterxml.jackson.core:jackson-annotations:jar:2.6.0:compile<br>
[INFO] | | +- com.google.guava:guava:jar:18.0:compile<br>
[INFO] | | +- com.google.code.findbugs:jsr305:jar:3.0.1:compile<br>
[INFO] | | \- joda-time:joda-time:jar:2.9:compile<br>
[INFO] | +- io.dropwizard:dropwizard-jackson:jar:0.9.2:compile<br>
[INFO] | | +- com.fasterxml.jackson.core:jackson-core:jar:2.6.3:compile<br>
[INFO] | | +- com.fasterxml.jackson.core:jackson-databind:jar:2.6.3:compile<br>
[INFO] | | +- com.fasterxml.jackson.datatype:jackson-datatype-jdk7:jar:2.6.3:compile<br>
[INFO] | | +- com.fasterxml.jackson.datatype:jackson-datatype-guava:jar:2.6.3:compile<br>
[INFO] | | +- com.fasterxml.jackson.module:jackson-module-afterburner:jar:2.6.3:compile<br>
[INFO] | | +- com.fasterxml.jackson.datatype:jackson-datatype-joda:jar:2.6.3:compile<br>
[INFO] | | +- org.slf4j:slf4j-api:jar:1.7.12:compile<br>
[INFO] | | \- ch.qos.logback:logback-classic:jar:1.1.3:compile<br>
[INFO] | +- io.dropwizard:dropwizard-validation:jar:0.9.2:compile<br>
[INFO] | | +- org.hibernate:hibernate-validator:jar:5.2.2.Final:compile<br>
[INFO] | | | +- javax.validation:validation-api:jar:1.1.0.Final:compile<br>
[INFO] | | | +- org.jboss.logging:jboss-logging:jar:3.2.1.Final:compile<br>
[INFO] | | | \- com.fasterxml:classmate:jar:1.1.0:compile<br>
[INFO] | | \- org.glassfish:javax.el:jar:3.0.0:compile<br>
[INFO] | +- io.dropwizard:dropwizard-configuration:jar:0.9.2:compile<br>
[INFO] | | +- com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:jar:2.6.3:compile<br>
[INFO] | | | \- org.yaml:snakeyaml:jar:1.15:compile<br>
[INFO] | | \- org.apache.commons:commons-lang3:jar:3.4:compile<br>
[INFO] | +- io.dropwizard:dropwizard-logging:jar:0.9.2:compile<br>
[INFO] | | +- io.dropwizard.metrics:metrics-logback:jar:3.1.2:compile<br>
[INFO] | | +- org.slf4j:jul-to-slf4j:jar:1.7.12:compile<br><br>
[INFO] | | +- ch.qos.logback:logback-core:jar:1.1.3:compile<br>
[INFO] | | +- org.slf4j:log4j-over-slf4j:jar:1.7.12:compile<br>
[INFO] | | +- org.slf4j:jcl-over-slf4j:jar:1.7.12:compile<br>
[INFO] | | \- org.eclipse.jetty:jetty-util:jar:9.2.13.v20150730:compile<br>
[INFO] | +- io.dropwizard:dropwizard-metrics:jar:0.9.2:compile<br>
[INFO] | +- io.dropwizard:dropwizard-jersey:jar:0.9.2:compile<br>
[INFO] | | +- org.glassfish.jersey.core:jersey-server:jar:2.22.1:compile<br>
[INFO] | | | +- org.glassfish.jersey.core:jersey-common:jar:2.22.1:compile<br>
[INFO] | | | | +- org.glassfish.jersey.bundles.repackaged:jersey-guava:jar:2.22.1:compile<br>
[INFO] | | | | \- org.glassfish.hk2:osgi-resource-locator:jar:1.0.1:compile<br>
[INFO] | | | +- javax.ws.rs:javax.ws.rs-api:jar:2.0.1:compile<br>
[INFO] | | | +- org.glassfish.jersey.media:jersey-media-jaxb:jar:2.22.1:compile<br>
[INFO] | | | +- javax.annotation:javax.annotation-api:jar:1.2:compile<br>
[INFO] | | | +- org.glassfish.hk2:hk2-api:jar:2.4.0-b31:compile<br>
[INFO] | | | | +- org.glassfish.hk2:hk2-utils:jar:2.4.0-b31:compile<br>
[INFO] | | | | \- org.glassfish.hk2.external:aopalliance-repackaged:jar:2.4.0-b31:compile<br>
[INFO] | | | +- org.glassfish.hk2.external:javax.inject:jar:2.4.0-b31:compile<br>
[INFO] | | | \- org.glassfish.hk2:hk2-locator:jar:2.4.0-b31:compile<br>
[INFO] | | | \- org.javassist:javassist:jar:3.18.1-GA:compile<br>
[INFO] | | +- org.glassfish.jersey.ext:jersey-metainf-services:jar:2.22.1:compile<br>
[INFO] | | +- org.glassfish.jersey.ext:jersey-bean-validation:jar:2.22.1:compile<br>
[INFO] | | +- io.dropwizard.metrics:metrics-jersey2:jar:3.1.2:compile<br>
[INFO] | | +- com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:jar:2.6.3:compile<br>
[INFO] | | | +- com.fasterxml.jackson.jaxrs:jackson-jaxrs-base:jar:2.6.3:compile<br>
[INFO] | | | \- com.fasterxml.jackson.module:jackson-module-jaxb-annotations:jar:2.6.3:compile<br>
[INFO] | | +- org.glassfish.jersey.containers:jersey-container-servlet:jar:2.22.1:compile<br>
[INFO] | | | \- org.glassfish.jersey.containers:jersey-container-servlet-core:jar:2.22.1:compile<br>
[INFO] | | +- org.eclipse.jetty:jetty-server:jar:9.2.13.v20150730:compile<br>
[INFO] | | | +- javax.servlet:javax.servlet-api:jar:3.1.0:compile<br>
[INFO] | | | \- org.eclipse.jetty:jetty-io:jar:9.2.13.v20150730:compile<br>
[INFO] | | +- org.eclipse.jetty:jetty-webapp:jar:9.2.13.v20150730:compile<br>
[INFO] | | | \- org.eclipse.jetty:jetty-xml:jar:9.2.13.v20150730:compile<br>
[INFO] | | \- org.eclipse.jetty:jetty-continuation:jar:9.2.13.v20150730:compile<br>
[INFO] | +- io.dropwizard:dropwizard-servlets:jar:0.9.2:compile<br>
[INFO] | | \- io.dropwizard.metrics:metrics-annotation:jar:3.1.2:compile<br>
[INFO] | +- io.dropwizard:dropwizard-jetty:jar:0.9.2:compile<br>
[INFO] | | +- io.dropwizard.metrics:metrics-jetty9:jar:3.1.2:compile<br>
[INFO] | | +- org.eclipse.jetty:jetty-servlet:jar:9.2.13.v20150730:compile<br>
[INFO] | | | \- org.eclipse.jetty:jetty-security:jar:9.2.13.v20150730:compile<br>
[INFO] | | +- org.eclipse.jetty:jetty-servlets:jar:9.2.13.v20150730:compile<br>
[INFO] | | \- org.eclipse.jetty:jetty-http:jar:9.2.13.v20150730:compile<br>
[INFO] | +- io.dropwizard:dropwizard-lifecycle:jar:0.9.2:compile<br>
[INFO] | +- io.dropwizard.metrics:metrics-core:jar:3.1.2:compile<br>
[INFO] | +- io.dropwizard.metrics:metrics-jvm:jar:3.1.2:compile<br>
[INFO] | +- io.dropwizard.metrics:metrics-servlets:jar:3.1.2:compile<br>
[INFO] | | \- io.dropwizard.metrics:metrics-json:jar:3.1.2:compile<br>
[INFO] | +- io.dropwizard.metrics:metrics-healthchecks:jar:3.1.2:compile<br>
[INFO] | +- net.sourceforge.argparse4j:argparse4j:jar:0.6.0:compile<br>
[INFO] | \- org.eclipse.jetty.toolchain.setuid:jetty-setuid-java:jar:1.0.3:compile<br>
[INFO] +- de.thomaskrille:dropwizard-template-config:jar:1.1.0:compile<br>
[INFO] +- my.groupId.myProject:myProject-module1:jar:1.0-SNAPSHOT:compile<br>
[INFO] +- my.groupId.myProject:myProject-module2:jar:1.0-SNAPSHOT:compile<br>
[INFO] +- my.groupId.myProject:myProject-module3:jar:0.0.1-SNAPSHOT:compile<br>
[INFO] | +- io.dropwizard:dropwizard-auth:jar:0.9.1:compile<br>
[INFO] | \- io.dropwizard:dropwizard-client:jar:0.9.1:compile<br>
[INFO] | +- org.glassfish.jersey.core:jersey-client:jar:2.22.1:compile<br>
[INFO] | +- org.apache.httpcomponents:httpclient:jar:4.5.1:compile<br>
[INFO] | | +- org.apache.httpcomponents:httpcore:jar:4.4.3:compile<br>
[INFO] | | \- commons-codec:commons-codec:jar:1.9:compile<br>
[INFO] | +- io.dropwizard.metrics:metrics-httpclient:jar:3.1.2:compile<br>
[INFO] | \- org.glassfish.jersey.connectors:jersey-apache-connector:jar:2.22.1:compile<br>
[INFO] +- junit:junit:jar:4.12:test<br>
[INFO] | \- org.hamcrest:hamcrest-core:jar:1.3:test<br>
[INFO] +- org.hamcrest:hamcrest-library:jar:1.3:test<br>
[INFO] \- org.mockito:mockito-core:jar:1.10.19:test<br>
[INFO] \- org.objenesis:objenesis:jar:2.1:test<br>
**Case 2 : When dropwizard-core is in parent POM :**
my.groupId.myProject:myProject-main:jar:jar:1.0-SNAPSHOT<br>
[INFO] +- de.thomaskrille:dropwizard-template-config:jar:1.1.0:compile<br>
[INFO] +- my.groupId.myProject:myProject-module1:jar:1.0-SNAPSHOT:compile<br>
[INFO] +- my.groupId.myProject:myProject-module2:jar:1.0-SNAPSHOT:compile<br>
[INFO] +- my.groupId.myProject:myProject-common:jar:0.0.1-SNAPSHOT:compile<br>
[INFO] | +- io.dropwizard:dropwizard-auth:jar:0.9.1:compile<br>
[INFO] | \- io.dropwizard:dropwizard-client:jar:0.9.1:compile<br>
[INFO] | +- org.glassfish.jersey.core:jersey-client:jar:2.22.1:compile<br>
[INFO] | | +- javax.ws.rs:javax.ws.rs-api:jar:2.0.1:compile<br>
[INFO] | | +- org.glassfish.jersey.core:jersey-common:jar:2.22.1:compile<br>
[INFO] | | | +- org.glassfish.jersey.bundles.repackaged:jersey-guava:jar:2.22.1:compile<br>
[INFO] | | | \- org.glassfish.hk2:osgi-resource-locator:jar:1.0.1:compile<br>
[INFO] | | +- org.glassfish.hk2:hk2-api:jar:2.4.0-b31:compile<br>
[INFO] | | | +- org.glassfish.hk2:hk2-utils:jar:2.4.0-b31:compile<br>
[INFO] | | | \- org.glassfish.hk2.external:aopalliance-repackaged:jar:2.4.0-b31:compile<br>
[INFO] | | +- org.glassfish.hk2.external:javax.inject:jar:2.4.0-b31:compile<br>
[INFO] | | \- org.glassfish.hk2:hk2-locator:jar:2.4.0-b31:compile<br>
[INFO] | | \- org.javassist:javassist:jar:3.18.1-GA:compile<br>
[INFO] | +- org.apache.httpcomponents:httpclient:jar:4.5.1:compile<br>
[INFO] | | +- org.apache.httpcomponents:httpcore:jar:4.4.3:compile<br>
[INFO] | | \- commons-codec:commons-codec:jar:1.9:compile<br>
[INFO] | +- io.dropwizard.metrics:metrics-httpclient:jar:3.1.2:compile<br>
[INFO] | \- org.glassfish.jersey.connectors:jersey-apache-connector:jar:2.22.1:compile<br>
[INFO] +- io.dropwizard:dropwizard-core:jar:0.9.2:compile<br>
[INFO] | +- io.dropwizard:dropwizard-util:jar:0.9.2:compile<br>
[INFO] | | +- com.fasterxml.jackson.core:jackson-annotations:jar:2.6.0:compile<br>
[INFO] | | +- com.google.guava:guava:jar:18.0:compile<br>
[INFO] | | +- com.google.code.findbugs:jsr305:jar:3.0.1:compile<br>
[INFO] | | \- joda-time:joda-time:jar:2.9:compile<br>
[INFO] | +- io.dropwizard:dropwizard-jackson:jar:0.9.2:compile<br>
[INFO] | | +- com.fasterxml.jackson.core:jackson-core:jar:2.6.3:compile<br>
[INFO] | | +- com.fasterxml.jackson.core:jackson-databind:jar:2.6.3:compile<br>
[INFO] | | +- com.fasterxml.jackson.datatype:jackson-datatype-jdk7:jar:2.6.3:compile<br>
[INFO] | | +- com.fasterxml.jackson.datatype:jackson-datatype-guava:jar:2.6.3:compile<br>
[INFO] | | +- com.fasterxml.jackson.module:jackson-module-afterburner:jar:2.6.3:compile<br>
[INFO] | | +- com.fasterxml.jackson.datatype:jackson-datatype-joda:jar:2.6.3:compile<br>
[INFO] | | +- org.slf4j:slf4j-api:jar:1.7.12:compile<br>
[INFO] | | \- ch.qos.logback:logback-classic:jar:1.1.3:compile<br>
[INFO] | +- io.dropwizard:dropwizard-validation:jar:0.9.2:compile<br>
[INFO] | | +- org.hibernate:hibernate-validator:jar:5.2.2.Final:compile<br>
[INFO] | | | +- javax.validation:validation-api:jar:1.1.0.Final:compile<br>
[INFO] | | | +- org.jboss.logging:jboss-logging:jar:3.2.1.Final:compile<br>
[INFO] | | | \- com.fasterxml:classmate:jar:1.1.0:compile<br>
[INFO] | | \- org.glassfish:javax.el:jar:3.0.0:compile<br>
[INFO] | +- io.dropwizard:dropwizard-configuration:jar:0.9.2:compile<br>
[INFO] | | +- com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:jar:2.6.3:compile<br>
[INFO] | | | \- org.yaml:snakeyaml:jar:1.15:compile<br>
[INFO] | | \- org.apache.commons:commons-lang3:jar:3.4:compile<br>
[INFO] | +- io.dropwizard:dropwizard-logging:jar:0.9.2:compile<br>
[INFO] | | +- io.dropwizard.metrics:metrics-logback:jar:3.1.2:compile<br>
[INFO] | | +- org.slf4j:jul-to-slf4j:jar:1.7.12:compile<br>
[INFO] | | +- ch.qos.logback:logback-core:jar:1.1.3:compile<br>
[INFO] | | +- org.slf4j:log4j-over-slf4j:jar:1.7.12:compile<br>
[INFO] | | +- org.slf4j:jcl-over-slf4j:jar:1.7.12:compile<br>
[INFO] | | \- org.eclipse.jetty:jetty-util:jar:9.2.13.v20150730:compile<br>
[INFO] | +- io.dropwizard:dropwizard-metrics:jar:0.9.2:compile<br>
[INFO] | +- io.dropwizard:dropwizard-jersey:jar:0.9.2:compile<br>
[INFO] | | +- org.glassfish.jersey.core:jersey-server:jar:2.22.1:compile<br>
[INFO] | | | +- org.glassfish.jersey.media:jersey-media-jaxb:jar:2.22.1:compile<br>
[INFO] | | | \- javax.annotation:javax.annotation-api:jar:1.2:compile<br>
[INFO] | | +- org.glassfish.jersey.ext:jersey-metainf-services:jar:2.22.1:compile<br>
[INFO] | | +- org.glassfish.jersey.ext:jersey-bean-validation:jar:2.22.1:compile<br>
[INFO] | | +- io.dropwizard.metrics:metrics-jersey2:jar:3.1.2:compile<br>
[INFO] | | +- com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:jar:2.6.3:compile<br>
[INFO] | | | +- com.fasterxml.jackson.jaxrs:jackson-jaxrs-base:jar:2.6.3:compile<br>
[INFO] | | | \- com.fasterxml.jackson.module:jackson-module-jaxb-annotations:jar:2.6.3:compile<br>
[INFO] | | +- org.glassfish.jersey.containers:jersey-container-servlet:jar:2.22.1:compile<br>
[INFO] | | | \- org.glassfish.jersey.containers:jersey-container-servlet-core:jar:2.22.1:compile<br>
[INFO] | | +- org.eclipse.jetty:jetty-server:jar:9.2.13.v20150730:compile<br>
[INFO] | | | +- javax.servlet:javax.servlet-api:jar:3.1.0:compile<br>
[INFO] | | | \- org.eclipse.jetty:jetty-io:jar:9.2.13.v20150730:compile<br>
[INFO] | | +- org.eclipse.jetty:jetty-webapp:jar:9.2.13.v20150730:compile<br>
[INFO] | | | \- org.eclipse.jetty:jetty-xml:jar:9.2.13.v20150730:compile<br>
[INFO] | | \- org.eclipse.jetty:jetty-continuation:jar:9.2.13.v20150730:compile<br>
[INFO] | +- io.dropwizard:dropwizard-servlets:jar:0.9.2:compile<br>
[INFO] | | \- io.dropwizard.metrics:metrics-annotation:jar:3.1.2:compile<br>
[INFO] | +- io.dropwizard:dropwizard-jetty:jar:0.9.2:compile<br>
[INFO] | | +- io.dropwizard.metrics:metrics-jetty9:jar:3.1.2:compile<br>
[INFO] | | +- org.eclipse.jetty:jetty-servlet:jar:9.2.13.v20150730:compile<br>
[INFO] | | | \- org.eclipse.jetty:jetty-security:jar:9.2.13.v20150730:compile<br>
[INFO] | | +- org.eclipse.jetty:jetty-servlets:jar:9.2.13.v20150730:compile<br>
[INFO] | | \- org.eclipse.jetty:jetty-http:jar:9.2.13.v20150730:compile<br>
[INFO] | +- io.dropwizard:dropwizard-lifecycle:jar:0.9.2:compile<br>
[INFO] | +- io.dropwizard.metrics:metrics-core:jar:3.1.2:compile<br>
[INFO] | +- io.dropwizard.metrics:metrics-jvm:jar:3.1.2:compile<br>
[INFO] | +- io.dropwizard.metrics:metrics-servlets:jar:3.1.2:compile<br>
[INFO] | | \- io.dropwizard.metrics:metrics-json:jar:3.1.2:compile<br>
[INFO] | +- io.dropwizard.metrics:metrics-healthchecks:jar:3.1.2:compile<br>
[INFO] | +- net.sourceforge.argparse4j:argparse4j:jar:0.6.0:compile<br>
[INFO] | \- org.eclipse.jetty.toolchain.setuid:jetty-setuid-java:jar:1.0.3:compile<br>
[INFO] +- junit:junit:jar:4.12:test<br>
[INFO] | \- org.hamcrest:hamcrest-core:jar:1.3:test<br>
[INFO] +- org.hamcrest:hamcrest-library:jar:1.3:test<br>
[INFO] \- org.mockito:mockito-core:jar:1.10.19:test<br>
[INFO] \- org.objenesis:objenesis:jar:2.1:test<br>
If anyone could come up with a possible reasoning, it would be of great help.
Thanks.
Your problem is that you have two different slf4j implementations (aka bindings) in your classpath and this shouldn't be the case.
When this happens, the first one (in order of appearance in the classpath) is used by slf4j. Then dropwizard LoggingUtil tries to retrieve the actual ILoggerFactory but expects it to be an instance of logback's LoggerContext.
In your case, it is an instance of SimpleLoggerFactory because slf4j-simple appears first in the classpath when you declare the dependency to dropwizard-core in the the parent POM: indeed, the logback-classic dependency is brought by dropwizard-core.
The solution is very simple: you must remove the dependency to slf4j-simple.
This is explained at the very beginning of the slf4j manual.
The issue is resolved for me after I globally excluded the jar slf4j-log4j12 by adding the below in my build.gradle
configurations.all {
exclude group:"org.slf4j", module: "slf4j-log4j12"
}
Sometimes you cannot exclude library because it is used by another libraries. So, you need to have two implementations. I had such problem so I in my model of Configuration which extends io.dropwizard.Configuration model I override method
#Override
public synchronized LoggingFactory getLoggingFactory() {
return new ExternalLoggingFactory();
}
Related
I have a class need to be tested:
public class TestClazz {
public void abc() {
List<String> sa = Collections.singletonList("sa");
Stream<PropertySource<?>> stream = StreamSupport.stream(Mockito.mock(Spliterator.class), false);
ICampaignHandler campaignHandler = CampaignHandlerFactory.getCampaignHandler(ProcessorTypeEnum.RETRY_CAMPAIGN);
System.out.println("============INSIDE ABC===========");
System.out.println(sa);
System.out.println(stream);
System.out.println(campaignHandler);
//Other logic code
}
}
And a test class:
#RunWith(PowerMockRunner.class)
#PrepareForTest({ Collections.class, StreamSupport.class, CampaignHandlerFactory.class})
public class DefaultSystemAppConfigServiceTest {
#Test
public void testing() {
PowerMockito.mockStatic(StreamSupport.class);
PowerMockito.mockStatic(Collections.class);
PowerMockito.mockStatic(CampaignHandlerFactory.class);
//Stubbing
Mockito.when(StreamSupport.stream(Mockito.any(Spliterator.class), Mockito.anyBoolean()))
.thenReturn(Mockito.mock(Stream.class));
Mockito.when(Collections.singletonList(Mockito.any()))
.thenReturn(Mockito.mock(List.class));
Mockito.when(CampaignHandlerFactory.getCampaignHandler(Mockito.any()))
.thenReturn(Mockito.mock(ICampaignHandler.class));
//Here invoked method under test
new TestClazz().abc();
Stream<PropertySource<?>> stream = StreamSupport.stream(Mockito.mock(Spliterator.class), false);
List<String> sa = Collections.singletonList("sa");
ICampaignHandler campaignHandler = CampaignHandlerFactory.getCampaignHandler(ProcessorTypeEnum.RETRY_CAMPAIGN);
System.out.println();
System.out.println("============OUTSIDE ABC===========");
System.out.println(sa);
System.out.println(stream);
System.out.println(campaignHandler);
}
}
I have to mock statics call so that it return as my expectation
I followed steps:
#RunWith(PowerMockRunner.class)
#PrepareForTest({ Collections.class, StreamSupport.class, CampaignHandlerFactory.class})
PowerMockito.mockStatic(clazz)
Mockito.when(method call).thenReturn(my mock)
Invoke method need to be tested
The result:
============INSIDE ABC===========
[sa]
java.util.stream.ReferencePipeline$Head#dffa30b
Mock for ICampaignHandler, hashCode: 81269359
============OUTSIDE ABC===========
Mock for List, hashCode: 628164202
Mock for Stream, hashCode: 1962826086
Mock for ICampaignHandler, hashCode: 81269359
Process finished with exit code 0
You guys can see 2/3 my stubbing setup does not work if the static calls are inside abc(), and it works if I copy static call outside abc() (copy to testing() directly). Only 1/3 stubbing works (inside and outside):
CampaignHandlerFactory.getCampaignHandler(param) //this return as my expectiation
Hint: CampaignHandlerFactory is my implementation; Collections, StreamSupport are built-in classes. This is spring boot application
Test dependencies tree:
mvn test dependency:tree -DskipTests=true
[INFO] --- maven-dependency-plugin:3.1.2:tree (default-cli) # ota-service ---
[INFO] com.sirea.ota:ota-service:jar:0.0.1-SNAPSHOT
[INFO] +- com.sirea.ota:ota-logging:jar:0.0.1-SNAPSHOT:compile
[INFO] | +- org.slf4j:slf4j-api:jar:1.7.30:compile
[INFO] | +- org.springframework.boot:spring-boot-starter-aop:jar:2.3.8.RELEASE:compile
[INFO] | | +- org.springframework:spring-aop:jar:5.2.12.RELEASE:compile
[INFO] | | \- org.aspectj:aspectjweaver:jar:1.9.6:compile
[INFO] | +- com.sirea:logFormattor:jar:1.0.9:compile
[INFO] | | \- org.codehaus.janino:janino:jar:3.1.2:compile
[INFO] | | \- org.codehaus.janino:commons-compiler:jar:3.1.2:compile
[INFO] | +- org.springframework.boot:spring-boot-starter-web:jar:2.3.8.RELEASE:compile
[INFO] | | +- org.springframework.boot:spring-boot-starter-json:jar:2.3.8.RELEASE:compile
[INFO] | | | +- com.fasterxml.jackson.datatype:jackson-datatype-jdk8:jar:2.11.4:compile
[INFO] | | | +- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.11.4:compile
[INFO] | | | \- com.fasterxml.jackson.module:jackson-module-parameter-names:jar:2.11.4:compile
[INFO] | | +- org.springframework:spring-web:jar:5.2.12.RELEASE:compile
[INFO] | | \- org.springframework:spring-webmvc:jar:5.2.12.RELEASE:compile
[INFO] | | \- org.springframework:spring-expression:jar:5.2.12.RELEASE:compile
[INFO] | \- org.springframework.boot:spring-boot-starter-jetty:jar:2.3.8.RELEASE:compile
[INFO] | +- jakarta.servlet:jakarta.servlet-api:jar:4.0.4:compile
[INFO] | +- jakarta.websocket:jakarta.websocket-api:jar:1.1.2:compile
[INFO] | +- org.eclipse.jetty:jetty-servlets:jar:9.4.35.v20201120:compile
[INFO] | | +- org.eclipse.jetty:jetty-continuation:jar:9.4.35.v20201120:compile
[INFO] | | +- org.eclipse.jetty:jetty-http:jar:9.4.35.v20201120:compile
[INFO] | | +- org.eclipse.jetty:jetty-util:jar:9.4.35.v20201120:compile
[INFO] | | \- org.eclipse.jetty:jetty-io:jar:9.4.35.v20201120:compile
[INFO] | +- org.eclipse.jetty:jetty-webapp:jar:9.4.35.v20201120:compile
[INFO] | | +- org.eclipse.jetty:jetty-xml:jar:9.4.35.v20201120:compile
[INFO] | | \- org.eclipse.jetty:jetty-servlet:jar:9.4.35.v20201120:compile
[INFO] | | +- org.eclipse.jetty:jetty-security:jar:9.4.35.v20201120:compile
[INFO] | | | \- org.eclipse.jetty:jetty-server:jar:9.4.35.v20201120:compile
[INFO] | | \- org.eclipse.jetty:jetty-util-ajax:jar:9.4.35.v20201120:compile
[INFO] | +- org.eclipse.jetty.websocket:websocket-server:jar:9.4.35.v20201120:compile
[INFO] | | +- org.eclipse.jetty.websocket:websocket-common:jar:9.4.35.v20201120:compile
[INFO] | | | \- org.eclipse.jetty.websocket:websocket-api:jar:9.4.35.v20201120:compile
[INFO] | | +- org.eclipse.jetty.websocket:websocket-client:jar:9.4.35.v20201120:compile
[INFO] | | | \- org.eclipse.jetty:jetty-client:jar:9.4.35.v20201120:compile
[INFO] | | \- org.eclipse.jetty.websocket:websocket-servlet:jar:9.4.35.v20201120:compile
[INFO] | +- org.eclipse.jetty.websocket:javax-websocket-server-impl:jar:9.4.35.v20201120:compile
[INFO] | | +- org.eclipse.jetty:jetty-annotations:jar:9.4.35.v20201120:compile
[INFO] | | | +- org.eclipse.jetty:jetty-plus:jar:9.4.35.v20201120:compile
[INFO] | | | +- org.ow2.asm:asm:jar:9.0:compile
[INFO] | | | \- org.ow2.asm:asm-commons:jar:9.0:compile
[INFO] | | | +- org.ow2.asm:asm-tree:jar:9.0:compile
[INFO] | | | \- org.ow2.asm:asm-analysis:jar:9.0:compile
[INFO] | | \- org.eclipse.jetty.websocket:javax-websocket-client-impl:jar:9.4.35.v20201120:compile
[INFO] | \- org.glassfish:jakarta.el:jar:3.0.3:compile
[INFO] +- com.sirea.common:sirea-logging:jar:1.2.0:compile
[INFO] | +- com.fasterxml.jackson.core:jackson-core:jar:2.11.4:compile
[INFO] | +- com.fasterxml.jackson.core:jackson-annotations:jar:2.11.4:compile
[INFO] | +- com.fasterxml.jackson.core:jackson-databind:jar:2.11.4:compile
[INFO] | \- ch.qos.logback:logback-classic:jar:1.2.3:compile
[INFO] | \- ch.qos.logback:logback-core:jar:1.2.3:compile
[INFO] +- com.sirea.ota:ota-common:jar:0.0.1-SNAPSHOT:compile
[INFO] | +- javax.validation:validation-api:jar:2.0.1.Final:compile
[INFO] | +- org.springframework.hateoas:spring-hateoas:jar:1.2.3:compile
[INFO] | | +- org.springframework:spring-beans:jar:5.2.12.RELEASE:compile
[INFO] | | +- org.springframework:spring-context:jar:5.2.12.RELEASE:compile
[INFO] | | \- org.springframework.plugin:spring-plugin-core:jar:2.0.0.RELEASE:compile
[INFO] | +- org.apache.commons:commons-lang3:jar:3.11:compile
[INFO] | +- org.codehaus.jackson:jackson-mapper-asl:jar:1.9.13:compile
[INFO] | | \- org.codehaus.jackson:jackson-core-asl:jar:1.9.13:compile
[INFO] | +- javax.xml.bind:jaxb-api:jar:2.3.1:compile
[INFO] | | \- javax.activation:javax.activation-api:jar:1.2.0:compile
[INFO] | +- com.sirea.amp.partner.oemil:oemil-integration:jar:1.0.4-7:compile
[INFO] | | +- com.nimbusds:nimbus-jose-jwt:jar:8.19:compile
[INFO] | | | \- com.github.stephenc.jcip:jcip-annotations:jar:1.0-1:compile
[INFO] | | \- com.sirea.amp:amp-schema:jar:0.0.2-SNAPSHOT:compile
[INFO] | | +- com.google.protobuf:protobuf-java:jar:3.14.0:compile
[INFO] | | \- com.google.protobuf:protobuf-java-util:jar:3.14.0:compile
[INFO] | | \- com.google.code.gson:gson:jar:2.8.6:compile
[INFO] | +- javax:javaee-api:jar:8.0.1:compile
[INFO] | | \- com.sun.mail:javax.mail:jar:1.6.2:compile
[INFO] | | \- javax.activation:activation:jar:1.1:compile
[INFO] | \- org.bouncycastle:bcpkix-jdk15on:jar:1.68:compile
[INFO] | \- org.bouncycastle:bcprov-jdk15on:jar:1.68:compile
[INFO] +- com.sirea.ota:server-interface-api:jar:0.0.1-SNAPSHOT:compile
[INFO] +- com.sirea.ota:ota-jpa:jar:0.0.1-SNAPSHOT:compile
[INFO] | +- org.flywaydb:flyway-core:jar:6.5.7:compile
[INFO] | \- org.projectlombok:lombok:jar:1.18.16:compile
[INFO] +- com.sirea.ota:ota-converter:jar:0.0.1-SNAPSHOT:compile
[INFO] | +- com.bazaarvoice.jolt:jolt-core:jar:0.1.1:compile
[INFO] | | \- javax.inject:javax.inject:jar:1:compile
[INFO] | \- com.bazaarvoice.jolt:json-utils:jar:0.1.1:compile
[INFO] +- com.sirea.ota:ota-rest-common:jar:0.0.1-SNAPSHOT:compile
[INFO] | +- com.google.guava:guava:jar:30.1-jre:compile
[INFO] | | +- com.google.guava:failureaccess:jar:1.0.1:compile
[INFO] | | +- com.google.guava:listenablefuture:jar:9999.0-empty-to-avoid-conflict-with-guava:compile
[INFO] | | +- com.google.code.findbugs:jsr305:jar:3.0.2:compile
[INFO] | | +- org.checkerframework:checker-qual:jar:3.5.0:compile
[INFO] | | +- com.google.errorprone:error_prone_annotations:jar:2.3.4:compile
[INFO] | | \- com.google.j2objc:j2objc-annotations:jar:1.3:compile
[INFO] | +- org.springframework.data:spring-data-commons:jar:2.3.6.RELEASE:compile
[INFO] | +- org.springframework.data:spring-data-redis:jar:2.3.6.RELEASE:compile
[INFO] | | +- org.springframework.data:spring-data-keyvalue:jar:2.3.6.RELEASE:compile
[INFO] | | +- org.springframework:spring-tx:jar:5.2.12.RELEASE:compile
[INFO] | | +- org.springframework:spring-oxm:jar:5.2.12.RELEASE:compile
[INFO] | | \- org.springframework:spring-context-support:jar:5.2.12.RELEASE:compile
[INFO] | +- io.lettuce:lettuce-core:jar:5.3.6.RELEASE:compile
[INFO] | | +- io.netty:netty-common:jar:4.1.58.Final:compile
[INFO] | | +- io.netty:netty-handler:jar:4.1.58.Final:compile
[INFO] | | | +- io.netty:netty-resolver:jar:4.1.58.Final:compile
[INFO] | | | +- io.netty:netty-buffer:jar:4.1.58.Final:compile
[INFO] | | | \- io.netty:netty-codec:jar:4.1.58.Final:compile
[INFO] | | +- io.netty:netty-transport:jar:4.1.58.Final:compile
[INFO] | | \- io.projectreactor:reactor-core:jar:3.3.13.RELEASE:compile
[INFO] | | \- org.reactivestreams:reactive-streams:jar:1.0.3:compile
[INFO] | +- org.apache.commons:commons-pool2:jar:2.8.1:compile
[INFO] | \- commons-io:commons-io:jar:2.8.0:compile
[INFO] +- org.springframework.boot:spring-boot-starter-amqp:jar:2.3.8.RELEASE:compile
[INFO] | +- org.springframework.boot:spring-boot-starter:jar:2.3.8.RELEASE:compile
[INFO] | | +- org.springframework.boot:spring-boot:jar:2.3.8.RELEASE:compile
[INFO] | | +- org.springframework.boot:spring-boot-autoconfigure:jar:2.3.8.RELEASE:compile
[INFO] | | +- org.springframework.boot:spring-boot-starter-logging:jar:2.3.8.RELEASE:compile
[INFO] | | +- jakarta.annotation:jakarta.annotation-api:jar:1.3.5:compile
[INFO] | | \- org.yaml:snakeyaml:jar:1.26:compile
[INFO] | +- org.springframework:spring-messaging:jar:5.2.12.RELEASE:compile
[INFO] | \- org.springframework.amqp:spring-rabbit:jar:2.3.4:compile
[INFO] | +- org.springframework.amqp:spring-amqp:jar:2.3.4:compile
[INFO] | \- com.rabbitmq:amqp-client:jar:5.9.0:compile
[INFO] +- org.springframework.boot:spring-boot-starter-data-jpa:jar:2.3.8.RELEASE:compile
[INFO] | +- org.springframework.boot:spring-boot-starter-jdbc:jar:2.3.8.RELEASE:compile
[INFO] | | +- com.zaxxer:HikariCP:jar:3.4.5:compile
[INFO] | | \- org.springframework:spring-jdbc:jar:5.2.12.RELEASE:compile
[INFO] | +- jakarta.transaction:jakarta.transaction-api:jar:1.3.3:compile
[INFO] | +- jakarta.persistence:jakarta.persistence-api:jar:2.2.3:compile
[INFO] | +- org.hibernate:hibernate-core:jar:5.4.27.Final:compile
[INFO] | | +- org.jboss.logging:jboss-logging:jar:3.2.1.Final:compile
[INFO] | | +- antlr:antlr:jar:2.7.7:compile
[INFO] | | +- org.jboss:jandex:jar:2.1.3.Final:compile
[INFO] | | +- com.fasterxml:classmate:jar:1.5.1:compile
[INFO] | | +- org.dom4j:dom4j:jar:2.1.3:compile
[INFO] | | +- org.hibernate.common:hibernate-commons-annotations:jar:5.1.2.Final:compile
[INFO] | | \- org.glassfish.jaxb:jaxb-runtime:jar:2.3.3:compile
[INFO] | | +- org.glassfish.jaxb:txw2:jar:2.3.3:compile
[INFO] | | +- com.sun.istack:istack-commons-runtime:jar:3.0.11:compile
[INFO] | | \- com.sun.activation:jakarta.activation:jar:1.2.2:runtime
[INFO] | +- org.springframework.data:spring-data-jpa:jar:2.3.6.RELEASE:compile
[INFO] | | \- org.springframework:spring-orm:jar:5.2.12.RELEASE:compile
[INFO] | \- org.springframework:spring-aspects:jar:5.2.12.RELEASE:compile
[INFO] +- com.sirea.atsp:oemResponseExtension:jar:1.0.2:compile
[INFO] +- redis.clients:jedis:jar:2.7.2:compile
[INFO] +- com.sirea.atsp:redis-client-wrapper:jar:1.1.0-SNAPSHOT:compile
[INFO] +- javax.el:javax.el-api:jar:3.0.0:test
[INFO] +- ru.yandex.qatools.allure:allure-junit-adaptor:jar:1.5.4:test
[INFO] | +- ru.yandex.qatools.allure:allure-java-aspects:jar:1.5.4:test
[INFO] | | +- ru.yandex.qatools.allure:allure-java-adaptor-api:jar:1.5.4:test
[INFO] | | | +- ru.yandex.qatools.allure:allure-java-annotations:jar:1.5.4:test
[INFO] | | | | \- ru.yandex.qatools.allure:allure-model:jar:1.5.4:test
[INFO] | | | | +- org.jvnet.jaxb2_commons:jaxb2-basics-runtime:jar:0.9.3:test
[INFO] | | | | \- ru.qatools.commons:properties:jar:2.0.RC5:test
[INFO] | | | \- org.apache.tika:tika-core:jar:1.7:test
[INFO] | | \- org.aspectj:aspectjrt:jar:1.9.6:test
[INFO] | \- junit:junit:jar:4.13.1:test
[INFO] +- org.powermock:powermock-module-junit4:jar:2.0.9:test
[INFO] | +- org.powermock:powermock-module-junit4-common:jar:2.0.9:test
[INFO] | | +- org.powermock:powermock-reflect:jar:2.0.9:test
[INFO] | | | \- net.bytebuddy:byte-buddy-agent:jar:1.10.19:test
[INFO] | | \- org.powermock:powermock-core:jar:2.0.9:test
[INFO] | \- org.hamcrest:hamcrest-core:jar:2.2:test
[INFO] +- org.javassist:javassist:jar:3.20.0-GA:compile
[INFO] +- com.sirea.orchestrator:sirea-job-orchestrator:jar:1.0.2.RELEASE:compile
[INFO] | +- org.springframework.boot:spring-boot-starter-webflux:jar:2.3.8.RELEASE:compile
[INFO] | | +- org.springframework.boot:spring-boot-starter-reactor-netty:jar:2.3.8.RELEASE:compile
[INFO] | | | \- io.projectreactor.netty:reactor-netty:jar:0.9.16.RELEASE:compile
[INFO] | | | +- io.netty:netty-codec-http:jar:4.1.58.Final:compile
[INFO] | | | +- io.netty:netty-codec-http2:jar:4.1.58.Final:compile
[INFO] | | | +- io.netty:netty-handler-proxy:jar:4.1.58.Final:compile
[INFO] | | | | \- io.netty:netty-codec-socks:jar:4.1.58.Final:compile
[INFO] | | | \- io.netty:netty-transport-native-epoll:jar:linux-x86_64:4.1.58.Final:compile
[INFO] | | | \- io.netty:netty-transport-native-unix-common:jar:4.1.58.Final:compile
[INFO] | | +- org.springframework:spring-webflux:jar:5.2.12.RELEASE:compile
[INFO] | | \- org.synchronoss.cloud:nio-multipart-parser:jar:1.1.0:compile
[INFO] | | \- org.synchronoss.cloud:nio-stream-storage:jar:1.1.3:compile
[INFO] | +- org.springframework.boot:spring-boot-starter-actuator:jar:2.3.8.RELEASE:compile
[INFO] | | +- org.springframework.boot:spring-boot-actuator-autoconfigure:jar:2.3.8.RELEASE:compile
[INFO] | | | \- org.springframework.boot:spring-boot-actuator:jar:2.3.8.RELEASE:compile
[INFO] | | \- io.micrometer:micrometer-core:jar:1.5.10:compile
[INFO] | | +- org.hdrhistogram:HdrHistogram:jar:2.1.12:compile
[INFO] | | \- org.latencyutils:LatencyUtils:jar:2.0.3:runtime
[INFO] | +- org.springframework.kafka:spring-kafka:jar:2.5.11.RELEASE:compile
[INFO] | | +- org.springframework.retry:spring-retry:jar:1.2.5.RELEASE:compile
[INFO] | | \- org.apache.kafka:kafka-clients:jar:2.5.1:compile
[INFO] | | +- com.github.luben:zstd-jni:jar:1.4.4-7:compile
[INFO] | | +- org.lz4:lz4-java:jar:1.7.1:compile
[INFO] | | \- org.xerial.snappy:snappy-java:jar:1.1.7.3:compile
[INFO] | +- mysql:mysql-connector-java:jar:8.0.23:runtime
[INFO] | \- org.springframework.cloud:spring-cloud-starter-stream-kafka:jar:3.0.13.RELEASE:compile
[INFO] | \- org.springframework.cloud:spring-cloud-stream-binder-kafka:jar:3.0.13.RELEASE:compile
[INFO] | +- org.springframework.cloud:spring-cloud-stream-binder-kafka-core:jar:3.0.13.RELEASE:compile
[INFO] | | \- org.springframework.integration:spring-integration-kafka:jar:3.3.1.RELEASE:compile
[INFO] | \- org.springframework.cloud:spring-cloud-stream:jar:3.0.13.RELEASE:compile
[INFO] | +- org.springframework.boot:spring-boot-starter-validation:jar:2.3.8.RELEASE:compile
[INFO] | | \- org.hibernate.validator:hibernate-validator:jar:6.1.7.Final:compile
[INFO] | | \- jakarta.validation:jakarta.validation-api:jar:2.0.2:compile
[INFO] | +- org.springframework.integration:spring-integration-core:jar:5.3.5.RELEASE:compile
[INFO] | +- org.springframework.integration:spring-integration-jmx:jar:5.3.5.RELEASE:compile
[INFO] | \- org.springframework.cloud:spring-cloud-function-context:jar:3.0.14.RELEASE:compile
[INFO] | +- net.jodah:typetools:jar:0.6.2:compile
[INFO] | \- org.springframework.cloud:spring-cloud-function-core:jar:3.0.14.RELEASE:compile
[INFO] +- org.powermock:powermock-api-mockito2:jar:2.0.9:test
[INFO] | +- org.powermock:powermock-api-support:jar:2.0.9:test
[INFO] | \- org.mockito:mockito-core:jar:3.3.3:test
[INFO] +- org.springframework.boot:spring-boot-starter-test:jar:2.3.8.RELEASE:test
[INFO] | +- org.springframework.boot:spring-boot-test:jar:2.3.8.RELEASE:test
[INFO] | +- org.springframework.boot:spring-boot-test-autoconfigure:jar:2.3.8.RELEASE:test
[INFO] | +- com.jayway.jsonpath:json-path:jar:2.5.0:compile
[INFO] | | \- net.minidev:json-smart:jar:2.3:compile
[INFO] | | \- net.minidev:accessors-smart:jar:1.2:compile
[INFO] | +- jakarta.xml.bind:jakarta.xml.bind-api:jar:2.3.3:compile
[INFO] | | \- jakarta.activation:jakarta.activation-api:jar:1.2.2:compile
[INFO] | +- org.assertj:assertj-core:jar:3.18.1:test
[INFO] | +- org.hamcrest:hamcrest:jar:2.2:test
[INFO] | +- org.junit.jupiter:junit-jupiter:jar:5.6.3:test
[INFO] | | +- org.junit.jupiter:junit-jupiter-api:jar:5.6.3:test
[INFO] | | | +- org.opentest4j:opentest4j:jar:1.2.0:test
[INFO] | | | \- org.junit.platform:junit-platform-commons:jar:1.6.3:test
[INFO] | | +- org.junit.jupiter:junit-jupiter-params:jar:5.6.3:test
[INFO] | | \- org.junit.jupiter:junit-jupiter-engine:jar:5.6.3:test
[INFO] | +- org.junit.vintage:junit-vintage-engine:jar:5.6.3:test
[INFO] | | +- org.apiguardian:apiguardian-api:jar:1.1.0:test
[INFO] | | \- org.junit.platform:junit-platform-engine:jar:1.6.3:test
[INFO] | +- org.mockito:mockito-junit-jupiter:jar:3.3.3:test
[INFO] | +- org.skyscreamer:jsonassert:jar:1.5.0:test
[INFO] | | \- com.vaadin.external.google:android-json:jar:0.0.20131108.vaadin1:test
[INFO] | +- org.springframework:spring-core:jar:5.2.12.RELEASE:compile
[INFO] | | \- org.springframework:spring-jcl:jar:5.2.12.RELEASE:compile
[INFO] | +- org.springframework:spring-test:jar:5.2.12.RELEASE:test
[INFO] | \- org.xmlunit:xmlunit-core:jar:2.7.0:test
[INFO] +- org.awaitility:awaitility:jar:3.0.0:test
[INFO] | +- org.hamcrest:hamcrest-library:jar:2.2:test
[INFO] | \- org.objenesis:objenesis:jar:2.5.1:test
[INFO] \- org.awaitility:awaitility-proxy:jar:3.0.0:test
[INFO] \- net.bytebuddy:byte-buddy:jar:1.10.19:compile
Question: So what is the problem here? Why my stubbing does not work if the static calls are inside abc(), but only CampaignHandlerFactory works?
Is there versions conflict?
java.util.Collections and java.util.stream.StreamSupport are system classes (Language and utility libraries that are part of JRE). The caller of the system class should be defined in #PrepareForTest({ClassThatCallsTheSystemClass.class}).
See documentation.
The way to go about mocking system classes are a bit different than
usual though. Normally you would prepare the class that contains the
static methods (let's call it X) you like to mock but because it's
impossible for PowerMock to prepare a system class for testing so
another approach has to be taken. So instead of preparing X you
prepare the class that calls the static methods in X!
So you need to add TestClazz.class into #PrepareForTest.
Correct definition:
#PrepareForTest({ CampaignHandlerFactory.class, TestClazz.class})
Execution test result:
============INSIDE ABC===========
Mock for List, hashCode: 1800605369
Mock for Stream, hashCode: 847606512
Mock for ICampaignHandler, hashCode: 1736458419
============OUTSIDE ABC===========
Mock for List, hashCode: 1800605369
Mock for Stream, hashCode: 847606512
Mock for ICampaignHandler, hashCode: 1736458419
I have just tried to upgrade the log4j library from version 2.3 to 2.17.1 to fix the well-known vulnerabilities that were discovered a few weeks ago. I am new to Maven, so I have little idea of what I am doing.
First, I changed my pom.xml project file and added all the log4j dependencies that I needed. I might have gone a little too far and only needed log4j-core and log4j-api, but just in case I added all of these:
...
<dependencies>
...
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j</artifactId>
<version>2.17.1</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.17.1</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.17.1</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-1.2-api</artifactId>
<version>2.17.1</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>2.17.1</version>
<type>pom</type>
</dependency>
...
</dependencies>
...
After doing this, the project compiles successfully if I run mvn clean package -U -Dmaven.test.skip=true. However, if I try to run the tests, I get the following error:
java.lang.NoClassDefFoundError: Could not initialize class org.apache.logging.log4j.core.LoggerContext
at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.createContext(ClassLoaderContextSelector.java:254)
at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.locateContext(ClassLoaderContextSelector.java:218)
at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.getContext(ClassLoaderContextSelector.java:140)
at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.getContext(ClassLoaderContextSelector.java:123)
at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:230)
at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:47)
at org.apache.logging.log4j.LogManager.getContext(LogManager.java:176)
at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:666)
at org.apache.logging.log4j.LogManager.getRootLogger(LogManager.java:700)
at org.mycomp.myproj.utils.TestUtils.removeLogFile(Unknown Source)
at org.mycomp.myproj.docs2tmx.AppTest.check(AppTest.java:48)
at org.mycomp.myproj.docs2tmx.AppTest.testApp(AppTest.java:30)
I tried to modify the scope of the dependencies to runtime or test, but it does not seem to change anything. Do any of you know how to solve this? If you further loggings, don't hesitate to comment.
[EDIT]
Here is my mvn dependency:tree -Dlog4j:
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] myproj_Docs2TMX
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building myproj_Docs2TMX 0.0.1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) # myproj_Docs2TMX ---
[INFO] org.mycomp.myproj:myproj_Docs2TMX:jar:0.0.1
[INFO] +- org.mycomp.myproj:myproj_Utils:jar:0.0.1:compile
[INFO] | +- org.mycomp.processor:PLBase:jar:2.0.1myproj:compile
[INFO] | | +- org.mycomp.processor:PLogger:jar:2.0.1:compile
[INFO] | | | +- org.apache.logging.log4j:log4j-1.2-api:jar:2.3:compile
[INFO] | | | \- com.fasterxml.jackson.dataformat:jackson-dataformat-xml:jar:2.7.2:compile
[INFO] | | | +- com.fasterxml.jackson.module:jackson-module-jaxb-annotations:jar:2.7.2:compile
[INFO] | | | \- org.codehaus.woodstox:stax2-api:jar:3.1.4:compile
[INFO] | | +- com.beust:jcommander:jar:1.48:compile
[INFO] | | \- com.googlecode.juniversalchardet:juniversalchardet:jar:1.0.3:compile
[INFO] | +- com.ctc.wstx:woodstox-osgi:jar:3.2.1.1:compile
[INFO] | +- org.apache.commons:commons-lang3:jar:3.4:compile
[INFO] | \- net.java.dev.stax-utils:stax-utils:jar:20070216:compile
[INFO] +- org.mycomp.processor:PLDocument:jar:2.0.1myproj:compile
[INFO] | +- org.apache.tika:tika-core:jar:1.20:compile
[INFO] | +- org.apache.tika:tika-parsers:jar:1.20:compile
[INFO] | | +- org.glassfish.jaxb:jaxb-runtime:jar:2.3.1:compile
[INFO] | | | +- javax.xml.bind:jaxb-api:jar:2.3.1:compile
[INFO] | | | +- org.glassfish.jaxb:txw2:jar:2.3.1:compile
[INFO] | | | +- com.sun.istack:istack-commons-runtime:jar:3.0.7:compile
[INFO] | | | +- org.jvnet.staxex:stax-ex:jar:1.8:compile
[INFO] | | | \- com.sun.xml.fastinfoset:FastInfoset:jar:1.2.15:compile
[INFO] | | +- com.sun.activation:javax.activation:jar:1.2.0:compile
[INFO] | | +- javax.annotation:javax.annotation-api:jar:1.3.2:compile
[INFO] | | +- org.gagravarr:vorbis-java-tika:jar:0.8:compile
[INFO] | | +- org.tallison:jmatio:jar:1.5:compile
[INFO] | | +- org.apache.james:apache-mime4j-core:jar:0.8.2:compile
[INFO] | | +- org.apache.james:apache-mime4j-dom:jar:0.8.2:compile
[INFO] | | +- org.apache.commons:commons-compress:jar:1.18:compile
[INFO] | | +- org.tukaani:xz:jar:1.8:compile
[INFO] | | +- com.epam:parso:jar:2.0.10:compile
[INFO] | | +- org.brotli:dec:jar:0.1.2:compile
[INFO] | | +- commons-codec:commons-codec:jar:1.11:compile
[INFO] | | +- org.apache.pdfbox:pdfbox:jar:2.0.13:compile
[INFO] | | | \- org.apache.pdfbox:fontbox:jar:2.0.13:compile
[INFO] | | +- org.apache.pdfbox:pdfbox-tools:jar:2.0.13:compile
[INFO] | | +- org.apache.pdfbox:jempbox:jar:1.8.16:compile
[INFO] | | +- org.bouncycastle:bcmail-jdk15on:jar:1.60:compile
[INFO] | | | \- org.bouncycastle:bcpkix-jdk15on:jar:1.60:compile
[INFO] | | +- org.bouncycastle:bcprov-jdk15on:jar:1.60:compile
[INFO] | | +- org.apache.poi:poi:jar:4.0.1:compile
[INFO] | | | +- org.apache.commons:commons-collections4:jar:4.2:compile
[INFO] | | | \- org.apache.commons:commons-math3:jar:3.6.1:compile
[INFO] | | +- org.apache.poi:poi-scratchpad:jar:4.0.1:compile
[INFO] | | +- org.apache.poi:poi-ooxml:jar:4.0.1:compile
[INFO] | | | +- org.apache.poi:poi-ooxml-schemas:jar:4.0.1:compile
[INFO] | | | \- com.github.virtuald:curvesapi:jar:1.05:compile
[INFO] | | +- com.healthmarketscience.jackcess:jackcess:jar:2.1.12:compile
[INFO] | | | \- commons-lang:commons-lang:jar:2.6:compile
[INFO] | | +- com.healthmarketscience.jackcess:jackcess-encrypt:jar:2.1.4:compile
[INFO] | | +- org.ccil.cowan.tagsoup:tagsoup:jar:1.2.1:compile
[INFO] | | +- org.ow2.asm:asm:jar:7.0:compile
[INFO] | | +- com.googlecode.mp4parser:isoparser:jar:1.1.22:compile
[INFO] | | +- com.drewnoakes:metadata-extractor:jar:2.11.0:compile
[INFO] | | | \- com.adobe.xmp:xmpcore:jar:5.1.3:compile
[INFO] | | +- de.l3s.boilerpipe:boilerpipe:jar:1.1.0:compile
[INFO] | | +- com.rometools:rome:jar:1.12.0:compile
[INFO] | | | \- com.rometools:rome-utils:jar:1.12.0:compile
[INFO] | | +- org.gagravarr:vorbis-java-core:jar:0.8:compile
[INFO] | | +- org.codelibs:jhighlight:jar:1.0.3:compile
[INFO] | | +- com.pff:java-libpst:jar:0.8.1:compile
[INFO] | | +- com.github.junrar:junrar:jar:2.0.0:compile
[INFO] | | +- org.apache.cxf:cxf-rt-rs-client:jar:3.2.7:compile
[INFO] | | | +- org.apache.cxf:cxf-rt-transports-http:jar:3.2.7:compile
[INFO] | | | +- org.apache.cxf:cxf-core:jar:3.2.7:compile
[INFO] | | | | +- com.fasterxml.woodstox:woodstox-core:jar:5.0.3:compile
[INFO] | | | | \- org.apache.ws.xmlschema:xmlschema-core:jar:2.2.3:compile
[INFO] | | | \- org.apache.cxf:cxf-rt-frontend-jaxrs:jar:3.2.7:compile
[INFO] | | | \- javax.ws.rs:javax.ws.rs-api:jar:2.1.1:compile
[INFO] | | +- org.apache.commons:commons-exec:jar:1.3:compile
[INFO] | | +- commons-io:commons-io:jar:2.6:compile
[INFO] | | +- com.googlecode.json-simple:json-simple:jar:1.1.1:compile
[INFO] | | +- com.github.openjson:openjson:jar:1.0.10:compile
[INFO] | | +- com.google.code.gson:gson:jar:2.8.5:compile
[INFO] | | +- org.slf4j:jul-to-slf4j:jar:1.7.25:compile
[INFO] | | +- org.slf4j:jcl-over-slf4j:jar:1.7.25:compile
[INFO] | | +- edu.ucar:netcdf4:jar:4.5.5:compile
[INFO] | | | \- net.jcip:jcip-annotations:jar:1.0:compile
[INFO] | | +- edu.ucar:grib:jar:4.5.5:compile
[INFO] | | | +- com.google.protobuf:protobuf-java:jar:2.5.0:compile
[INFO] | | | \- org.itadaki:bzip2:jar:0.9.1:compile
[INFO] | | +- net.java.dev.jna:jna:jar:5.1.0:compile
[INFO] | | +- org.jsoup:jsoup:jar:1.11.3:compile
[INFO] | | +- edu.ucar:cdm:jar:4.5.5:compile
[INFO] | | | +- edu.ucar:udunits:jar:4.5.5:compile
[INFO] | | | +- joda-time:joda-time:jar:2.2:compile
[INFO] | | | +- org.quartz-scheduler:quartz:jar:2.2.0:compile
[INFO] | | | | \- c3p0:c3p0:jar:0.9.1.1:compile
[INFO] | | | +- net.sf.ehcache:ehcache-core:jar:2.6.2:compile
[INFO] | | | \- com.google.guava:guava:jar:17.0:compile
[INFO] | | +- edu.ucar:httpservices:jar:4.5.5:compile
[INFO] | | +- org.apache.httpcomponents:httpclient:jar:4.5.6:compile
[INFO] | | | \- org.apache.httpcomponents:httpcore:jar:4.4.10:compile
[INFO] | | +- org.apache.httpcomponents:httpmime:jar:4.5.6:compile
[INFO] | | +- org.apache.commons:commons-csv:jar:1.6:compile
[INFO] | | +- org.apache.sis.core:sis-utility:jar:0.8:compile
[INFO] | | | \- javax.measure:unit-api:jar:1.0:compile
[INFO] | | +- org.apache.sis.storage:sis-netcdf:jar:0.8:compile
[INFO] | | | +- org.apache.sis.storage:sis-storage:jar:0.8:compile
[INFO] | | | | \- org.apache.sis.core:sis-feature:jar:0.8:compile
[INFO] | | | \- org.apache.sis.core:sis-referencing:jar:0.8:compile
[INFO] | | +- org.apache.sis.core:sis-metadata:jar:0.8:compile
[INFO] | | +- org.opengis:geoapi:jar:3.0.1:compile
[INFO] | | +- edu.usc.ir:sentiment-analysis-parser:jar:0.1:compile
[INFO] | | +- org.apache.uima:uimafit-core:jar:2.4.0:compile
[INFO] | | +- org.apache.uima:uimaj-core:jar:3.0.1:compile
[INFO] | | | +- org.bitbucket.mstrobel:procyon-compilertools:jar:0.5.32:compile
[INFO] | | | \- org.bitbucket.mstrobel:procyon-core:jar:0.5.32:compile
[INFO] | | +- org.jdom:jdom2:jar:2.0.6:compile
[INFO] | | +- com.fasterxml.jackson.core:jackson-annotations:jar:2.9.7:compile
[INFO] | | +- org.apache.pdfbox:jbig2-imageio:jar:3.0.2:compile
[INFO] | | \- com.github.jai-imageio:jai-imageio-core:jar:1.4.0:compile
[INFO] | +- org.mycomp:poi-sooxml-schemas:jar:4.0.1:compile
[INFO] | | \- org.apache.xmlbeans:xmlbeans:jar:3.0.2:compile
[INFO] | \- org.xerial:sqlite-jdbc:jar:3.25.2:compile
[INFO] +- org.mycomp.processor:PLModel:jar:2.0.1myproj:compile
[INFO] +- org.mycomp.processor:PLEngines:jar:2.0.1myproj:compile
[INFO] | +- org.mycomp:LanguageDetection:jar:0.0.3:compile
[INFO] | +- org.mycomp:aligner:jar:0.1.0:compile
[INFO] | | +- org.apache.lucene:lucene-core:jar:5.4.1:compile
[INFO] | | +- org.apache.lucene:lucene-analyzers-common:jar:5.4.1:compile
[INFO] | | +- org.apache.lucene:lucene-misc:jar:5.4.1:compile
[INFO] | | +- com.lmax:disruptor:jar:3.2.0:compile
[INFO] | | \- javax.jms:javax.jms-api:jar:2.0.1:compile
[INFO] | +- org.zeromq:jeromq:jar:0.4.0:compile
[INFO] | +- com.fasterxml.jackson.core:jackson-databind:jar:2.7.2:compile
[INFO] | +- com.fasterxml.jackson.core:jackson-core:jar:2.7.2:compile
[INFO] | +- org.apache.logging.log4j:log4j-slf4j-impl:jar:2.3:compile
[INFO] | \- org.apache.lucene:lucene-analyzers-stempel:jar:5.4.1:compile
[INFO] +- junit:junit:jar:3.8.1:test
[INFO] +- org.apache.logging.log4j:log4j:pom:2.17.1:compile
[INFO] +- org.apache.logging.log4j:log4j-core:pom:2.17.1:compile
[INFO] | \- org.apache.logging.log4j:log4j-api:jar:2.17.1:compile
[INFO] +- org.apache.logging.log4j:log4j-api:pom:2.17.1:compile
[INFO] +- org.apache.logging.log4j:log4j-1.2-api:pom:2.17.1:compile
[INFO] \- org.apache.logging.log4j:log4j-slf4j-impl:pom:2.17.1:compile
[INFO] +- org.slf4j:slf4j-api:jar:1.7.25:compile
[INFO] \- org.apache.logging.log4j:log4j-core:jar:2.17.1:compile
[INFO]
[INFO] Reactor Summary:
[INFO]
[INFO] myproj_Docs2TMX ...................................... SUCCESS [ 0.355 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.898 s
[INFO] Finished at: 2022-01-18T13:17:36+01:00
[INFO] Final Memory: 41M/1963M
[INFO] ------------------------------------------------------------------------
It is a little bit trimmed to only show the information about the project that fails during the tests.
In a spring boot application running google cloud dataflow code. The dataflow takes data from google PubSub, transform incoming data and output result to bigquery for storage. The code does not have any syntax errors. The problem is when the application is run, the following exception is thrown.
Exception in thread "main" java.lang.RuntimeException: Failed to construct instance from factory method DataflowRunner#fromOptions(interface org.apache.beam.sdk.options.PipelineOptions)
at org.apache.beam.sdk.util.InstanceBuilder.buildFromMethod(InstanceBuilder.java:233)
at org.apache.beam.sdk.util.InstanceBuilder.build(InstanceBuilder.java:162)
at org.apache.beam.sdk.PipelineRunner.fromOptions(PipelineRunner.java:52)
at org.apache.beam.sdk.Pipeline.create(Pipeline.java:142)
at com.trackers.exlon.ExlonApplication.main(ExlonApplication.java:69)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.beam.sdk.util.InstanceBuilder.buildFromMethod(InstanceBuilder.java:222)
... 4 more
Caused by: java.lang.NoClassDefFoundError: com/google/api/services/cloudresourcemanager/CloudResourceManager$Builder
at org.apache.beam.sdk.extensions.gcp.options.GcpOptions$GcpTempLocationFactory.newCloudResourceManagerClient(GcpOptions.java:369)
at org.apache.beam.sdk.extensions.gcp.options.GcpOptions$GcpTempLocationFactory.create(GcpOptions.java:240)
at org.apache.beam.sdk.extensions.gcp.options.GcpOptions$GcpTempLocationFactory.create(GcpOptions.java:228)
at org.apache.beam.sdk.options.ProxyInvocationHandler.returnDefaultHelper(ProxyInvocationHandler.java:592)
at org.apache.beam.sdk.options.ProxyInvocationHandler.getDefault(ProxyInvocationHandler.java:533)
at org.apache.beam.sdk.options.ProxyInvocationHandler.invoke(ProxyInvocationHandler.java:156)
at com.sun.proxy.$Proxy85.getGcpTempLocation(Unknown Source)
at org.apache.beam.runners.dataflow.DataflowRunner.fromOptions(DataflowRunner.java:223)
... 9 more
Caused by: java.lang.ClassNotFoundException: com.google.api.services.cloudresourcemanager.CloudResourceManager$Builder
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 17 more
As this is a spring boot maven project, instead of copy pasting POM file dependencies, i think below dependency tree will show more on dependencies and transitive dependencies as well, though if POM is needed i will switch this with POM file
[INFO] +- org.springframework.boot:spring-boot-starter-webflux:jar:2.0.0.RC1:compile
[INFO] | +- org.springframework.boot:spring-boot-starter:jar:2.0.0.RC1:compile
[INFO] | | +- org.springframework.boot:spring-boot:jar:2.0.0.RC1:compile
[INFO] | | | \- org.springframework:spring-context:jar:5.0.3.RELEASE:compile
[INFO] | | | +- org.springframework:spring-aop:jar:5.0.3.RELEASE:compile
[INFO] | | | \- org.springframework:spring-expression:jar:5.0.3.RELEASE:compile
[INFO] | | +- org.springframework.boot:spring-boot-autoconfigure:jar:2.0.0.RC1:compile
[INFO] | | +- org.springframework.boot:spring-boot-starter-logging:jar:2.0.0.RC1:compile
[INFO] | | | +- ch.qos.logback:logback-classic:jar:1.2.3:compile
[INFO] | | | | \- ch.qos.logback:logback-core:jar:1.2.3:compile
[INFO] | | | +- org.apache.logging.log4j:log4j-to-slf4j:jar:2.10.0:compile
[INFO] | | | | \- org.apache.logging.log4j:log4j-api:jar:2.10.0:compile
[INFO] | | | \- org.slf4j:jul-to-slf4j:jar:1.7.25:compile
[INFO] | | +- javax.annotation:javax.annotation-api:jar:1.3.1:compile
[INFO] | | \- org.yaml:snakeyaml:jar:1.19:runtime
[INFO] | +- org.springframework.boot:spring-boot-starter-json:jar:2.0.0.RC1:compile
[INFO] | | +- com.fasterxml.jackson.datatype:jackson-datatype-jdk8:jar:2.9.2:compile
[INFO] | | +- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.9.2:compile
[INFO] | | \- com.fasterxml.jackson.module:jackson-module-parameter-names:jar:2.9.2:compile
[INFO] | +- org.springframework.boot:spring-boot-starter-reactor-netty:jar:2.0.0.RC1:compile
[INFO] | | \- io.projectreactor.ipc:reactor-netty:jar:0.7.3.RELEASE:compile
[INFO] | | \- io.netty:netty-transport-native-epoll:jar:4.1.20.Final:compile
[INFO] | | +- io.netty:netty-common:jar:4.1.20.Final:compile
[INFO] | | \- io.netty:netty-transport-native-unix-common:jar:4.1.20.Final:compile
[INFO] | +- org.hibernate.validator:hibernate-validator:jar:6.0.7.Final:compile
[INFO] | | +- javax.validation:validation-api:jar:2.0.1.Final:compile
[INFO] | | +- org.jboss.logging:jboss-logging:jar:3.3.1.Final:compile
[INFO] | | \- com.fasterxml:classmate:jar:1.3.4:compile
[INFO] | +- org.springframework:spring-web:jar:5.0.3.RELEASE:compile
[INFO] | | \- org.springframework:spring-beans:jar:5.0.3.RELEASE:compile
[INFO] | +- org.springframework:spring-webflux:jar:5.0.3.RELEASE:compile
[INFO] | \- org.synchronoss.cloud:nio-multipart-parser:jar:1.1.0:compile
[INFO] | \- org.synchronoss.cloud:nio-stream-storage:jar:1.1.3:compile
[INFO] +- org.springframework.cloud:spring-cloud-gcp-starter-pubsub:jar:1.0.0.BUILD-SNAPSHOT:compile
[INFO] | +- org.springframework.cloud:spring-cloud-gcp-starter:jar:1.0.0.BUILD-SNAPSHOT:compile
[INFO] | | +- org.springframework.cloud:spring-cloud-gcp-core:jar:1.0.0.BUILD-SNAPSHOT:compile
[INFO] | | \- org.springframework.cloud:spring-cloud-gcp-autoconfigure:jar:1.0.0.BUILD-SNAPSHOT:compile
[INFO] | +- org.springframework.cloud:spring-cloud-gcp-pubsub:jar:1.0.0.BUILD-SNAPSHOT:compile
[INFO] | | +- com.google.cloud:google-cloud-pubsub:jar:0.33.0-beta:compile
[INFO] | | \- org.springframework:spring-messaging:jar:5.0.3.RELEASE:compile
[INFO] | \- org.slf4j:slf4j-api:jar:1.7.25:compile
[INFO] +- org.apache.beam:beam-sdks-java-core:jar:2.2.0:compile
[INFO] | +- com.google.code.findbugs:jsr305:jar:3.0.1:compile
[INFO] | +- com.fasterxml.jackson.core:jackson-core:jar:2.9.2:compile
[INFO] | +- com.fasterxml.jackson.core:jackson-annotations:jar:2.9.0:compile
[INFO] | +- com.fasterxml.jackson.core:jackson-databind:jar:2.9.2:compile
[INFO] | +- org.apache.avro:avro:jar:1.8.2:compile
[INFO] | | +- org.codehaus.jackson:jackson-core-asl:jar:1.9.13:compile
[INFO] | | +- org.codehaus.jackson:jackson-mapper-asl:jar:1.9.13:compile
[INFO] | | +- com.thoughtworks.paranamer:paranamer:jar:2.7:compile
[INFO] | | +- org.apache.commons:commons-compress:jar:1.8.1:compile
[INFO] | | \- org.tukaani:xz:jar:1.5:compile
[INFO] | +- org.xerial.snappy:snappy-java:jar:1.1.4:compile
[INFO] | \- joda-time:joda-time:jar:2.9.9:compile
[INFO] +- com.google.cloud:google-cloud-bigquery:jar:0.33.0-beta:compile
[INFO] | +- com.google.cloud:google-cloud-core:jar:1.15.0:compile
[INFO] | | +- com.google.api:api-common:jar:1.2.0:compile
[INFO] | | +- com.google.api:gax:jar:1.16.0:compile
[INFO] | | | +- com.google.auto.value:auto-value:jar:1.2:compile
[INFO] | | | \- org.threeten:threetenbp:jar:1.3.3:compile
[INFO] | | +- com.google.protobuf:protobuf-java-util:jar:3.5.1:compile
[INFO] | | | \- com.google.code.gson:gson:jar:2.8.2:compile
[INFO] | | +- com.google.api.grpc:proto-google-common-protos:jar:1.0.4:compile
[INFO] | | \- com.google.api.grpc:proto-google-iam-v1:jar:0.1.28:compile
[INFO] | +- com.google.cloud:google-cloud-core-http:jar:1.15.0:compile
[INFO] | | +- com.google.oauth-client:google-oauth-client:jar:1.23.0:compile
[INFO] | | +- com.google.http-client:google-http-client-appengine:jar:1.23.0:compile
[INFO] | | +- com.google.http-client:google-http-client-jackson:jar:1.23.0:compile
[INFO] | | \- com.google.api:gax-httpjson:jar:0.33.0:compile
[INFO] | \- com.google.apis:google-api-services-bigquery:jar:v2-rev347-1.22.0:compile
[INFO] +- io.grpc:grpc-core:jar:1.9.0:compile
[INFO] | +- io.grpc:grpc-context:jar:1.9.0:compile
[INFO] | +- com.google.guava:guava:jar:20.0:compile
[INFO] | +- com.google.errorprone:error_prone_annotations:jar:2.1.2:compile
[INFO] | +- com.google.instrumentation:instrumentation-api:jar:0.4.3:compile
[INFO] | +- io.opencensus:opencensus-api:jar:0.10.0:compile
[INFO] | \- io.opencensus:opencensus-contrib-grpc-metrics:jar:0.10.0:compile
[INFO] +- io.grpc:grpc-netty:jar:1.9.0:compile
[INFO] | +- io.netty:netty-codec-http2:jar:4.1.20.Final:compile
[INFO] | | +- io.netty:netty-codec-http:jar:4.1.20.Final:compile
[INFO] | | | \- io.netty:netty-codec:jar:4.1.20.Final:compile
[INFO] | | \- io.netty:netty-handler:jar:4.1.20.Final:compile
[INFO] | | \- io.netty:netty-buffer:jar:4.1.20.Final:compile
[INFO] | \- io.netty:netty-handler-proxy:jar:4.1.20.Final:compile
[INFO] | +- io.netty:netty-transport:jar:4.1.20.Final:compile
[INFO] | | \- io.netty:netty-resolver:jar:4.1.20.Final:compile
[INFO] | \- io.netty:netty-codec-socks:jar:4.1.20.Final:compile
[INFO] +- org.apache.beam:beam-runners-google-cloud-dataflow-java:jar:2.2.0:compile
[INFO] | +- org.apache.beam:beam-sdks-java-extensions-google-cloud-platform-core:jar:2.2.0:compile
[INFO] | | +- com.google.cloud.bigdataoss:gcsio:jar:1.4.5:compile
[INFO] | | \- com.google.apis:google-api-services-cloudresourcemanager:jar:v1beta1-rev10-1.21.0:compile
[INFO] | +- org.apache.beam:beam-sdks-common-runner-api:jar:2.2.0:compile
[INFO] | | +- com.google.protobuf:protobuf-java:jar:3.5.1:compile
[INFO] | | +- io.grpc:grpc-protobuf:jar:1.9.0:compile
[INFO] | | | \- io.grpc:grpc-protobuf-lite:jar:1.9.0:compile
[INFO] | | \- io.grpc:grpc-stub:jar:1.9.0:compile
[INFO] | +- org.apache.beam:beam-sdks-java-io-google-cloud-platform:jar:2.2.0:compile
[INFO] | | +- org.apache.beam:beam-sdks-java-extensions-protobuf:jar:2.2.0:compile
[INFO] | | +- com.google.api:gax-grpc:jar:1.16.0:compile
[INFO] | | +- com.google.cloud:google-cloud-core-grpc:jar:1.15.0:compile
[INFO] | | +- com.google.apis:google-api-services-pubsub:jar:v1-rev10-1.22.0:compile
[INFO] | | +- com.google.api.grpc:grpc-google-cloud-pubsub-v1:jar:0.1.28:compile
[INFO] | | +- com.google.api.grpc:proto-google-cloud-pubsub-v1:jar:0.1.28:compile
[INFO] | | +- com.google.cloud.datastore:datastore-v1-proto-client:jar:1.6.0:compile
[INFO] | | | +- com.google.api.grpc:proto-google-cloud-datastore-v1:jar:0.1.28:compile
[INFO] | | | \- com.google.http-client:google-http-client-protobuf:jar:1.20.0:compile
[INFO] | | +- com.google.cloud.datastore:datastore-v1-protos:jar:1.3.0:compile
[INFO] | | | \- com.google.api.grpc:grpc-google-common-protos:jar:1.0.4:compile
[INFO] | | +- io.grpc:grpc-auth:jar:1.9.0:compile
[INFO] | | +- io.grpc:grpc-all:jar:1.2.0:runtime
[INFO] | | | +- io.grpc:grpc-okhttp:jar:1.2.0:runtime
[INFO] | | | | +- com.squareup.okhttp:okhttp:jar:2.5.0:runtime
[INFO] | | | | \- com.squareup.okio:okio:jar:1.6.0:runtime
[INFO] | | | \- io.grpc:grpc-protobuf-nano:jar:1.2.0:runtime
[INFO] | | | \- com.google.protobuf.nano:protobuf-javanano:jar:3.0.0-alpha-5:runtime
[INFO] | | +- com.google.cloud:google-cloud-spanner:jar:0.33.0-beta:compile
[INFO] | | | +- com.google.api.grpc:proto-google-cloud-spanner-v1:jar:0.1.28:compile
[INFO] | | | +- com.google.api.grpc:proto-google-cloud-spanner-admin-instance-v1:jar:0.1.28:compile
[INFO] | | | +- com.google.api.grpc:grpc-google-cloud-spanner-v1:jar:0.1.28:compile
[INFO] | | | +- com.google.api.grpc:grpc-google-cloud-spanner-admin-database-v1:jar:0.1.28:compile
[INFO] | | | +- com.google.api.grpc:grpc-google-cloud-spanner-admin-instance-v1:jar:0.1.28:compile
[INFO] | | | \- io.opencensus:opencensus-contrib-grpc-util:jar:0.10.0:compile
[INFO] | | +- com.google.cloud.bigtable:bigtable-protos:jar:1.0.0-pre3:compile
[INFO] | | +- com.google.cloud.bigtable:bigtable-client-core:jar:1.0.0-pre3:compile
[INFO] | | | +- commons-logging:commons-logging:jar:1.2:compile
[INFO] | | | +- com.google.auth:google-auth-library-appengine:jar:0.7.0:compile
[INFO] | | | \- io.dropwizard.metrics:metrics-core:jar:3.2.6:compile
[INFO] | | +- io.netty:netty-tcnative-boringssl-static:jar:2.0.7.Final:compile
[INFO] | | \- com.google.api.grpc:proto-google-cloud-spanner-admin-database-v1:jar:0.1.28:compile
[INFO] | +- com.google.api-client:google-api-client:jar:1.23.0:compile
[INFO] | +- com.google.http-client:google-http-client:jar:1.23.0:compile
[INFO] | | \- org.apache.httpcomponents:httpclient:jar:4.5.5:compile
[INFO] | | +- org.apache.httpcomponents:httpcore:jar:4.4.9:compile
[INFO] | | \- commons-codec:commons-codec:jar:1.11:compile
[INFO] | +- com.google.http-client:google-http-client-jackson2:jar:1.23.0:compile
[INFO] | +- com.google.apis:google-api-services-dataflow:jar:v1b3-rev213-1.22.0:compile
[INFO] | +- com.google.apis:google-api-services-clouddebugger:jar:v2-rev8-1.22.0:compile
[INFO] | +- com.google.apis:google-api-services-storage:jar:v1-rev114-1.23.0:compile
[INFO] | +- com.google.auth:google-auth-library-credentials:jar:0.9.0:compile
[INFO] | +- com.google.auth:google-auth-library-oauth2-http:jar:0.7.1:compile
[INFO] | \- com.google.cloud.bigdataoss:util:jar:1.4.5:compile
[INFO] | +- com.google.api-client:google-api-client-java6:jar:1.20.0:compile
[INFO] | +- com.google.api-client:google-api-client-jackson2:jar:1.20.0:compile
[INFO] | \- com.google.oauth-client:google-oauth-client-java6:jar:1.20.0:compile
[INFO] +- net.sf.marineapi:marineapi:jar:0.10.0:compile
[INFO] +- org.projectlombok:lombok:jar:1.16.20:compile (optional)
[INFO] +- org.springframework.boot:spring-boot-starter-test:jar:2.0.0.RC1:test
[INFO] | +- org.springframework.boot:spring-boot-test:jar:2.0.0.RC1:test
[INFO] | +- org.springframework.boot:spring-boot-test-autoconfigure:jar:2.0.0.RC1:test
[INFO] | +- com.jayway.jsonpath:json-path:jar:2.4.0:test
[INFO] | | \- net.minidev:json-smart:jar:2.3:test
[INFO] | | \- net.minidev:accessors-smart:jar:1.2:test
[INFO] | | \- org.ow2.asm:asm:jar:5.0.4:test
[INFO] | +- junit:junit:jar:4.12:compile
[INFO] | +- org.assertj:assertj-core:jar:3.9.0:test
[INFO] | +- org.mockito:mockito-core:jar:2.13.0:test
[INFO] | | +- net.bytebuddy:byte-buddy:jar:1.7.9:test
[INFO] | | +- net.bytebuddy:byte-buddy-agent:jar:1.7.9:test
[INFO] | | \- org.objenesis:objenesis:jar:2.6:test
[INFO] | +- org.hamcrest:hamcrest-core:jar:1.3:compile
[INFO] | +- org.hamcrest:hamcrest-library:jar:1.3:test
[INFO] | +- org.skyscreamer:jsonassert:jar:1.5.0:test
[INFO] | | \- com.vaadin.external.google:android-json:jar:0.0.20131108.vaadin1:test
[INFO] | +- org.springframework:spring-core:jar:5.0.3.RELEASE:compile
[INFO] | | \- org.springframework:spring-jcl:jar:5.0.3.RELEASE:compile
[INFO] | +- org.springframework:spring-test:jar:5.0.3.RELEASE:test
[INFO] | \- org.xmlunit:xmlunit-core:jar:2.5.1:test
[INFO] \- io.projectreactor:reactor-test:jar:3.1.3.RELEASE:test
[INFO] \- io.projectreactor:reactor-core:jar:3.1.3.RELEASE:compile
[INFO] \- org.reactivestreams:reactive-streams:jar:1.0.2:compile
What google cloud dataflow dependencies should i use for a pipeline to run successfuly.
Add the newer version of the cloudresourcemanager to your POM.
<dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-cloudresourcemanager</artifactId>
<version>v1-rev6-1.22.0</version>
</dependency>
Full explanation here.
Please use this dependency in your pom.xml
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-cloudresourcemanager</artifactId>
<version>v1beta1-rev3-1.20.0</version>
I'm attempting to use Hibernate Validator in an API gateway framework. The code eventually runs in Karaf, but I'm trying to get a unit test (not a PAX test) working first. I'll be using Mockito for mocking, but I don't think that's an issue yet.
I'm using "hibernate-validator" and "hibernate-validator-annotation-processor", version 5.4.1.Final.
When I run the test, I get the following:
HV000183: Unable to initialize 'javax.el.ExpressionFactory'. Check that you have the EL dependencies on the classpath, or use ParameterMessageInterpolator instead
From other occurrences of this, I concluded that I have to add "org.glassfish:javax.el:3.0.0". Unfortunately, this had no effect. Exact same exception.
Update:
Some advice I've seen said to REMOVE the "javax.el-api" artifact. I found this referenced in one POM, so I commented it out. I also noticed that the "cdi-api" artifact appears to pull it in transitively, so I also commented that out.
Unfortunately, "mvn dependency:tree" still shows the 2.2.5 version of "javax.el-api" showing up, along with the 3.0.0 version of the glassfish "javax.el" artifact.
How do I get past this?
Update:
I've now updated my dependencies so that I have only "javax.el", version 3.0.1-b08, no "api" variant, but I'm still getting the error.
Here's my current dependency tree:
[INFO] mygroupid:usl-fraudcheck-impl:bundle:2.5.0-SNAPSHOT
[INFO] +- mygroupid:usl-csi-jaxb-base:jar:2.5.0-SNAPSHOT:compile
[INFO] | +- mygroupid:usl-shared:jar:2.5.0-SNAPSHOT:compile
[INFO] | | +- org.apache.servicemix.bundles:org.apache.servicemix.bundles.xmlbeans:jar:2.5.0_1:compile
[INFO] | | +- org.apache.servicemix.bundles:org.apache.servicemix.bundles.xstream:jar:1.4.9_1:compile
[INFO] | | | +- xmlpull:xmlpull:jar:1.1.3.1:compile
[INFO] | | | \- xpp3:xpp3_min:jar:1.1.4c:compile
[INFO] | | +- org.apache.servicemix.bundles:org.apache.servicemix.bundles.xmlpull:jar:1.1.3.1_2:compile
[INFO] | | +- org.apache.servicemix.bundles:org.apache.servicemix.bundles.javax.mail:jar:1.4.1_5:compile
[INFO] | | +- org.apache.servicemix.bundles:org.apache.servicemix.bundles.commons-httpclient:jar:3.1_7:compile
[INFO] | | +- org.apache.servicemix.bundles:org.apache.servicemix.bundles.commons-codec:jar:1.3_5:compile
[INFO] | | +- org.apache.servicemix.bundles:org.apache.servicemix.bundles.commons-io:jar:1.4_3:compile
[INFO] | | +- javax.ejb:javax.ejb-api:jar:3.2:compile
[INFO] | | +- javax.jms:javax.jms-api:jar:2.0:compile
[INFO] | | +- mygroupid.csi:csi88:jar:88.0:compile
[INFO] | | +- mygroupid.csi:csi213:jar:213.0:compile
[INFO] | | +- javax.xml.rpc:com.springsource.javax.xml.rpc:jar:1.1.0.v20110517:compile
[INFO] | | +- javax.transaction:javax.transaction-api:jar:1.2:compile
[INFO] | | +- javax.interceptor:javax.interceptor-api:jar:1.2:compile
[INFO] | | \- org.apache.servicemix.bundles:org.apache.servicemix.bundles.javax-inject:jar:1_2:compile
[INFO] | +- mygroupid:usl-base:jar:2.5.0-SNAPSHOT:compile
[INFO] | | +- org.apache.xmlbeans:xmlbeans:jar:2.4.0:compile
[INFO] | | | \- stax:stax-api:jar:1.0.1:compile
[INFO] | | +- org.apache.axis:axis:jar:1.4:compile
[INFO] | | +- org.apache.neethi:neethi:jar:3.0.0:compile
[INFO] | | | \- wsdl4j:wsdl4j:jar:1.6.2:compile
[INFO] | | +- org.apache.woden:woden-api:jar:1.0M9:compile
[INFO] | | +- org.apache.commons:com.springsource.org.apache.commons.net:jar:1.4.1:compile
[INFO] | | +- org.apache.woden:woden-impl-dom:jar:1.0M9:compile
[INFO] | | +- org.apache.woden:woden-impl-commons:jar:1.0M9:compile
[INFO] | | +- org.apache.ws.commons.schema:XmlSchema:jar:1.4.7:compile
[INFO] | | +- org.apache.httpcomponents:httpcore-osgi:jar:4.4:compile
[INFO] | | | +- org.apache.httpcomponents:httpcore:jar:4.4:compile
[INFO] | | | \- org.apache.httpcomponents:httpcore-nio:jar:4.4:compile
[INFO] | | +- org.apache.httpcomponents:httpclient-osgi:jar:4.5.2:compile
[INFO] | | | +- org.apache.httpcomponents:httpclient:jar:4.5.2:compile
[INFO] | | | +- commons-codec:commons-codec:jar:1.10:compile
[INFO] | | | +- org.apache.httpcomponents:httpmime:jar:4.5.2:compile
[INFO] | | | +- org.apache.httpcomponents:httpclient-cache:jar:4.5.2:compile
[INFO] | | | \- org.apache.httpcomponents:fluent-hc:jar:4.5.2:compile
[INFO] | | +- org.apache.servicemix.bundles:org.apache.servicemix.bundles.wsdl4j:jar:1.6.2_5:compile
[INFO] | | +- org.apache.ws.commons.axiom:axiom-api:jar:1.2.5:compile
[INFO] | | | +- javax.mail:mail:jar:1.4:compile
[INFO] | | | | \- javax.activation:activation:jar:1.1:compile
[INFO] | | | \- xml-apis:xml-apis:jar:1.4.01:test
[INFO] | | +- org.apache.axiom:com.springsource.org.apache.axiom:jar:1.2.5:compile
[INFO] | | +- org.apache.servicemix.bundles:org.apache.servicemix.bundles.axiom-impl:jar:1.2.13_1:compile
[INFO] | | | +- org.apache.james:apache-mime4j-core:jar:0.7.2:compile
[INFO] | | | +- org.apache.geronimo.specs:geronimo-activation_1.1_spec:jar:1.1:compile
[INFO] | | | +- org.apache.geronimo.specs:geronimo-javamail_1.4_spec:jar:1.7.1:compile
[INFO] | | | +- org.codehaus.woodstox:wstx-asl:jar:3.2.9:compile
[INFO] | | | \- org.apache.geronimo.specs:geronimo-stax-api_1.0_spec:jar:1.0.1:compile
[INFO] | | +- org.apache.axis:com.springsource.org.apache.axis:jar:1.4.0:compile
[INFO] | | | \- org.apache.commons:com.springsource.org.apache.commons.httpclient:jar:3.1.0:compile
[INFO] | | | \- org.apache.commons:com.springsource.org.apache.commons.codec:jar:1.3.0:compile
[INFO] | | +- org.apache.commons:com.springsource.org.apache.commons.discovery:jar:0.4.0:compile
[INFO] | | +- org.apache.commons:com.springsource.org.apache.commons.logging:jar:1.1.1:compile
[INFO] | | +- javax.jms:com.springsource.javax.jms:jar:1.1.0:compile
[INFO] | | +- javax.servlet:servlet-api:jar:2.5:compile
[INFO] | | \- javax.ws.rs:javax.ws.rs-api:jar:2.0:compile
[INFO] | +- mygroupid.csi:csi-app:jar:1.0:compile
[INFO] | +- mygroupid.csi:csi97:jar:97.0:compile
[INFO] | +- mygroupid.csi:csi104:jar:104.0:compile
[INFO] | +- mygroupid.csi:csi106:jar:106.0:compile
[INFO] | +- mygroupid.csi:csi112:jar:112.1:compile
[INFO] | +- mygroupid.csi:csi109:jar:109.0:compile
[INFO] | +- mygroupid.csi:csi217:jar:217.0:compile
[INFO] | +- mygroupid.csi:csi116:jar:116:compile
[INFO] | +- mygroupid.csi.icas:csi116:jar:200.0:compile
[INFO] | +- mygroupid.csi.unifiedservices:csi116:jar:212.0:compile
[INFO] | +- mygroupid.csi.paom:csi112:jar:205.0:compile
[INFO] | +- mygroupid.csi.oneviewaddresslocationsystem:csi116:jar:203.0:compile
[INFO] | +- mygroupid.csi.orderandsubscriptionmanagementmobility:csi116:jar:206.0:compile
[INFO] | +- mygroupid.csi:csi121:jar:121:compile
[INFO] | \- mygroupid.csi.unifiedservices:csi121:jar:216.0:compile
[INFO] +- mygroupid:usl-fraudcheck-api:jar:2.5.0-SNAPSHOT:compile
[INFO] | \- mygroupid:usl-metrics:jar:2.5.0-SNAPSHOT:compile
[INFO] | +- mygroupid.oracle:ojdbc6:jar:11.2.0.3.0:compile
[INFO] | +- mygroupid.oracle:oracle.jdbc.OracleDriver:jar:12.1.0.1:compile
[INFO] | +- com.zaxxer:HikariCP:jar:2.6.1:compile
[INFO] | \- org.javassist:javassist:jar:3.18.2-GA:compile
[INFO] +- mygroupid.xmlsoap:xmlsoap:jar:11.0:compile
[INFO] +- mygroupid:usl-csi-jaxb-base:test-jar:tests:2.5.0-SNAPSHOT:test
[INFO] +- commons-beanutils:commons-beanutils:jar:1.9.3:compile
[INFO] +- org.hibernate:hibernate-validator:jar:5.4.1.Final:compile
[INFO] | +- javax.validation:validation-api:jar:1.1.0.Final:compile
[INFO] | +- org.jboss.logging:jboss-logging:jar:3.3.0.Final:compile
[INFO] | \- com.fasterxml:classmate:jar:1.3.1:compile
[INFO] +- org.hibernate:hibernate-validator-annotation-processor:jar:5.4.1.Final:compile
[INFO] +- org.glassfish:javax.el:jar:3.0.1-b08:compile
[INFO] +- log4j:log4j:jar:1.2.16:provided
[INFO] +- org.codehaus.mojo:cobertura-maven-plugin:jar:2.6:compile
[INFO] | +- net.sourceforge.cobertura:cobertura:jar:2.0.3:compile
[INFO] | | +- org.ow2.asm:asm:jar:4.1:compile
[INFO] | | +- org.ow2.asm:asm-tree:jar:4.1:compile
[INFO] | | +- org.ow2.asm:asm-commons:jar:4.1:compile
[INFO] | | +- org.ow2.asm:asm-util:jar:4.1:compile
[INFO] | | +- org.ow2.asm:asm-analysis:jar:4.1:compile
[INFO] | | +- oro:oro:jar:2.0.8:compile
[INFO] | | +- jaxen:jaxen:jar:1.1-beta-8:compile
[INFO] | | | +- dom4j:dom4j:jar:1.6.1:compile
[INFO] | | | +- jdom:jdom:jar:1.0:compile
[INFO] | | | +- xerces:xmlParserAPIs:jar:2.6.2:compile
[INFO] | | | +- xerces:xercesImpl:jar:2.11.0:test
[INFO] | | | \- xom:xom:jar:1.0b3:compile
[INFO] | | | +- com.ibm.icu:icu4j:jar:2.6.1:compile
[INFO] | | | +- xalan:xalan:jar:2.7.2:compile
[INFO] | | | | \- xalan:serializer:jar:2.7.2:compile
[INFO] | | | \- org.ccil.cowan.tagsoup:tagsoup:jar:0.9.7:compile
[INFO] | | +- org.apache.ant:ant:jar:1.8.3:compile
[INFO] | | | \- org.apache.ant:ant-launcher:jar:1.8.3:compile
[INFO] | | +- org.mortbay.jetty:servlet-api-2.5:jar:6.1.14:compile
[INFO] | | +- org.mortbay.jetty:jetty:jar:6.1.14:compile
[INFO] | | +- org.mortbay.jetty:jetty-util:jar:6.1.14:compile
[INFO] | | \- com.sun:tools:jar:0:system
[INFO] | +- net.sourceforge.cobertura:cobertura-runtime:pom:2.0.3:compile
[INFO] | +- urbanophile:java-getopt:jar:1.0.9:compile
[INFO] | +- org.apache.maven:maven-core:jar:2.0.8:compile
[INFO] | | +- org.apache.maven:maven-settings:jar:2.0.8:compile
[INFO] | | +- org.apache.maven.wagon:wagon-file:jar:1.0-beta-2:runtime
[INFO] | | +- org.apache.maven:maven-plugin-parameter-documenter:jar:2.0.8:compile
[INFO] | | +- org.apache.maven.wagon:wagon-http-lightweight:jar:1.0-beta-2:runtime
[INFO] | | | \- org.apache.maven.wagon:wagon-http-shared:jar:1.0-beta-2:runtime
[INFO] | | | \- jtidy:jtidy:jar:4aug2000r7-dev:runtime
[INFO] | | +- org.apache.maven:maven-profile:jar:2.0.8:compile
[INFO] | | +- org.apache.maven:maven-model:jar:2.0.8:compile
[INFO] | | +- org.apache.maven.wagon:wagon-provider-api:jar:1.0-beta-2:compile
[INFO] | | +- org.codehaus.plexus:plexus-container-default:jar:1.0-alpha-9-stable-1:compile
[INFO] | | +- org.apache.maven:maven-repository-metadata:jar:2.0.8:compile
[INFO] | | +- org.apache.maven:maven-error-diagnostics:jar:2.0.8:compile
[INFO] | | +- commons-cli:commons-cli:jar:1.0:compile
[INFO] | | +- org.apache.maven.wagon:wagon-ssh-external:jar:1.0-beta-2:runtime
[INFO] | | | \- org.apache.maven.wagon:wagon-ssh-common:jar:1.0-beta-2:runtime
[INFO] | | +- org.apache.maven:maven-plugin-descriptor:jar:2.0.8:compile
[INFO] | | +- org.codehaus.plexus:plexus-interactivity-api:jar:1.0-alpha-4:compile
[INFO] | | +- org.apache.maven:maven-artifact-manager:jar:2.0.8:compile
[INFO] | | +- org.apache.maven:maven-monitor:jar:2.0.8:compile
[INFO] | | +- org.apache.maven.wagon:wagon-ssh:jar:1.0-beta-2:runtime
[INFO] | | | \- com.jcraft:jsch:jar:0.1.27:runtime
[INFO] | | \- classworlds:classworlds:jar:1.1:compile
[INFO] | +- org.apache.maven:maven-artifact:jar:2.0.8:compile
[INFO] | +- org.apache.maven:maven-plugin-api:jar:2.0.8:compile
[INFO] | +- org.apache.maven.reporting:maven-reporting-api:jar:2.0.8:compile
[INFO] | | \- org.apache.maven.doxia:doxia-sink-api:jar:1.0-alpha-9:compile
[INFO] | +- org.apache.maven:maven-project:jar:2.0.8:compile
[INFO] | | \- org.apache.maven:maven-plugin-registry:jar:2.0.8:compile
[INFO] | +- org.apache.maven.reporting:maven-reporting-impl:jar:2.0.4.2:compile
[INFO] | | +- commons-validator:commons-validator:jar:1.2.0:compile
[INFO] | | | \- commons-digester:commons-digester:jar:1.6:compile
[INFO] | | +- org.apache.maven.doxia:doxia-core:jar:1.0:compile
[INFO] | | \- org.apache.maven.doxia:doxia-site-renderer:jar:1.0:compile
[INFO] | | +- org.codehaus.plexus:plexus-i18n:jar:1.0-beta-7:compile
[INFO] | | +- org.codehaus.plexus:plexus-velocity:jar:1.1.7:compile
[INFO] | | +- org.apache.velocity:velocity:jar:1.5:compile
[INFO] | | +- org.apache.maven.doxia:doxia-decoration-model:jar:1.0:compile
[INFO] | | +- org.apache.maven.doxia:doxia-module-apt:jar:1.0:compile
[INFO] | | +- org.apache.maven.doxia:doxia-module-fml:jar:1.0:compile
[INFO] | | +- org.apache.maven.doxia:doxia-module-xdoc:jar:1.0:compile
[INFO] | | \- org.apache.maven.doxia:doxia-module-xhtml:jar:1.0:compile
[INFO] | +- org.codehaus.plexus:plexus-utils:jar:2.0.2:compile
[INFO] | \- org.apache.maven.shared:maven-invoker:jar:2.0.11:compile
[INFO] +- org.osgi:org.osgi.core:jar:5.0.0:provided
[INFO] +- org.osgi:org.osgi.compendium:jar:5.0.0:provided
[INFO] +- junit:junit:jar:4.11:test
[INFO] | \- org.hamcrest:hamcrest-core:jar:1.3:test
[INFO] +- org.mockito:mockito-core:jar:1.10.19:test
[INFO] | \- org.objenesis:objenesis:jar:2.1:test
[INFO] +- org.powermock:powermock-module-junit4:jar:1.6.6:test
[INFO] | \- org.powermock:powermock-module-junit4-common:jar:1.6.6:test
[INFO] | +- org.powermock:powermock-core:jar:1.6.6:test
[INFO] | \- org.powermock:powermock-reflect:jar:1.6.6:test
[INFO] +- org.powermock:powermock-api-mockito:jar:1.6.6:test
[INFO] | \- org.powermock:powermock-api-mockito-common:jar:1.6.6:test
[INFO] | \- org.powermock:powermock-api-support:jar:1.6.6:test
[INFO] +- org.slf4j:slf4j-api:jar:1.7.21:provided
[INFO] +- org.apache.aries.blueprint:org.apache.aries.blueprint.annotation.api:jar:1.0.0:provided
[INFO] +- org.ops4j.pax.exam:pax-exam-junit4:jar:4.9.1:test
[INFO] | +- org.ops4j.pax.exam:pax-exam-spi:jar:4.9.1:test
[INFO] | | \- org.ops4j.pax.tinybundles:tinybundles:jar:2.1.1:test
[INFO] | | \- biz.aQute.bnd:bndlib:jar:2.4.0:test
[INFO] | \- org.ops4j.base:ops4j-base-lang:jar:1.5.0:test
[INFO] +- org.ops4j.pax.exam:pax-exam-container-karaf:jar:4.9.1:test
[INFO] | +- org.ops4j.pax.exam:pax-exam-container-remote:jar:4.9.1:test
[INFO] | | +- org.ops4j.pax.exam:pax-exam-container-rbc-client:jar:4.9.1:test
[INFO] | | | \- org.ops4j.pax.exam:pax-exam-container-rbc:jar:4.9.1:test
[INFO] | | +- org.ops4j.pax.swissbox:pax-swissbox-core:jar:1.8.2:test
[INFO] | | | \- org.ops4j.pax.swissbox:pax-swissbox-lifecycle:jar:1.8.2:test
[INFO] | | \- org.ops4j.base:ops4j-base-net:jar:1.5.0:test
[INFO] | +- org.apache.commons:commons-compress:jar:1.4.1:test
[INFO] | | \- org.tukaani:xz:jar:1.0:test
[INFO] | +- org.ops4j.pax.swissbox:pax-swissbox-framework:jar:1.8.2:test
[INFO] | | +- org.ops4j.pax.swissbox:pax-swissbox-tracker:jar:1.8.2:test
[INFO] | | +- org.ops4j.base:ops4j-base-exec:jar:1.5.0:test
[INFO] | | +- org.ops4j.base:ops4j-base-io:jar:1.5.0:test
[INFO] | | \- org.ops4j.base:ops4j-base-monitors:jar:1.5.0:test
[INFO] | \- org.ops4j.base:ops4j-base-spi:jar:1.5.0:test
[INFO] +- org.apache.karaf:apache-karaf:zip:4.0.7:compile
[INFO] | +- org.apache.karaf.features:framework:kar:4.0.7:compile
[INFO] | | +- org.apache.karaf.features:base:jar:4.0.7:runtime
[INFO] | | +- org.apache.karaf:org.apache.karaf.main:jar:4.0.7:runtime
[INFO] | | | +- org.apache.karaf:org.apache.karaf.util:jar:4.0.7:runtime
[INFO] | | | | \- org.apache.felix:org.apache.felix.utils:jar:1.8.2:runtime
[INFO] | | | +- net.java.dev.jna:jna:jar:4.2.2:runtime
[INFO] | | | \- net.java.dev.jna:jna-platform:jar:4.2.2:runtime
[INFO] | | +- org.apache.karaf:org.apache.karaf.exception:jar:4.0.7:runtime
[INFO] | | +- org.apache.karaf:org.apache.karaf.client:jar:4.0.7:runtime
[INFO] | | | \- org.apache.sshd:sshd-core:jar:0.14.0:runtime
[INFO] | | +- org.apache.karaf.jaas:org.apache.karaf.jaas.boot:jar:4.0.7:runtime
[INFO] | | +- org.apache.karaf.diagnostic:org.apache.karaf.diagnostic.boot:jar:4.0.7:runtime
[INFO] | | +- org.eclipse.tycho:org.eclipse.osgi:jar:3.10.101.v20150820-1432:runtime
[INFO] | | +- org.apache.felix:org.apache.felix.framework:jar:5.4.0:runtime
[INFO] | | +- jline:jline:jar:2.14.2:compile
[INFO] | | +- org.jledit:core:jar:0.2.1:compile
[INFO] | | +- org.ops4j.pax.logging:pax-logging-api:jar:1.8.5:compile
[INFO] | | +- org.ops4j.pax.logging:pax-logging-service:jar:1.8.5:compile
[INFO] | | +- org.ops4j.pax.url:pax-url-aether:jar:2.4.7:compile
[INFO] | | \- org.apache.karaf.features:org.apache.karaf.features.core:jar:4.0.7:compile
[INFO] | +- org.apache.karaf.features:framework:xml:features:4.0.7:runtime
[INFO] | +- org.apache.karaf.features:standard:xml:features:4.0.7:compile
[INFO] | +- org.apache.karaf.features:spring:xml:features:4.0.7:runtime
[INFO] | \- org.apache.karaf.features:enterprise:xml:features:4.0.7:runtime
[INFO] +- org.ops4j.pax.exam:pax-exam:jar:4.9.1:test
[INFO] | +- org.ops4j.base:ops4j-base-store:jar:1.5.0:test
[INFO] | \- org.ops4j.base:ops4j-base-util-property:jar:1.5.0:test
[INFO] +- org.apache.camel:camel-core:jar:2.17.0:provided
[INFO] | +- com.sun.xml.bind:jaxb-core:jar:2.2.11:provided
[INFO] | \- com.sun.xml.bind:jaxb-impl:jar:2.2.11:provided
[INFO] +- org.apache.camel:camel-blueprint:jar:2.17.0:provided
[INFO] | +- org.apache.camel:camel-core-xml:jar:2.17.0:provided
[INFO] | \- org.apache.camel:camel-core-osgi:jar:2.17.0:provided
[INFO] +- org.apache.camel:camel-jms:jar:2.17.0:provided
[INFO] | +- org.apache.camel:camel-spring:jar:2.17.0:provided
[INFO] | | +- org.springframework:spring-core:jar:4.2.5.RELEASE:provided
[INFO] | | +- org.springframework:spring-aop:jar:4.2.5.RELEASE:provided
[INFO] | | | \- aopalliance:aopalliance:jar:1.0:provided
[INFO] | | \- org.springframework:spring-expression:jar:4.2.5.RELEASE:provided
[INFO] | +- org.springframework:spring-jms:jar:4.2.5.RELEASE:provided
[INFO] | | \- org.springframework:spring-messaging:jar:4.2.5.RELEASE:provided
[INFO] | +- org.springframework:spring-context:jar:4.2.5.RELEASE:provided
[INFO] | +- org.springframework:spring-tx:jar:4.2.5.RELEASE:provided
[INFO] | \- org.springframework:spring-beans:jar:4.2.5.RELEASE:provided
[INFO] +- org.apache.camel:camel-jaxb:jar:2.17.0:provided
[INFO] +- org.apache.camel:camel-test:jar:2.17.0:test
[INFO] +- commons-logging:commons-logging:jar:1.2:provided
[INFO] +- commons-lang:commons-lang:jar:2.6:provided
[INFO] +- commons-io:commons-io:jar:2.4:provided
[INFO] +- org.apache.camel:camel-test-blueprint:jar:2.13.0:test
[INFO] | +- org.apache.aries.blueprint:org.apache.aries.blueprint:jar:1.1.0:test
[INFO] | +- org.apache.aries:org.apache.aries.util:jar:1.1.0:test
[INFO] | +- org.apache.aries.proxy:org.apache.aries.proxy.impl:jar:1.0.1:test
[INFO] | +- org.apache.aries.proxy:org.apache.aries.proxy.api:jar:1.0.0:test
[INFO] | +- com.googlecode.pojosr:de.kalpatec.pojosr.framework:jar:0.2.1:test
[INFO] | +- org.ops4j.pax.swissbox:pax-swissbox-tinybundles:jar:1.3.1:test
[INFO] | | \- org.ops4j.pax.swissbox:pax-swissbox-bnd:jar:1.3.1:test
[INFO] | | \- biz.aQute:bndlib:jar:0.0.357:test
[INFO] | +- org.apache.felix:org.apache.felix.configadmin:jar:1.4.0:compile
[INFO] | \- org.apache.felix:org.apache.felix.fileinstall:jar:3.2.6:compile
[INFO] +- org.apache.camel:camel-jackson:jar:2.17.0:provided
[INFO] | \- com.fasterxml.jackson.module:jackson-module-jaxb-annotations:jar:2.7.2:provided
[INFO] +- org.apache.camel:camel-jsonpath:jar:2.17.0:provided
[INFO] +- org.apache.camel:camel-jolt:jar:2.17.0:provided
[INFO] +- org.apache.camel:camel-quartz2:jar:2.17.0:provided
[INFO] | +- org.quartz-scheduler:quartz:jar:2.2.2:provided
[INFO] | | \- c3p0:c3p0:jar:0.9.1.1:provided
[INFO] | \- com.mchange:c3p0:jar:0.9.5.2:provided
[INFO] | \- com.mchange:mchange-commons-java:jar:0.2.11:provided
[INFO] +- org.apache.camel:camel-hazelcast:jar:2.17.0:provided
[INFO] | +- com.hazelcast:hazelcast:jar:3.6.2:provided
[INFO] | \- com.hazelcast:hazelcast-client:jar:3.6.2:provided
[INFO] +- com.jayway.jsonpath:json-path:jar:2.0.0:provided
[INFO] +- com.fasterxml.jackson.core:jackson-databind:jar:2.8.3:provided
[INFO] +- com.fasterxml.jackson.core:jackson-core:jar:2.8.3:provided
[INFO] +- com.fasterxml.jackson.core:jackson-annotations:jar:2.8.3:provided
[INFO] +- com.bazaarvoice.jolt:jolt-core:jar:0.0.16:provided
[INFO] | \- javax.inject:javax.inject:jar:1:provided
[INFO] +- com.bazaarvoice.jolt:json-utils:jar:0.0.16:provided
[INFO] +- net.minidev:json-smart:jar:2.1.1:provided
[INFO] +- net.minidev:asm:jar:1.0.2:provided
[INFO] | \- asm:asm:jar:3.3.1:provided
[INFO] +- com.google.code.gson:gson:jar:2.8.0:provided
[INFO] +- commons-collections:commons-collections:jar:3.2.1:compile
[INFO] +- org.apache.maven.surefire:surefire-junit4:jar:2.19.1:test
[INFO] | \- org.apache.maven.surefire:surefire-api:jar:2.19.1:test
[INFO] +- org.apache.cxf:cxf-core:jar:3.1.8:provided
[INFO] | +- org.codehaus.woodstox:woodstox-core-asl:jar:4.4.1:compile
[INFO] | | \- org.codehaus.woodstox:stax2-api:jar:3.1.4:compile
[INFO] | \- org.apache.ws.xmlschema:xmlschema-core:jar:2.2.1:compile
[INFO] +- org.apache.cxf:cxf-rt-rs-client:jar:3.1.8:provided
[INFO] | +- org.apache.cxf:cxf-rt-transports-http:jar:3.1.8:provided
[INFO] | \- org.apache.cxf:cxf-rt-frontend-jaxrs:jar:3.1.8:provided
[INFO] | \- javax.annotation:javax.annotation-api:jar:1.2:provided
[INFO] +- org.jacoco:org.jacoco.agent:jar:runtime:0.7.8:test
[INFO] \- org.eclipse.jdt:org.eclipse.jdt.annotation:jar:2.1.0:compile
The following is an excerpt from the output of "mvn install" in the module, when it's running the unit test:
Running package.usl.fraudcheck.impl.InquireCPNIContactInformationProcessorTest
[org.jboss.logging] : Logging Provider: org.jboss.logging.Log4j2LoggerProvider Ignored FQCN: org.jboss.logging.Logger
[org.hibernate.validator.internal.util.Version] : HV000001: Hibernate Validator 5.4.1.Final Ignored FQCN: org.hibernate.validator.internal.util.logging.Log_$logger
[org.hibernate.validator.internal.engine.resolver.DefaultTraversableResolver] : Cannot find javax.persistence.Persistence on classpath. Assuming non JPA 2 environment. All properties will per default be traversable. Ignored FQCN: org.jboss.logging.DelegatingBasicLogger
[org.hibernate.validator.internal.xml.ValidationXmlParser] : Trying to load META-INF/validation.xml for XML based Validator configuration. Ignored FQCN: org.jboss.logging.DelegatingBasicLogger
[org.hibernate.validator.internal.xml.ResourceLoaderHelper] : Trying to load META-INF/validation.xml via TCCL Ignored FQCN: org.jboss.logging.DelegatingBasicLogger
[org.hibernate.validator.internal.xml.ResourceLoaderHelper] : Trying to load META-INF/validation.xml via Hibernate Validator's class loader Ignored FQCN: org.jboss.logging.DelegatingBasicLogger
[org.hibernate.validator.internal.xml.ValidationXmlParser] : No META-INF/validation.xml found. Using annotation based configuration only. Ignored FQCN: org.jboss.logging.DelegatingBasicLogger
Tests run: 3, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.67 sec <<< FAILURE! - in package.usl.fraudcheck.impl.InquireCPNIContactInformationProcessorTest
testValidate(package.usl.fraudcheck.impl.InquireCPNIContactInformationProcessorTest) Time elapsed: 0.219 sec <<< ERROR!
javax.validation.ValidationException: HV000183: Unable to initialize 'javax.el.ExpressionFactory'. Check that you have the EL dependencies on the classpath, or use ParameterMessageInterpolator instead
at package.usl.fraudcheck.impl.InquireCPNIContactInformationProcessorTest.testValidate(InquireCPNIContactInformationProcessorTest.java:23)
Caused by: java.lang.NoClassDefFoundError: javax/el/ExpressionFactory
at package.usl.fraudcheck.impl.InquireCPNIContactInformationProcessorTest.testValidate(InquireCPNIContactInformationProcessorTest.java:23)
I have had the same error even after adding a dependency to org.glassfish:javax.el:3.0.1-b08. The issue turned out to be transitive dependencies being pulled in that include javax.el.ExpressionFactory but have no implementation.
The following command will output all the dependencies that include javax.el.ExpressionFactory
for i in $(mvn dependency:build-classpath | grep '.m2' | tr ':' ' '); do
jar -tvf $i | grep 'javax/el/ExpressionFactory' && echo -e "\t$i"
done 2> /dev/null
I then used <exclusions> in my pom.xml to remove the jars that do not match org.glassfish:javax.el:3.0.1-b08.
The exclusions may end up removing code in the excluded Jars that is needed as well. In my case I had to find a replacement jar that provided an embedded Jetty Server.
So, you really need only one version of the el jar. And it should be:
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.el</artifactId>
<version>3.0.1-b08</version>
</dependency>
As for the other el jars, you need to exclude them from your dependencies. The dependency tree should help you as you are able to see where they come from.
Just use an exclusion on the dependencies transitively bringing the old el jars and be sure you don't reference it explicitly in your poms and it should work.
The other solution, as mentioned by the error message, is to use a message interpolator not using EL but I wouldn't recommend it as some built-in constraints use EL in their messages and you will probably need it for your own constraints.
I've been trying to figure out MetricRegistry details for one of my project based out on dropwizard:1.1.0
A minor confusion here is that I see the version used for localhost:8181/metrics (adminConnector) by my service is 3.1.3 which is not the latest and the one included in dropwizard-core (Note : +- io.dropwizard.metrics:metrics-core:jar:3.2.2 in the dependency:tree below)
Relative POM dependencies used are :
<dependency>
<groupId>io.dropwizard</groupId>
<artifactId>dropwizard-core</artifactId>
<version>1.1.0</version>
</dependency>
<dependency>
<groupId>io.federecio</groupId>
<artifactId>dropwizard-swagger</artifactId>
<version>0.7.0</version>
</dependency>
mvn dependency:tree for the projects is as follows :
+- io.dropwizard:dropwizard-core:jar:1.1.0:compile
[INFO] | +- io.dropwizard:dropwizard-util:jar:1.1.0:compile
[INFO] | | +- com.fasterxml.jackson.core:jackson-annotations:jar:2.8.0:compile
[INFO] | | +- com.google.code.findbugs:jsr305:jar:3.0.1:compile
[INFO] | | \- joda-time:joda-time:jar:2.9.7:compile
[INFO] | +- io.dropwizard:dropwizard-jackson:jar:1.1.0:compile
[INFO] | | +- com.fasterxml.jackson.core:jackson-core:jar:2.8.7:compile
[INFO] | | +- com.fasterxml.jackson.core:jackson-databind:jar:2.8.7:compile
[INFO] | | +- com.fasterxml.jackson.datatype:jackson-datatype-guava:jar:2.8.7:compile
[INFO] | | +- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.8.7:compile
[INFO] | | +- com.fasterxml.jackson.datatype:jackson-datatype-jdk8:jar:2.8.7:compile
[INFO] | | +- com.fasterxml.jackson.module:jackson-module-parameter-names:jar:2.8.7:compile
[INFO] | | +- com.fasterxml.jackson.module:jackson-module-afterburner:jar:2.8.7:compile
[INFO] | | +- com.fasterxml.jackson.datatype:jackson-datatype-joda:jar:2.8.7:compile
[INFO] | | +- org.slf4j:slf4j-api:jar:1.7.24:compile
[INFO] | | \- ch.qos.logback:logback-classic:jar:1.2.1:compile
[INFO] | +- io.dropwizard:dropwizard-validation:jar:1.1.0:compile
[INFO] | | +- org.hibernate:hibernate-validator:jar:5.3.4.Final:compile
[INFO] | | | +- org.jboss.logging:jboss-logging:jar:3.3.0.Final:compile
[INFO] | | | \- com.fasterxml:classmate:jar:1.3.1:compile
[INFO] | | \- org.glassfish:javax.el:jar:3.0.0:compile
[INFO] | +- io.dropwizard:dropwizard-configuration:jar:1.1.0:compile
[INFO] | | \- com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:jar:2.8.7:compile
[INFO] | | \- org.yaml:snakeyaml:jar:1.17:compile
[INFO] | +- io.dropwizard:dropwizard-logging:jar:1.1.0:compile
[INFO] | | +- io.dropwizard.metrics:metrics-logback:jar:3.2.2:compile
[INFO] | | +- org.slf4j:jul-to-slf4j:jar:1.7.24:compile
[INFO] | | +- ch.qos.logback:logback-core:jar:1.2.1:compile
[INFO] | | +- org.slf4j:log4j-over-slf4j:jar:1.7.24:compile
[INFO] | | +- org.slf4j:jcl-over-slf4j:jar:1.7.24:compile
[INFO] | | \- org.eclipse.jetty:jetty-util:jar:9.4.2.v20170220:compile
[INFO] | +- io.dropwizard:dropwizard-metrics:jar:1.1.0:compile
[INFO] | +- io.dropwizard:dropwizard-jersey:jar:1.1.0:compile
[INFO] | | +- org.glassfish.jersey.core:jersey-server:jar:2.25.1:compile
[INFO] | | | +- org.glassfish.jersey.core:jersey-common:jar:2.25.1:compile
[INFO] | | | | +- org.glassfish.jersey.bundles.repackaged:jersey-guava:jar:2.25.1:compile
[INFO] | | | | \- org.glassfish.hk2:osgi-resource-locator:jar:1.0.1:compile
[INFO] | | | +- org.glassfish.jersey.core:jersey-client:jar:2.25.1:compile
[INFO] | | | +- org.glassfish.jersey.media:jersey-media-jaxb:jar:2.25.1:compile
[INFO] | | | +- javax.annotation:javax.annotation-api:jar:1.2:compile
[INFO] | | | +- org.glassfish.hk2:hk2-api:jar:2.5.0-b32:compile
[INFO] | | | | +- org.glassfish.hk2:hk2-utils:jar:2.5.0-b32:compile
[INFO] | | | | \- org.glassfish.hk2.external:aopalliance-repackaged:jar:2.5.0-b32:compile
[INFO] | | | +- org.glassfish.hk2.external:javax.inject:jar:2.5.0-b32:compile
[INFO] | | | \- org.glassfish.hk2:hk2-locator:jar:2.5.0-b32:compile
[INFO] | | | \- org.javassist:javassist:jar:3.20.0-GA:compile
[INFO] | | +- org.glassfish.jersey.ext:jersey-metainf-services:jar:2.25.1:compile
[INFO] | | +- org.glassfish.jersey.ext:jersey-bean-validation:jar:2.25.1:compile
[INFO] | | | +- javax.el:javax.el-api:jar:2.2.4:compile
[INFO] | | | \- org.glassfish.web:javax.el:jar:2.2.4:compile
[INFO] | | +- io.dropwizard.metrics:metrics-jersey2:jar:3.2.2:compile
[INFO] | | +- com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:jar:2.8.7:compile
[INFO] | | | +- com.fasterxml.jackson.jaxrs:jackson-jaxrs-base:jar:2.8.7:compile
[INFO] | | | \- com.fasterxml.jackson.module:jackson-module-jaxb-annotations:jar:2.8.7:compile
[INFO] | | +- org.glassfish.jersey.containers:jersey-container-servlet:jar:2.25.1:compile
[INFO] | | | \- org.glassfish.jersey.containers:jersey-container-servlet-core:jar:2.25.1:compile
[INFO] | | +- org.eclipse.jetty:jetty-server:jar:9.4.2.v20170220:compile
[INFO] | | | +- javax.servlet:javax.servlet-api:jar:3.1.0:compile
[INFO] | | | \- org.eclipse.jetty:jetty-io:jar:9.4.2.v20170220:compile
[INFO] | | +- org.eclipse.jetty:jetty-webapp:jar:9.4.2.v20170220:compile
[INFO] | | | \- org.eclipse.jetty:jetty-xml:jar:9.4.2.v20170220:compile
[INFO] | | \- org.eclipse.jetty:jetty-continuation:jar:9.4.2.v20170220:compile
[INFO] | +- io.dropwizard:dropwizard-servlets:jar:1.1.0:compile
[INFO] | | \- io.dropwizard.metrics:metrics-annotation:jar:3.2.2:compile
[INFO] | +- io.dropwizard:dropwizard-jetty:jar:1.1.0:compile
[INFO] | | +- io.dropwizard.metrics:metrics-jetty9:jar:3.2.2:compile
[INFO] | | +- org.eclipse.jetty:jetty-servlet:jar:9.4.2.v20170220:compile
[INFO] | | | \- org.eclipse.jetty:jetty-security:jar:9.4.2.v20170220:compile
[INFO] | | +- org.eclipse.jetty:jetty-servlets:jar:9.4.2.v20170220:compile
[INFO] | | \- org.eclipse.jetty:jetty-http:jar:9.4.2.v20170220:compile
[INFO] | +- io.dropwizard:dropwizard-lifecycle:jar:1.1.0:compile
[INFO] | +- io.dropwizard.metrics:metrics-core:jar:3.2.2:compile
[INFO] | +- io.dropwizard.metrics:metrics-jvm:jar:3.2.2:compile
[INFO] | +- io.dropwizard.metrics:metrics-servlets:jar:3.2.2:compile
[INFO] | | +- io.dropwizard.metrics:metrics-json:jar:3.2.2:compile
[INFO] | | \- com.papertrail:profiler:jar:1.0.2:compile
[INFO] | +- io.dropwizard.metrics:metrics-healthchecks:jar:3.2.2:compile
[INFO] | +- io.dropwizard:dropwizard-request-logging:jar:1.1.0:compile
[INFO] | | \- ch.qos.logback:logback-access:jar:1.2.1:compile
[INFO] | +- net.sourceforge.argparse4j:argparse4j:jar:0.7.0:compile
[INFO] | \- org.eclipse.jetty.toolchain.setuid:jetty-setuid-java:jar:1.0.3:compile
[INFO] +- io.federecio:dropwizard-swagger:jar:0.7.0:compile
[INFO] | +- io.dropwizard:dropwizard-assets:jar:0.8.0:compile
[INFO] | +- io.dropwizard:dropwizard-views:jar:0.8.0:compile
[INFO] | +- io.dropwizard:dropwizard-views-freemarker:jar:0.8.0:compile
[INFO] | | \- org.freemarker:freemarker:jar:2.3.21:compile
[INFO] | +- com.wordnik:swagger-jersey2-jaxrs:jar:1.5.1-M2:compile
[INFO] | | \- com.wordnik:swagger-jaxrs:jar:1.5.1-M2:compile
[INFO] | | +- com.fasterxml.jackson.dataformat:jackson-dataformat-xml:jar:2.4.2:compile
[INFO] | | | \- org.codehaus.woodstox:stax2-api:jar:3.1.4:compile
[INFO] | | +- com.wordnik:swagger-core:jar:1.5.1-M2:compile
[INFO] | | | \- com.wordnik:swagger-models:jar:1.5.1-M2:compile
[INFO] | | | \- com.wordnik:swagger-annotations:jar:1.5.1-M2:compile
[INFO] | | \- org.reflections:reflections:jar:0.9.9:compile
[INFO] | | \- com.google.code.findbugs:annotations:jar:2.0.1:compile
[INFO] | \- xml-apis:xml-apis:jar:1.4.01:compile
[INFO] +- com.google.inject:guice:jar:4.1.0:compile
[INFO] | +- javax.inject:javax.inject:jar:1:compile
[INFO] | +- aopalliance:aopalliance:jar:1.0:compile
[INFO] | \- com.google.guava:guava:jar:19.0:compile
[INFO] +- org.apache.httpcomponents:httpclient:jar:4.5.3:compile
[INFO] | +- org.apache.httpcomponents:httpcore:jar:4.4.6:compile
[INFO] | +- commons-logging:commons-logging:jar:1.2:compile
[INFO] | \- commons-codec:commons-codec:jar:1.9:compile
[INFO] +- javax.ws.rs:javax.ws.rs-api:jar:2.0.1:compile
[INFO] \- org.junit.jupiter:junit-jupiter-api:jar:5.0.0-M4:test
[INFO] +- org.opentest4j:opentest4j:jar:1.0.0-M2:test
[INFO] \- org.junit.platform:junit-platform-commons:jar:1.0.0-M4:test
Just wanted to know, how does Dropwizard configure the MetricRegistry?
Futher Details (if required) :-
I am using guice injection to bind the MetricRegistry in a module extending AbstractModule as
bind(MetricRegistry.class).toInstance(environment.metrics());
and in a service class calling this injector as
public static void main(String[] args) throws Exception {
new Service().run(args);
}
#Override
public void run(ServiceConfig config, Environment environment) throws Exception {
Injector injector = Guice.createInjector(new ExtendingModule(config, environment));
.... // not altering metrics here
}
DW simply creates a metric registry, no magic or nothing involved. See the Bootstrap class for that:
public Bootstrap(Application<T> application) {
this.application = application;
this.objectMapper = Jackson.newObjectMapper();
this.bundles = new ArrayList<>();
this.configuredBundles = new ArrayList<>();
this.commands = new ArrayList<>();
this.validatorFactory = Validators.newValidatorFactory();
this.metricRegistry = new MetricRegistry();
this.configurationSourceProvider = new FileConfigurationSourceProvider();
this.classLoader = Thread.currentThread().getContextClassLoader();
this.configurationFactoryFactory = new DefaultConfigurationFactoryFactory<>();
this.healthCheckRegistry = new HealthCheckRegistry();
}
in particular:
this.metricRegistry = new MetricRegistry();
That is pretty much it.
Forgot, they also register some standard modules:
/**
* Registers the JVM metrics to the metric registry and start to report
* the registry metrics via JMX.
*/
public void registerMetrics() {
if (metricsAreRegistered) {
return;
}
getMetricRegistry().register("jvm.attribute", new JvmAttributeGaugeSet());
getMetricRegistry().register("jvm.buffers", new BufferPoolMetricSet(ManagementFactory
.getPlatformMBeanServer()));
getMetricRegistry().register("jvm.classloader", new ClassLoadingGaugeSet());
getMetricRegistry().register("jvm.filedescriptor", new FileDescriptorRatioGauge());
getMetricRegistry().register("jvm.gc", new GarbageCollectorMetricSet());
getMetricRegistry().register("jvm.memory", new MemoryUsageGaugeSet());
getMetricRegistry().register("jvm.threads", new ThreadStatesGaugeSet());
JmxReporter.forRegistry(metricRegistry).build().start();
metricsAreRegistered = true;
}
The version is not tied to the Metric library version you are using, but to the MetricsModule registered with the ObjectMapper for serialisation. In my case, the class looks like that:
public class MetricsModule extends Module {
static final Version VERSION = new Version(3, 0, 0, "", "com.codahale.metrics", "metrics-json");
in the serialiser, the first line then does:
#Override
public void serialize(MetricRegistry registry,
JsonGenerator json,
SerializerProvider provider) throws IOException {
json.writeStartObject();
json.writeStringField("version", VERSION.toString());
This is where your version is from.
Admittedly, this is not very intuitive. I reckon that this is more of an internal versioning and it gets updated whenever the code in that particular serialising module is changing - but you'd have to ask the DW guys for the details on that. My Metrics are 3.1.2 or something similar and it prints 3.0.0 for me.
-- Artur