Afrozaar / wp-api-v2-client-java

WP-API v2 Java Client
Apache License 2.0
84 stars 55 forks source link

Latest version (4.14) on start ends with exception #57

Open hasanli-orkhan opened 4 years ago

hasanli-orkhan commented 4 years ago

Hello, dear developer! I have builded jar from source code with maven. Steps to reproduce the problem:

clintonbosch commented 4 years ago

Hi

This is very strange, I can not reproduce this issue. Also MultiValueMap is definitely part of spring-core and spring-web is definitely included in pom. See dependency tree below:

--- maven-dependency-plugin:2.8:tree (default-cli) @ wp-api-v2-client-java --- [INFO] com.afrozaar.wordpress:wp-api-v2-client-java:jar:4.14.0-SNAPSHOT [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] +- junit:junit:jar:4.11:test [INFO] | - org.hamcrest:hamcrest-core:jar:1.3:test [INFO] +- com.fasterxml.jackson.core:jackson-annotations:jar:2.6.5:compile [INFO] +- com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:jar:2.6.5:compile [INFO] | +- com.fasterxml.jackson.jaxrs:jackson-jaxrs-base:jar:2.6.5:compile [INFO] | +- com.fasterxml.jackson.core:jackson-core:jar:2.6.5:compile [INFO] | +- com.fasterxml.jackson.core:jackson-databind:jar:2.6.5:compile [INFO] | - com.fasterxml.jackson.module:jackson-module-jaxb-annotations:jar:2.6.5:compile [INFO] +- org.assertj:assertj-core:jar:3.0.0:compile [INFO] +- org.springframework:spring-web:jar:4.1.7.RELEASE:compile [INFO] | +- org.springframework:spring-aop:jar:4.1.7.RELEASE:compile [INFO] | | - aopalliance:aopalliance:jar:1.0:compile [INFO] | +- org.springframework:spring-beans:jar:4.1.7.RELEASE:compile [INFO] | +- org.springframework:spring-context:jar:4.1.7.RELEASE:compile [INFO] | | - org.springframework:spring-expression:jar:4.1.7.RELEASE:compile [INFO] | - org.springframework:spring-core:jar:4.1.7.RELEASE:compile [INFO] +- com.google.guava:guava:jar:18.0:compile [INFO] +- org.slf4j:slf4j-api:jar:1.7.12:compile [INFO] +- ch.qos.logback:logback-classic:jar:1.1.3:compile [INFO] | - ch.qos.logback:logback-core:jar:1.1.3:compile [INFO] +- org.yaml:snakeyaml:jar:1.15:compile [INFO] +- com.github.tomakehurst:wiremock:jar:1.55:test [INFO] | +- org.apache.httpcomponents:httpclient:jar:4.3.5:test [INFO] | | +- org.apache.httpcomponents:httpcore:jar:4.3.2:test [INFO] | | - commons-codec:commons-codec:jar:1.6:test [INFO] | +- xmlunit:xmlunit:jar:1.5:test [INFO] | +- org.mortbay.jetty:jetty:jar:6.1.26:test [INFO] | | +- org.mortbay.jetty:jetty-util:jar:6.1.26:test [INFO] | | - org.mortbay.jetty:servlet-api:jar:2.5-20081211:test [INFO] | +- org.skyscreamer:jsonassert:jar:1.2.3:test [INFO] | | - org.json:json:jar:20090211:test [INFO] | +- com.jayway.jsonpath:json-path:jar:0.8.1:test [INFO] | | +- net.minidev:json-smart:jar:1.1.1:test [INFO] | | - commons-lang:commons-lang:jar:2.6:test [INFO] | - net.sf.jopt-simple:jopt-simple:jar:4.7:test [INFO] +- commons-beanutils:commons-beanutils-core:jar:1.8.3:compile [INFO] | - commons-logging:commons-logging:jar:1.1.1:compile [INFO] +- com.google.code.findbugs:jsr305:jar:3.0.1:compile [INFO] - org.testcontainers:testcontainers:jar:1.7.3:test [INFO] +- org.slf4j:slf4j-ext:jar:1.7.25:test [INFO] +- org.jetbrains:annotations:jar:15.0:test [INFO] +- javax.annotation:javax.annotation-api:jar:1.3.1:test [INFO] +- org.apache.commons:commons-compress:jar:1.16.1:test [INFO] | - org.objenesis:objenesis:jar:2.6:test [INFO] +- javax.xml.bind:jaxb-api:jar:2.3.0:test [INFO] +- org.rnorth.duct-tape:duct-tape:jar:1.0.7:test [INFO] +- org.rnorth.visible-assertions:visible-assertions:jar:2.1.0:test [INFO] | - net.java.dev.jna:jna:jar:4.5.0:test [INFO] - org.rnorth:tcp-unix-socket-proxy:jar:1.0.2:test [INFO] +- com.kohlschutter.junixsocket:junixsocket-native-common:jar:2.0.4:test [INFO] | +- org.scijava:native-lib-loader:jar:2.0.2:test [INFO] | - log4j:log4j:jar:1.2.17:test [INFO] - com.kohlschutter.junixsocket:junixsocket-common:jar:2.0.4:test

hasanli-orkhan commented 4 years ago

I can also send the full log of maven compile evening. Can you attach the builded jar, please?)) I really need it today))) Thanks in advance.

clintonbosch commented 4 years ago

https://wetransfer.com/downloads/18b151f24f69f51cf4d7deceb6b1bcac20200211112103/6c961cd7bf9caed24c1d01ccaec042fc20200211112104/a638ad

hasanli-orkhan commented 4 years ago

Thank you so much! I have included this jar to the test project and get the same Exception -

Exception in thread "main" java.lang.NoClassDefFoundError: org/springframework/util/MultiValueMap
    at com.afrozaar.wordpress.wpapi.v2.config.ClientFactory.fromConfig(ClientFactory.java:12)
    at wpTest.WP.main(WP.java:21)
Caused by: java.lang.ClassNotFoundException: org.springframework.util.MultiValueMap
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
Caused by: java.lang.ClassNotFoundException: org.springframework.util.MultiValueMap

    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
    ... 2 more

Here is the simple project: https://github.com/azerphoenix/wpTestJavaClient

This code works well with version 4.8.3 wich was on mvnrepository. Also I have tested this code with Java 1.8 Oracle, Java 1.8 OpenJDK, Java 11 OpenJDK.

To make it work I have also included this libraries into Gradle build

    compile fileTree(include: ['*.jar'], dir: 'libs')

    // https://mvnrepository.com/artifact/org.springframework/spring-core
    compile group: 'org.springframework', name: 'spring-core', version: '4.1.7.RELEASE'
    // https://mvnrepository.com/artifact/org.springframework/spring-web
    compile group: 'org.springframework', name: 'spring-web', version: '4.1.7.RELEASE'
    // https://mvnrepository.com/artifact/org.slf4j/slf4j-api
    compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.12'
    // https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core
    compile group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: '2.6.5'
    // https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind
    compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.6.5'
    // https://mvnrepository.com/artifact/com.google.guava/guava
    compile group: 'com.google.guava', name: 'guava', version: '18.0'

Also per my check there is other problem in 4.8.3 & 4.14.0 versions.

final Post post = PostBuilder.aPost()
                    .withTitle(aTitle().withRendered(articleName).build())
                    .withContent(ContentBuilder.aContent().withRendered(articleContent).build())
                    .withLink(articleSlug)
                    .withSlug(articleSlug)
                    .withCategories(catIds)
                    .build();

Methods withLink() & withSlug() not working. WordPress generates slugs itself.