Jackson Databind Issue - Gradle - gradle

I tried to deploy strom Topology written with 2.2.0 at local with below command:
./storm local ./sample.jar com.sample.processor.storm.Main config.yml
But unfortunately, I got this issue:
java.lang.NoClassDefFoundError:
Could not initialize class
com.fasterxml.jackson.databind.deser.std.JdkDeserializers
I had included this at gradle file , provided below the gradle file:
buildscript {
repositories {
mavenCentral()
jcenter()
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.0.1"
}
}
repositories {
maven { url "http://clojars.org/repo"}
maven { url "https://repository.cloudera.com/artifactory/cloudera-repos/" }
jcenter { url "http://jcenter.bintray.com/" }
}
configurations {
includeInJar
}
dependencies {
includeInJar 'org.codehaus.jackson:jackson-core-asl:1.9.13'
includeInJar 'org.codehaus.jackson:jackson-mapper-asl:1.9.12'
includeInJar 'com.fasterxml.jackson.core:jackson-databind:2.9.8'
compile ('org.apache.storm:storm-core:2.2.0') {
exclude group: 'org.slf4j'
exclude group: 'com.fasterxml.jackson.core'
}
compile 'org.codehaus.jackson:jackson-core-asl:1.9.13'
compile 'org.codehaus.jackson:jackson-mapper-asl:1.9.12'
compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.9.8'
}
Compilation is successful, I was able to test at IDE at runtime, but only during local deployment, above error occurs
Any help appreciated. Thanks in Advance!
Same gradle-file worked with storm 0.10.0 but not working at 2.2.0

I removed fasterxml dependencies from gradle build as this conflicts with jackson library and it builds JAR executable fine.

Related

Getting 401 Unauthorized during Gradle build for Atlassian Renderer library

I think by Gradle build problem is related to this Spring article about Spring Artifactory instance repo.spring.io permissions. Pls help me correct my build.gradle which has started failing recently after upgrading to Gradle 5.0.
Snippet from build.gradle
buildscript {
ext {
springBootVersion = SPRING_BOOT_VERSION
}
repositories {
mavenCentral()
maven {
url 'https://repo.spring.io/libs-milestone'
}
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
classpath('se.transmode.gradle:gradle-docker:1.2')
}
}
apply plugin: 'java'
repositories {
mavenCentral()
maven {
url 'https://repo.spring.io/libs-milestone'
}
maven { url "https://packages.atlassian.com/maven/repository/public" }
}
dependencies {
compile (group: 'com.atlassian.renderer', name: 'atlassian-renderer', version:'8.0.5') {
exclude(module: 'servlet-api')
exclude(module: 'radeox')
// https://mvnrepository.com/artifact/javax.activation/activation
compile group: 'javax.activation', name: 'activation', version: '1.1.1'
}
}
The error i get is
> Could not resolve com.atlassian.renderer:atlassian-renderer:8.0.5.
> Could not get resource 'https://repo.spring.io/libs-milestone/com/atlassian/renderer/atlassian-renderer/8.0.5/atlassian-renderer-8.0.5.pom'.
> Could not HEAD 'https://repo.spring.io/libs-milestone/com/atlassian/renderer/atlassian-renderer/8.0.5/atlassian-renderer-8.0.5.pom'. Received status code 401 from server: Unauthorized
Please help.
I added jCenter in the repositories in build.gradle and it worked for me.
jcenter()
I think the atlassian-renderer is no longer available with maven repo.

How to upgrade existing Micronaut application to new Micronaut version 1.1.2?

I have been upgrading like this..
plugins {
id "io.spring.dependency-management" version "1.0.6.RELEASE"
id "com.github.johnrengelman.shadow" version "4.0.2"
}
apply plugin:"application"
apply plugin:"groovy"
version "0.1"
group "com.shanky"
repositories {
mavenLocal()
mavenCentral()
maven { url "https://jcenter.bintray.com" }
}
dependencyManagement {
imports {
mavenBom 'io.micronaut:micronaut-bom:1.1.2'
}
}
dependencies {
compile "io.micronaut:micronaut-runtime-groovy"
compile "io.micronaut:micronaut-validation"
compile "io.micronaut:micronaut-http-client"
compile "io.micronaut:micronaut-http-server-netty"
compileOnly "io.micronaut:micronaut-inject-groovy"
runtime "ch.qos.logback:logback-classic:1.2.3"
testCompile "io.micronaut:micronaut-inject-groovy"
testCompile("org.spockframework:spock-core") {
exclude group: "org.codehaus.groovy", module: "groovy-all"
}
compile 'io.micronaut:micronaut-views'
runtime 'org.thymeleaf:thymeleaf:3.0.11.RELEASE'
compile "io.micronaut.configuration:micronaut-hibernate-validator"
compile "io.micronaut.configuration:micronaut-hibernate-gorm"
runtime 'org.postgresql:postgresql:42.2.5'
annotationProcessor "io.micronaut:micronaut-security"
compile "io.micronaut:micronaut-security"
compile "io.micronaut:micronaut-security-session"
runtime "org.hibernate:hibernate-ehcache:5.1.9.Final"
}
shadowJar {
mergeServiceFiles()
}
run.jvmArgs('-noverify', '-XX:TieredStopAtLevel=1')
mainClassName = "com.shanky.Application"
tasks.withType(GroovyCompile) {
groovyOptions.forkOptions.jvmArgs.add('-Dgroovy.parameters=true')
}
So far this is my build.gradle file. I have updated mavenBom to upgrade Micronaut version. I've create a dummy project with Micronaut version 1.1.2 just to differentiate build.gradle file. I don't see any major difference in between them.
Any help would be appreciated
But it is not upgrading.
That is unlikely to be correct. It may be that you aren't seeing the effect of that change in your IDE if the IDE is out of sync with your Gradle build but changing that version number in build.gradle does in fact upgrade the project.

quarkus gradle test not executed

I'am trying the quarkus getting-started project. With maven the contained unittest is executed. Then I tried the proposed gradle build file, because we use gradle instead of maven. When I run gradle test, the unittest is definitivly not executed (I know, because I modified it to fail).
apply plugin: 'java'
apply plugin: 'io.quarkus.gradle.plugin'
buildscript {
repositories {
mavenCentral()
maven {
//this is temporary, all dependencies should be in central soon
url 'http://repository.jboss.org/nexus/content/groups/public'
}
}
dependencies {
classpath 'io.quarkus:quarkus-gradle-plugin:0.11.0'
}
}
repositories {
mavenCentral()
maven {
url 'http://repository.jboss.org/nexus/content/groups/public'
}
}
dependencies {
compileOnly group: 'io.quarkus', name: 'quarkus-resteasy', version:'0.11.0'
testCompile group: 'io.quarkus', name: 'quarkus-junit5', version:'0.11.0'
testCompile group: 'io.rest-assured', name: 'rest-assured', version: '3.3.0'
}
Is this a bug or do I anything wrong?
OK, I found the problem. Gradle does not use JUnit5 out of the box. You have to add the following to the build.gradle to get gradle starting the tests:
test {
useJUnitPlatform()
}

Spring Boot plugin doesn't add lib folder in jar

I have the following build.gradle:
group 'as'
version '1.0'
buildscript {
ext {
springVersion = '5.0.4.RELEASE'
springBootVersion = '1.5.6.RELEASE'
springJPAVersion = '2.0.5.RELEASE'
javaxVersion = '1.0.2'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
apply plugin: 'java'
apply plugin: 'org.springframework.boot'
jar {
baseName = 'reports'
version = '0.0.1'
manifest {
attributes 'Implementation-Title': baseName,
'Implementation-Version': version
}
from {
configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }
}
}
repositories {
jcenter()
maven { url "https://repo.spring.io/snapshot" }
maven { url "https://repo.spring.io/milestone" }
}
dependencies {
implementation "org.springframework.boot:spring-boot-starter-web:${springBootVersion}"
implementation "org.springframework.boot:spring-boot-starter-data-jpa:${springBootVersion}"
implementation "org.springframework.data:spring-data-jpa:${springJPAVersion}"
implementation "javax.persistence:persistence-api:${javaxVersion}"
implementation "mysql:mysql-connector-java:5.1.43"
testImplementation group: 'junit', name: 'junit', version: '4.11'
}
And gradle creates jar with following structure:
BOOT-INF
classes
META-INF
org
But it seems that the structure must be the following:
BOOT-INF
classes
lib
META-INF
org
with lib folder, which contains dependencies, because now after launch I get error:
Exception ...
Caused by: java.lang.NoClassDefFoundError:
org/springframework/boot/SpringApplication at com.as.reports.Application.main(Application.java:12)
So I know this answer is probably too late to help you, but I stumbled across this question while trying to solve the exact same problem, and was reminded of this.
After half a day of trial and error, I found the solution, so hopefully I can save someone else the pain of finding this unanswered question.
The problem is with using the implementation keyword in your dependencies. The 1.x Spring Boot Gradle plugin doesn't appear recognize that keyword as notating required dependencies for repackaging a fat jar. If you change those back to the older compile keyword, you should get the necessary lib folder.

How to force a specific dependency version in a gradle buildscript

There's an issue for the gradle-docker-plugin and SpringBootVersion 2.0.0.M4
M4 uses a newer jersey client and using the docker-plugin ends in an Exception:
ERROR com.github.dockerjava.core.async.ResultCallbackTemplate - Error during callback
java.lang.IllegalStateException: InjectionManagerFactory not found.
at org.glassfish.jersey.internal.inject.Injections.lambda$lookupInjectionManagerFactory$0(Injections.java:98)
at java.util.Optional.orElseThrow(Optional.java:290)
at org.glassfish.jersey.internal.inject.Injections.lookupInjectionManagerFactory(Injections.java:98)
at org.glassfish.jersey.internal.inject.Injections.createInjectionManager(Injections.java:68)
at org.glassfish.jersey.client.ClientConfig$State.initRuntime(ClientConfig.java:432)
at org.glassfish.jersey.internal.util.collection.Values$LazyValueImpl.get(Values.java:341)
at org.glassfish.jersey.client.ClientConfig.getRuntime(ClientConfig.java:826)
at org.glassfish.jersey.client.ClientRequest.getConfiguration(ClientRequest.java:285)
at org.glassfish.jersey.client.JerseyInvocation.validateHttpMethodAndEntity(JerseyInvocation.java:143)
at org.glassfish.jersey.client.JerseyInvocation.<init>(JerseyInvocation.java:112)
at org.glassfish.jersey.client.JerseyInvocation.<init>(JerseyInvocation.java:108)
at org.glassfish.jersey.client.JerseyInvocation.<init>(JerseyInvocation.java:99)
at org.glassfish.jersey.client.JerseyInvocation$Builder.method(JerseyInvocation.java:456)
at org.glassfish.jersey.client.JerseyInvocation$Builder.post(JerseyInvocation.java:357)
at com.github.dockerjava.jaxrs.async.POSTCallbackNotifier.response(POSTCallbackNotifier.java:29)
at com.github.dockerjava.jaxrs.async.AbstractCallbackNotifier.call(AbstractCallbackNotifier.java:50)
at com.github.dockerjava.jaxrs.async.AbstractCallbackNotifier.call(AbstractCallbackNotifier.java:24)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
My BuildScript in my main project:
buildscript {
ext {
springBootVersion = "2.0.0.M4"
}
repositories {
maven { url "https://repo.spring.io/plugins-snapshot" }
maven { url "https://plugins.gradle.org/m2/" }
}
dependencies {
classpath "org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}"
}
}
....
As you can see, we load the spring-boot-gradle-plugin version=2.0.0.M4 and all its dependencies.
My subproject build.gradle:
apply plugin: "org.springframework.boot"
apply from: "docker.gradle"
....
Most important the docker.gradle file in the same directory as the build.gradle of the subproject:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.bmuschko:gradle-docker-plugin:3.0.11'
}
}
apply plugin: com.bmuschko.gradle.docker.DockerRemoteApiPlugin
import com.bmuschko.gradle.docker.tasks.image.*
...
task buildImage(type: DockerBuildImage, dependsOn: copyDockerFiles) {
version.release = true
dockerFile = file("${projectDir}/build/docker/Dockerfile")
inputDir = file("${projectDir}/build/docker")
tags = ['...']
}
My Questions:
How do I know which Version of the jersey client loads SpringBoot 2.0.0.M4?
How do I force gradle in docker.gradle to use a specific version of the jersey client?
Adding to the classpath didnt work. I think gradle will just use the newest version, wich will be loaded by SpringBoot 2.0.0.M4
You have to add the following in your build.gradle dependencies as pointed in: This Link
dockerJava 'com.nirima:docker-java-shaded:0.16.2'
dockerJava 'org.slf4j:slf4j-simple:1.7.5'
dockerJava 'cglib:cglib:3.2.0'
After that you have to separate "buildImage" and "tagImage" tasks as suggested in This link
I have tested this with: spring boot 2.0.0.M6
I simply did:-
dependencies {
classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4+"
classpath "org.mozilla:rhino:1.7.14"
classpath ( group: 'org.apache.commons', name: 'commons-text'){
version{
strictly '1.10.0'
}
}
}

Resources