Programming

basic programming

Error When Running Integration Test and Swagger at the Same Time

Met this error today when trying to implement Swagger with Failsafe integration test, which runs well before implementing swagger to this microservice project.

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cachingOperationReader' defined in URL [jar:file:/C:/Users/edw/.m2/repository/io/springfox/springfox-spring-web/2.9.2/springfox-spring-web-2.9.2.jar!/springfox/documentation/spring/web/scanners/CachingOperationReader.class]: Bean instantiation via constructor failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [springfox.documentation.spring.web.scanners.CachingOperationReader]: Constructor threw exception; nested exception is java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkState(ZLjava/lang/String;J)V
    at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:304)
    at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:285)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1341)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1187)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515)
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
    at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:277)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1251)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1171)
    at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:857)
    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:760)
    ... 80 more
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [springfox.documentation.spring.web.scanners.CachingOperationReader]: Constructor threw exception; nested exception is java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkState(ZLjava/lang/String;J)V
    at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:184)
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:117)
    at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:300)
    ... 94 more
Caused by: java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkState(ZLjava/lang/String;J)V
    at com.google.common.cache.CacheBuilder.maximumSize(CacheBuilder.java:407)
    at springfox.documentation.spring.web.scanners.CachingOperationReader.<init>(CachingOperationReader.java:45)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
    at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:172)
    ... 96 more

As we can see on the end of Exception log, issue happen at Preconditions class,due to library conflicting. We can see this class is loaded by which library from our IDE, and remove conflicting library accordingly.

Next step is detecting those class are within which jarfiles and being a dependency to which library by using below command,

mvn dependency:tree

Which will result in below mvn output,

E:\Source>mvn dependency:tree
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for com.edw.dosomething:user:jar:0.0.1-SNAPSHOT
[WARNING] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: org.springframework.security:spring-security-test:jar -> duplicate declara
tion of version (?) @ line 84, column 21
[WARNING] The expression ${groupId} is deprecated. Please use ${project.groupId} instead.
[WARNING] The expression ${artifactId} is deprecated. Please use ${project.artifactId} instead.
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building user-audit-trail-service 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:3.1.1:tree (default-cli) @ user ---
[INFO] com.edw.dosomething:user:jar:0.0.1-SNAPSHOT
[INFO] +- org.springframework.boot:spring-boot-starter-actuator:jar:2.1.6.RELEASE:compile
[INFO] |  +- org.springframework.boot:spring-boot-starter:jar:2.1.6.RELEASE:compile
[INFO] |  |  +- org.springframework.boot:spring-boot:jar:2.1.6.RELEASE:compile
[INFO] |  |  +- org.springframework.boot:spring-boot-autoconfigure:jar:2.1.6.RELEASE:compile
[INFO] |  |  +- org.springframework.boot:spring-boot-starter-logging:jar:2.1.6.RELEASE: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.11.2:compile
[INFO] |  |  |  |  \- org.apache.logging.log4j:log4j-api:jar:2.11.2:compile
[INFO] |  |  |  \- org.slf4j:jul-to-slf4j:jar:1.7.26:compile
[INFO] |  |  +- javax.annotation:javax.annotation-api:jar:1.3.2:compile
[INFO] |  |  \- org.yaml:snakeyaml:jar:1.23:runtime
[INFO] |  \- org.springframework.boot:spring-boot-actuator-autoconfigure:jar:2.1.6.RELEASE:compile
[INFO] |     +- org.springframework.boot:spring-boot-actuator:jar:2.1.6.RELEASE:compile
[INFO] |     +- com.fasterxml.jackson.core:jackson-databind:jar:2.9.9:compile
[INFO] |     |  \- com.fasterxml.jackson.core:jackson-core:jar:2.9.9:compile
[INFO] |     +- org.springframework:spring-context:jar:5.1.8.RELEASE:compile
[INFO] |     \- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.9.9:compile
[INFO] +- org.springframework.boot:spring-boot-starter-data-jpa:jar:2.1.6.RELEASE:compile
[INFO] |  +- org.springframework.boot:spring-boot-starter-aop:jar:2.1.6.RELEASE:compile
[INFO] |  |  +- org.springframework:spring-aop:jar:5.1.8.RELEASE:compile
[INFO] |  |  \- org.aspectj:aspectjweaver:jar:1.9.4:compile
[INFO] |  +- org.springframework.boot:spring-boot-starter-jdbc:jar:2.1.6.RELEASE:compile
[INFO] |  |  +- com.zaxxer:HikariCP:jar:3.2.0:compile
[INFO] |  |  \- org.springframework:spring-jdbc:jar:5.1.8.RELEASE:compile
[INFO] |  +- javax.transaction:javax.transaction-api:jar:1.3:compile
[INFO] |  +- javax.xml.bind:jaxb-api:jar:2.3.1:compile
[INFO] |  +- org.hibernate:hibernate-core:jar:5.3.10.Final:compile
[INFO] |  |  +- org.jboss.logging:jboss-logging:jar:3.3.2.Final:compile
[INFO] |  |  +- javax.persistence:javax.persistence-api:jar:2.2:compile
[INFO] |  |  +- org.javassist:javassist:jar:3.23.2-GA:compile
[INFO] |  |  +- net.bytebuddy:byte-buddy:jar:1.9.13:compile
[INFO] |  |  +- antlr:antlr:jar:2.7.7:compile
[INFO] |  |  +- org.jboss:jandex:jar:2.0.5.Final:compile
[INFO] |  |  +- org.dom4j:dom4j:jar:2.1.1:compile
[INFO] |  |  \- org.hibernate.common:hibernate-commons-annotations:jar:5.0.4.Final:compile
[INFO] |  +- org.springframework.data:spring-data-jpa:jar:2.1.9.RELEASE:compile
[INFO] |  |  +- org.springframework.data:spring-data-commons:jar:2.1.9.RELEASE:compile
[INFO] |  |  +- org.springframework:spring-orm:jar:5.1.8.RELEASE:compile
[INFO] |  |  +- org.springframework:spring-tx:jar:5.1.8.RELEASE:compile
[INFO] |  |  \- org.springframework:spring-beans:jar:5.1.8.RELEASE:compile
[INFO] |  \- org.springframework:spring-aspects:jar:5.1.8.RELEASE:compile
[INFO] +- org.springframework.boot:spring-boot-starter-web:jar:2.1.6.RELEASE:compile
[INFO] |  +- org.springframework.boot:spring-boot-starter-json:jar:2.1.6.RELEASE:compile
[INFO] |  |  +- com.fasterxml.jackson.datatype:jackson-datatype-jdk8:jar:2.9.9:compile
[INFO] |  |  \- com.fasterxml.jackson.module:jackson-module-parameter-names:jar:2.9.9:compile
[INFO] |  +- org.hibernate.validator:hibernate-validator:jar:6.0.17.Final:compile
[INFO] |  |  \- javax.validation:validation-api:jar:2.0.1.Final:compile
[INFO] |  +- org.springframework:spring-web:jar:5.1.8.RELEASE:compile
[INFO] |  \- org.springframework:spring-webmvc:jar:5.1.8.RELEASE:compile
[INFO] |     \- org.springframework:spring-expression:jar:5.1.8.RELEASE:compile
[INFO] +- org.springframework.boot:spring-boot-starter-undertow:jar:2.1.6.RELEASE:compile
[INFO] |  +- io.undertow:undertow-core:jar:2.0.21.Final:compile
[INFO] |  |  +- org.jboss.xnio:xnio-api:jar:3.3.8.Final:compile
[INFO] |  |  \- org.jboss.xnio:xnio-nio:jar:3.3.8.Final:runtime
[INFO] |  +- io.undertow:undertow-servlet:jar:2.0.21.Final:compile
[INFO] |  |  \- org.jboss.spec.javax.annotation:jboss-annotations-api_1.2_spec:jar:1.0.2.Final:compile
[INFO] |  +- io.undertow:undertow-websockets-jsr:jar:2.0.21.Final:compile
[INFO] |  |  \- org.jboss.spec.javax.websocket:jboss-websocket-api_1.1_spec:jar:1.1.4.Final:compile
[INFO] |  +- javax.servlet:javax.servlet-api:jar:4.0.1:compile
[INFO] |  \- org.glassfish:javax.el:jar:3.0.0:compile
[INFO] +- org.projectlombok:lombok:jar:1.18.8:compile (optional)
[INFO] +- org.springframework.boot:spring-boot-starter-test:jar:2.1.6.RELEASE:test
[INFO] |  +- org.springframework.boot:spring-boot-test:jar:2.1.6.RELEASE:test
[INFO] |  +- org.springframework.boot:spring-boot-test-autoconfigure:jar:2.1.6.RELEASE: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] |  +- junit:junit:jar:4.12:test
[INFO] |  +- org.assertj:assertj-core:jar:3.11.1:test
[INFO] |  +- org.mockito:mockito-core:jar:2.23.4:test
[INFO] |  |  +- net.bytebuddy:byte-buddy-agent:jar:1.9.13:test
[INFO] |  |  \- org.objenesis:objenesis:jar:2.6:test
[INFO] |  +- org.hamcrest:hamcrest-core:jar:1.3:test
[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.1.8.RELEASE:compile
[INFO] |  |  \- org.springframework:spring-jcl:jar:5.1.8.RELEASE:compile
[INFO] |  +- org.springframework:spring-test:jar:5.1.8.RELEASE:test
[INFO] |  \- org.xmlunit:xmlunit-core:jar:2.6.2:test
[INFO] +- org.springframework.security:spring-security-test:jar:5.1.5.RELEASE:test
[INFO] |  +- org.springframework.security:spring-security-core:jar:5.1.5.RELEASE:test
[INFO] |  \- org.springframework.security:spring-security-web:jar:5.1.5.RELEASE:test
[INFO] +- com.h2database:h2:jar:1.4.199:runtime
[INFO] +- io.rest-assured:rest-assured:jar:3.1.1:test
[INFO] |  +- org.codehaus.groovy:groovy:jar:2.5.7:test
[INFO] |  +- org.codehaus.groovy:groovy-xml:jar:2.5.7:test
[INFO] |  +- org.apache.httpcomponents:httpclient:jar:4.5.9:test
[INFO] |  |  +- org.apache.httpcomponents:httpcore:jar:4.4.11:test
[INFO] |  |  \- commons-codec:commons-codec:jar:1.11:test
[INFO] |  +- org.apache.httpcomponents:httpmime:jar:4.5.9:test
[INFO] |  +- org.ccil.cowan.tagsoup:tagsoup:jar:1.2.1:test
[INFO] |  \- io.rest-assured:xml-path:jar:3.1.1:test
[INFO] |     \- org.apache.commons:commons-lang3:jar:3.8.1:test
[INFO] +- io.rest-assured:json-path:jar:3.1.1:test
[INFO] |  +- org.codehaus.groovy:groovy-json:jar:2.5.7:test
[INFO] |  \- io.rest-assured:rest-assured-common:jar:3.1.1:test
[INFO] +- io.micrometer:micrometer-core:jar:1.1.5:compile
[INFO] |  +- org.hdrhistogram:HdrHistogram:jar:2.1.9:compile
[INFO] |  \- org.latencyutils:LatencyUtils:jar:2.0.3:compile
[INFO] +- io.micrometer:micrometer-registry-prometheus:jar:1.1.5:compile
[INFO] |  \- io.prometheus:simpleclient_common:jar:0.5.0:compile
[INFO] |     \- io.prometheus:simpleclient:jar:0.5.0:compile
[INFO] +- javax.activation:javax.activation-api:jar:1.2.0:compile
[INFO] +- org.apache.maven.plugins:maven-failsafe-plugin:jar:3.0.0-M1:test
[INFO] |  \- org.apache.maven.surefire:maven-surefire-common:jar:3.0.0-M1:test
[INFO] |     +- org.apache.maven.surefire:surefire-api:jar:3.0.0-M1:test
[INFO] |     |  \- org.apache.maven.surefire:surefire-logger-api:jar:3.0.0-M1:test
[INFO] |     +- org.apache.maven.surefire:surefire-booter:jar:3.0.0-M1:test
[INFO] |     +- org.apache.maven:maven-toolchain:jar:3.0-alpha-2:test
[INFO] |     |  +- org.apache.maven:maven-core:jar:3.0-alpha-2:test
[INFO] |     |  |  +- org.apache.maven:maven-lifecycle:jar:3.0-alpha-2:test
[INFO] |     |  |  +- org.apache.maven:maven-reporting-api:jar:3.0-alpha-2:test
[INFO] |     |  |  |  \- org.apache.maven.doxia:doxia-sink-api:jar:1.0-alpha-9:test
[INFO] |     |  |  +- org.apache.maven:maven-model:jar:3.0-alpha-2:test
[INFO] |     |  |  +- org.apache.maven:maven-plugin-api:jar:3.0-alpha-2:test
[INFO] |     |  |  +- org.codehaus.plexus:plexus-container-default:jar:1.0-beta-3.0.5:test
[INFO] |     |  |  |  +- org.apache.xbean:xbean-reflect:jar:3.4:test
[INFO] |     |  |  |  |  +- log4j:log4j:jar:1.2.12:test
[INFO] |     |  |  |  |  \- commons-logging:commons-logging-api:jar:1.1:test
[INFO] |     |  |  |  \- com.google.code.google-collections:google-collect:jar:snapshot-20080530:test
[INFO] |     |  |  +- org.apache.maven:maven-project:jar:3.0-alpha-2:test
[INFO] |     |  |  |  \- org.codehaus.woodstox:wstx-asl:jar:3.2.6:test
[INFO] |     |  |  +- org.apache.maven:maven-project-builder:jar:3.0-alpha-2:test
[INFO] |     |  |  +- commons-cli:commons-cli:jar:1.0:test
[INFO] |     |  |  +- org.codehaus.plexus:plexus-interactivity-api:jar:1.0-alpha-6:test
[INFO] |     |  |  +- org.codehaus.plexus:plexus-interpolation:jar:1.1:test
[INFO] |     |  |  +- org.codehaus.plexus:plexus-utils:jar:1.5.6:test
[INFO] |     |  |  +- org.codehaus.plexus:plexus-classworlds:jar:1.3:test
[INFO] |     |  |  +- org.codehaus.plexus:plexus-component-annotations:jar:1.0-beta-3.0.5:test
[INFO] |     |  |  +- org.sonatype.plexus:plexus-plugin-manager:jar:1.0-alpha-1:test
[INFO] |     |  |  |  +- org.apache.maven.mercury:mercury-plexus:jar:1.0.0-alpha-2:test
[INFO] |     |  |  |  |  +- org.apache.maven.mercury:mercury-repo-remote-m2:jar:1.0.0-alpha-2:test
[INFO] |     |  |  |  |  |  +- org.apache.maven.mercury:mercury-repo-api:jar:1.0.0-alpha-2:test
[INFO] |     |  |  |  |  |  |  \- org.apache.maven.mercury:mercury-transport-api:jar:1.0.0-alpha-2:test
[INFO] |     |  |  |  |  |  |     \- org.apache.maven.mercury:mercury-crypto-api:jar:1.0.0-alpha-2:test
[INFO] |     |  |  |  |  |  +- org.apache.maven.mercury:mercury-transport-http:jar:1.0.0-alpha-2:test
[INFO] |     |  |  |  |  |  |  +- org.mortbay.jetty:jetty-client:jar:6.1.12:test
[INFO] |     |  |  |  |  |  |  |  +- org.mortbay.jetty:jetty-sslengine:jar:6.1.12:test
[INFO] |     |  |  |  |  |  |  |  +- org.mortbay.jetty:jetty:jar:6.1.12:test
[INFO] |     |  |  |  |  |  |  |  \- org.mortbay.jetty:jetty-util:jar:6.1.12:test
[INFO] |     |  |  |  |  |  |  +- org.mortbay.jetty:servlet-api-2.5:jar:6.1.12:test
[INFO] |     |  |  |  |  |  |  \- org.apache.maven.mercury:mercury-crypto-basic:jar:1.0.0-alpha-2:test
[INFO] |     |  |  |  |  |  |     +- bouncycastle:bcprov-jdk15:jar:140:test
[INFO] |     |  |  |  |  |  |     \- bouncycastle:bcpg-jdk15:jar:140:test
[INFO] |     |  |  |  |  |  +- org.apache.maven.mercury:mercury-md-shared:jar:1.0.0-alpha-2:test
[INFO] |     |  |  |  |  |  |  \- org.apache.maven.mercury:mercury-util:jar:1.0.0-alpha-2:test
[INFO] |     |  |  |  |  |  \- org.apache.maven.mercury:mercury-repo-local-m2:jar:1.0.0-alpha-2:test
[INFO] |     |  |  |  |  +- org.apache.maven.mercury:mercury-repo-virtual:jar:1.0.0-alpha-2:test
[INFO] |     |  |  |  |  |  \- org.apache.maven.mercury:mercury-repo-cache-fs:jar:1.0.0-alpha-2:test
[INFO] |     |  |  |  |  +- org.apache.maven.mercury:mercury-md-sat:jar:1.0.0-alpha-2:test
[INFO] |     |  |  |  |  |  +- org.sat4j:org.sat4j.core:jar:2.0.4:test
[INFO] |     |  |  |  |  |  +- org.sat4j:org.sat4j.pb:jar:2.0.4:test
[INFO] |     |  |  |  |  |  \- org.apache.maven.mercury:mercury-event:jar:1.0.0-alpha-2:test
[INFO] |     |  |  |  |  +- org.apache.maven.mercury:mercury-logging:jar:1.0.0-alpha-2:test
[INFO] |     |  |  |  |  \- org.codehaus.plexus:plexus-lang:jar:1.1:test
[INFO] |     |  |  |  \- org.slf4j:slf4j-jdk14:jar:1.7.26:test
[INFO] |     |  |  +- org.apache.maven:maven-mercury:jar:3.0-alpha-2:test
[INFO] |     |  |  |  +- org.apache.maven.mercury:mercury-artifact:jar:1.0.0-alpha-2:test
[INFO] |     |  |  |  \- org.apache.maven.mercury:mercury-external:jar:1.0.0-alpha-2:test
[INFO] |     |  |  \- org.sonatype.spice:model-builder:jar:1.3:test
[INFO] |     |  |     \- stax:stax-api:jar:1.0.1:test
[INFO] |     |  \- org.apache.maven:maven-compat:jar:3.0-alpha-2:test
[INFO] |     |     \- org.apache.maven.wagon:wagon-provider-api:jar:1.0-beta-4:test
[INFO] |     \- org.codehaus.plexus:plexus-java:jar:0.9.11:test
[INFO] |        +- org.ow2.asm:asm:jar:7.0-beta:test
[INFO] |        \- com.thoughtworks.qdox:qdox:jar:2.0-M9:test
[INFO] +- org.postgresql:postgresql:jar:9.4.1212:runtime
[INFO] +- io.springfox:springfox-swagger2:jar:2.9.2:compile
[INFO] |  +- io.swagger:swagger-annotations:jar:1.5.20:compile
[INFO] |  +- io.swagger:swagger-models:jar:1.5.20:compile
[INFO] |  |  \- com.fasterxml.jackson.core:jackson-annotations:jar:2.9.0:compile
[INFO] |  +- io.springfox:springfox-spi:jar:2.9.2:compile
[INFO] |  |  \- io.springfox:springfox-core:jar:2.9.2:compile
[INFO] |  +- io.springfox:springfox-schema:jar:2.9.2:compile
[INFO] |  +- io.springfox:springfox-swagger-common:jar:2.9.2:compile
[INFO] |  +- io.springfox:springfox-spring-web:jar:2.9.2:compile
[INFO] |  +- com.google.guava:guava:jar:20.0:compile
[INFO] |  +- com.fasterxml:classmate:jar:1.4.0:compile
[INFO] |  +- org.slf4j:slf4j-api:jar:1.7.26:compile
[INFO] |  +- org.springframework.plugin:spring-plugin-core:jar:1.2.0.RELEASE:compile
[INFO] |  +- org.springframework.plugin:spring-plugin-metadata:jar:1.2.0.RELEASE:compile
[INFO] |  \- org.mapstruct:mapstruct:jar:1.2.0.Final:compile
[INFO] +- org.springframework.boot:spring-boot-starter-activemq:jar:2.1.6.RELEASE:compile
[INFO] |  +- org.springframework:spring-jms:jar:5.1.8.RELEASE:compile
[INFO] |  |  \- org.springframework:spring-messaging:jar:5.1.8.RELEASE:compile
[INFO] |  +- org.apache.activemq:activemq-broker:jar:5.15.9:compile
[INFO] |  |  +- org.apache.activemq:activemq-client:jar:5.15.9:compile
[INFO] |  |  |  +- org.fusesource.hawtbuf:hawtbuf:jar:1.11:compile
[INFO] |  |  |  \- org.apache.geronimo.specs:geronimo-j2ee-management_1.1_spec:jar:1.0.1:compile
[INFO] |  |  \- org.apache.activemq:activemq-openwire-legacy:jar:5.15.9:compile
[INFO] |  \- javax.jms:javax.jms-api:jar:2.0.1:compile
[INFO] \- org.apache.activemq.tooling:activemq-junit:jar:5.15.9:test
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.764 s
[INFO] Finished at: 2019-07-09T12:53:49+07:00
[INFO] Final Memory: 33M/446M
[INFO] ------------------------------------------------------------------------

And we can see that com.google.code.google-collections:google-collect:jar:snapshot-20080530:test was loaded by maven-failsafe-plugin. Removing maven-failsafe-plugin from pom file solve this issue.

And this is the result,

Create A Docker for Running Apache and PHP

Below is the script for creating a docker which contain Apache and PHP,

docker run --rm \
--detach \
--name=web_01 \
--net mynet \
--ip 192.168.0.29 \
--publish 10209:80 \
--volume="$PWD"/apps:/app \
--volume="$PWD"/logs:/app/application/logs \
--workdir=/app \
-e PHP_DATE_TIMEZONE='Asia/Jakarta' \
-e LOG_STDOUT='/logs' \
-e LOG_STDERR='/logs' \
webdevops/php-apache:alpine

A Simple Thousand Separator using Java

Trying to create a quick and simple solution for formatting an Integer into a formatted string with thousand separator,

	class Main
	{
		public static void main (String[] args) throws java.lang.Exception
		{
			String s = (String.format("%,d", 10000000)).replace(",",".");
			System.out.println(s);
		}
	}

The output will be, 10.000.000. (H)

Changing Couchbase Data Directory Location

Usually Couchbase put its data on default location (/opt/couchbase/var/lib/couchbase/data). But because my disk’s space is full, i have to move Couchbase data to other location. In my case, /data folder which is mounted to an empty 100GB SSD disk. Below is how i change it,

First, i have to change the content of below file,

vi /opt/couchbase/etc/couchdb/default.d/capi.ini 

Changing database_dir and view_index_dir on below Couchbase configuration file, to my new location folder

[couchdb]
max_dbs_open = 10000
database_dir = /data
view_index_dir = /data

[httpd]
db_frontend = capi_frontend
ip4_bind_address = 0.0.0.0
ip6_bind_address = ::
port = 8092

Next is move the content of old folder (/opt/couchbase/var/lib/couchbase/data), to our new folder (/data). And restart our Couchbase service to implement our changes.

  sudo service couchbase-server stop
  sudo service couchbase-server start

We can see the result on our Couchbase web console, hopefully it helps (H)

ps. My Couchbase version is “Enterprise Edition 6.0.0 build 1693”.