Spring data Mongo DB wrong REST configuration - java

currently I am writing some small web application using Spring and Mongo DB. My problem is to display ID in RESTs. I found this solution:
import org.springframework.context.annotation.Configuration;
import org.springframework.data.rest.core.config.RepositoryRestConfiguration;
import org.springframework.data.rest.webmvc.config.RepositoryRestMvcConfiguration;
import pl.rakoczy.taskmanager.model.Task;
#Configuration
public class RepositoryConfig extends
RepositoryRestMvcConfiguration {
#Override
protected void configureRepositoryRestConfiguration(
RepositoryRestConfiguration config) {
config.exposeIdsFor(Task.class);
}
}
After start application exception appears:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'repositoryExporterHandlerAdapter' defined in class path resource [pl/rakoczy/taskmanager/repository/RepositoryConfig.class]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: org.springframework.data.util.ClassTypeInformation.from(Ljava/lang/Class;)Lorg/springframework/data/util/TypeInformation;
I found solution to update some dependencies in gradle configuration, but I think I do have newest versions:
dependencies {
compile 'org.slf4j:slf4j-api:1.7.21'
compile group: 'org.springframework', name: 'spring-context', version: '4.3.2.RELEASE'
compile group: 'org.springframework', name: 'spring-core', version: '4.3.2.RELEASE'
compile group: 'org.springframework', name: 'spring-beans', version: '4.3.2.RELEASE'
compile group: 'org.springframework', name: 'spring-web', version: '4.3.2.RELEASE'
compile group: 'org.springframework', name: 'spring-expression', version: '4.3.2.RELEASE'
compile group: 'org.springframework', name: 'spring-asm', version: '3.1.4.RELEASE'
compile group: 'org.springframework.boot', name: 'spring-boot-starter-test', version: '1.4.0.RELEASE'
compile group: 'org.springframework.boot', name: 'spring-boot-starter-web', version: '1.4.0.RELEASE'
compile group: 'org.springframework.data', name: 'spring-data-mongodb', version: '1.9.2.RELEASE'
compile group: 'org.springframework.data', name: 'spring-data-jpa', version: '1.10.2.RELEASE'
compile group: 'org.springframework.data', name: 'spring-data-rest-webmvc', version: '2.0.0.RELEASE'
compile group: 'org.springframework.hateoas', name: 'spring-hateoas', version: '0.16.0.RELEASE'
compile group: 'org.tinylog', name: 'tinylog', version: '1.1'
compile group: 'javax.inject', name: 'javax.inject', version: '1'
compile group: 'org.mongodb', name: 'mongo-java-driver', version: '3.3.0'
compile group: 'org.aspectj', name: 'aspectjweaver', version: '1.8.9'
compile group: 'cglib', name: 'cglib-nodep', version: '3.2.4'
testCompile 'junit:junit:4.12'
testCompile 'com.jayway.jsonpath:json-path'
testCompile 'org.springframework.boot:spring-boot-starter-test'
}
I am new at Spring, can you see any problems?

You have added both Spring and Spring boot dependencies. Best way to start is to use Spring Boot dependencies and then add other dependencies as per requirement. Please check https://spring.io/guides/gs/accessing-data-mongodb/. The error you are getting is related to "org.springframework.data.util.ClassTypeInformation" class which is part of spring-data-commons jar file. Check if this jar file and its latest version is there in your deployed war file. I will again suggest you to clean up your Gradle build and keep required and latest files. For example you are using older version of spring-data-rest-webmvc.

The error says that Spring is trying to invoke an init() method in that class, and none exists.
Consult the spring documentation here: http://docs.spring.io/spring-data/rest/docs/current/reference/html/#customizing-sdr.adding-sdr-to-spring-mvc-app

Related

Spring boot app runs with intelliJ but crashes in docker

I have a spring boot app. It is mainly a Kafka listening app and its only web application part is the health check API through the spring-boot-starter-actuator.
When running locally in IntelliJ, the application runs perfectly, with no errors and no crashes.
However, when trying to run the app through docker, the app starts (i can see the spring logo) and then it imidietly crashes with the next error:
[org.springframework.boot.SpringApplication] - Application run failed
MyApp | 2021-02-25T19:17:17.802342316Z org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.context.ApplicationContextException: Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean.
My dependency section in the build.gradle file looks as follows:
dependencies {
implementation 'org.springframework.boot:spring-boot-starter'
implementation 'org.springframework.kafka:spring-kafka'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
compile group: 'org.springframework.boot', name: 'spring-boot-starter-web', version: '2.4.2'
/*logging*/
compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.30'
testCompile group: 'org.slf4j', name: 'slf4j-log4j12', version: '1.7.30'
testCompile group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.3'
compile group: 'net.logstash.logback', name: 'logstash-logback-encoder', version: '6.4'
compile group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.3'
compile group: 'ch.qos.logback', name: 'logback-core', version: '1.2.3'
compile group: 'ch.qos.logback', name: 'logback-access', version: '1.2.3'
/*lombok*/
compileOnly 'org.projectlombok:lombok:1.18.16'
annotationProcessor 'org.projectlombok:lombok:1.18.16'
/*metrics*/
compile group: 'io.prometheus', name: 'simpleclient', version: '0.9.0'
compile group: 'io.prometheus', name: 'simpleclient_httpserver', version: '0.9.0'
compile group: 'io.prometheus', name: 'simpleclient_servlet', version: '0.9.0'
compile group: 'io.micrometer', name: 'micrometer-registry-prometheus', version: '1.5.1'
compile group: 'io.micrometer', name: 'micrometer-core', version: '1.5.1'
compile group: 'org.springframework.boot', name: 'spring-boot-starter-actuator', version: '2.4.2'
/*Jetty server*/
compile group: 'org.eclipse.jetty', name: 'jetty-server', version: '9.4.29.v20200521'
compile group: 'org.eclipse.jetty', name: 'jetty-servlet', version: '9.4.29.v20200521'
/* mysql */
compile group: 'mysql', name: 'mysql-connector-java', version: '8.0.22'
/*mongo*/
compile group: 'org.mongodb', name: 'mongo-java-driver', version: '3.12.7'
// generate pojo from avro schema
compile "org.apache.avro:avro-compiler:1.10.0"
//avro serde
compile group: 'io.confluent', name: 'kafka-streams-avro-serde', version: '5.2.1'
compile group: 'com.fasterxml.jackson.datatype', name: 'jackson-datatype-jsr310', version: '2.12.0'
compile group: 'io.projectreactor', name: 'reactor-core', version: '3.4.0'
implementation('com.fasterxml.jackson.dataformat:jackson-dataformat-avro:2.11.2')
/* cassandra*/
implementation("io.dropwizard.metrics:metrics-core:3.2.2")
compile group: 'com.datastax.cassandra', name: 'cassandra-driver-core', version: '3.8.0'
compile group: 'com.datastax.cassandra', name: 'cassandra-driver-mapping', version: '3.10.2'
/*tests*/
testImplementation 'org.springframework.kafka:spring-kafka-test'
testImplementation('org.springframework.boot:spring-boot-starter-test') {
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
}
testCompile("junit:junit:4.12")
}
My main application class looks as follows:
#SpringBootApplication()
public class MyApp {
public static void main(String[] args) {
SpringApplication.run(MyApp.class, args);
}
}
Can anyone shed some light on the reason behind this issue and how to fix it?
Why would it run with no problems in IntelliJ but crash with docker?
Any help would be appreciated.
Thank you.

java.lang.AbstractMethodError: Receiver class org.springframework.cloud.bootstrap.BootstrapApplicationListener [duplicate]

I'm facing this error while running the project. I'm unable to know the cause of the error and unable to find a solution online as well.
This project is running over another laptop without any error but when I extracted the zip and tried to run it, found it throwing error.
Please help me figure this out. Thanks
Error
Execution failed for task ':Application.main()'.
Process 'command '/home/jamshaid/Documents/idea-IC-192.5728.98/jbr/bin/java'' finished with non-zero exit value 1
StackTrace
2019-08-11 09:57:06,589 2269 [main] INFO com.techno.homes.Application - No active profile set, falling back to default profiles: default
2019-08-11 09:57:06,628 2308 [main] ERROR o.s.boot.SpringApplication - Application run failed
java.lang.AbstractMethodError: Receiver class org.springframework.cloud.bootstrap.BootstrapApplicationListener$CloseContextOnFailureApplicationListener does not define or inherit an implementation of the resolved method abstract getOrder()I of interface org.springframework.core.Ordered.
at org.springframework.core.OrderComparator.findOrder(OrderComparator.java:142)
at org.springframework.core.annotation.AnnotationAwareOrderComparator.findOrder(AnnotationAwareOrderComparator.java:65)
at org.springframework.core.OrderComparator.getOrder(OrderComparator.java:125)
at org.springframework.core.OrderComparator.getOrder(OrderComparator.java:113)
at org.springframework.core.OrderComparator.doCompare(OrderComparator.java:82)
at org.springframework.core.OrderComparator.compare(OrderComparator.java:68)
at java.base/java.util.TimSort.countRunAndMakeAscending(TimSort.java:360)
at java.base/java.util.TimSort.sort(TimSort.java:220)
at java.base/java.util.Arrays.sort(Arrays.java:1515)
at java.base/java.util.ArrayList.sort(ArrayList.java:1749)
at org.springframework.boot.SpringApplication.asUnmodifiableOrderedSet(SpringApplication.java:1325)
at org.springframework.boot.SpringApplication.getListeners(SpringApplication.java:1234)
at org.springframework.boot.context.event.EventPublishingRunListener.contextLoaded(EventPublishingRunListener.java:85)
at org.springframework.boot.SpringApplicationRunListeners.contextLoaded(SpringApplicationRunListeners.java:66)
at org.springframework.boot.SpringApplication.prepareContext(SpringApplication.java:394)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:328)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1258)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1246)
at com.techno.homes.Application.main(Application.java:24)
Gradle File
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'org.springframework.boot'
apply plugin: 'application'
apply plugin: 'docker'
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'}
buildscript {
project.ext {
springBootVersion = '2.0.4.RELEASE'
jarName = 'recipe'
versionName = '1.0.0'
gradleDockerVersion = '1.2'
swagger2version = '2.9.2'
}
repositories {
jcenter()
maven { url "https://repo.maven.apache.org/maven2" }
}
dependencies {
classpath "org.springframework.boot:spring-boot-gradle- plugin:${project.springBootVersion}"
classpath "se.transmode.gradle:gradle-docker:${project.gradleDockerVersion}"
}
}
task createWrapper(type: Wrapper) {
gradleVersion = '4.4.1'
}
// Used by the Docker gradle plugin, group refers to the account under which the docker image is created
group = 'com.techno.homes'
mainClassName = 'com.techno.homes.Application'
sourceCompatibility = 11
targetCompatibility = 11
repositories {
mavenCentral()
jcenter()
}
ext {
springCloudVersion = 'Greenwich.SR2'
}
dependencies {
compile group: 'org.springframework.boot', name: 'spring-boot-starter-data-jpa', version: '2.0.4.RELEASE'
compile group: 'org.springframework.boot', name: 'spring-boot-starter-web'
compile group: 'org.springframework.boot', name: 'spring-boot-starter-actuator', version: '2.0.4.RELEASE'
compile group: 'org.hibernate.validator', name: 'hibernate-validator', version: '6.0.16.Final'
compile group: 'org.springframework.boot', name: 'spring-boot-starter-web-services', version: '2.0.4.RELEASE'
compile group: 'ma.glasnost.orika', name: 'orika-core', version: '1.4.6'
compile group: 'org.hamcrest', name: 'hamcrest-library', version: '1.3'
compile group: 'junit', name: 'junit', version: '4.12'
compile group: 'org.springframework.boot', name: 'spring-boot-test-autoconfigure', version: '2.0.4.RELEASE'
compile group: 'org.springframework', name: 'spring-test', version: '5.1.8.RELEASE'
compile(group: 'org.hibernate', name: 'hibernate-entitymanager', version: '5.4.3.Final')
compile(group: 'org.hibernate', name: 'hibernate-core', version: '5.2.17.Final')
compile group: 'org.springframework.boot', name: 'spring-boot-test'
compile group: 'org.mockito', name: 'mockito-core', version: '2.15.0'
compile group: 'info.cukes', name: 'cucumber-java', version: '1.2.4'
compile group: 'info.cukes', name: 'cucumber-core', version: '1.2.4'
compile group: 'info.cukes', name: 'cucumber-junit', version: '1.2.4'
compile group: 'com.google.code.findbugs', name: 'jsr305', version: '2.0.1'
compile group: 'com.spotify', name: 'docker-maven-plugin', version: '1.2.0'
compile group: 'org.projectlombok', name: 'lombok', version: '1.18.8'
runtime group: 'mysql', name: 'mysql-connector-java', version: '5.1.46'
testCompile group: 'org.springframework.boot', name: 'spring-boot-starter-test'
testCompile group: 'com.github.tomakehurst', name: 'wiremock', version: '1.58'
testCompile group: 'info.cukes', name: 'cucumber-spring', version: '1.2.5'
// Basic Spring boot with config client
// compile('org.springframework.cloud:spring-cloud-starter-config')
compile("org.springframework.boot:spring-boot-starter-web")
compile("org.springframework.boot:spring-boot-starter-actuator")
// Spring OAuth2 security
compile("org.springframework.boot:spring-boot-starter-security")
compile("org.springframework.security.oauth:spring-security-oauth2")
// compile("org.springframework.security:spring-security-jwt")
compile group: 'org.springframework.security', name: 'spring-security-jwt', version: '1.0.10.RELEASE'
// Eureka client
// compile('org.springframework.cloud:spring-cloud-starter-eureka')
compile group: 'org.springframework.cloud', name: 'spring-cloud-starter-netflix-eureka-client', version: '2.0.0.RELEASE'
// Zipkin tracing
//compile('org.springframework.cloud:spring-cloud-starter-zipkin')
compile group: 'org.springframework.cloud', name: 'spring-cloud-starter-zipkin', version: '2.1.2.RELEASE'
// Swagger for API testing
compile("io.springfox:springfox-swagger2:${swagger2version}")
compile("io.springfox:springfox-swagger-ui:${swagger2version}")
compile group: 'org.springframework.security', name: 'spring-security-core', version: '5.1.5.RELEASE'
compile group: 'org.springframework.security', name: 'spring-security-config', version: '5.1.5.RELEASE'
compile group: 'org.springframework.security', name: 'spring-security-web', version: '5.1.5.RELEASE'
compile group: 'org.springframework.security.oauth', name: 'spring-security-oauth2', version: '2.3.6.RELEASE'
compile group: 'com.google.code.gson', name: 'gson', version: '2.8.5'
//camel
compile group: 'org.apache.camel', name: 'camel-spring-boot', version: '2.15.1'
compile group: 'org.apache.camel', name: 'camel-pulsar', version: '2.24.1'
compile group: 'org.apache.camel', name: 'camel-core', version: '2.24.1'
compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.9.9.3'
}
jar {
baseName = "${project.jarName}"
version = "${project.versionName}"
enabled = true
manifest {
attributes 'Main-Class': 'com.techno.homes.Application'
}
}
Allication
#Configuration
#EnableJpaAuditing
#EnableJpaRepositories("com.techno.homes.repositories")
#SpringBootApplication
#EnableEurekaClient
#EnableResourceServer
#EnableSwagger2
#EnableOAuth2Client
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
Your Spring Boot version is too old for your Spring Cloud version:
https://github.com/spring-cloud/spring-cloud-commons/issues/552
Spring Cloud Greenwich (2.1.x) is not compatible with spring boot 2.0.x and spring framework 5.0.x. Either update spring boot or downgrade spring cloud to Finchley.
So please update Spring Boot to 2.1.x
PS: searching on 'BootstrapApplicationListener$CloseContextOnFailureApplicationListener' would have lead you there straight away :-)
Ok - did some testing here.
Created empty SpringBoot application from start.spring.io.
Imported the project into IntelliJ.
I then loaded your gradle file contents. Also started by removing all the # imports in the main (Application) class - just kept #SpringBootApplication.
Removed all the other classes (including tests).
Had same error.
Started by removing all the gradle dependencies for Swagger and Hibernate, etc. Those are not required to get a bare-bones SpringBoot app running.
Removing this line solved to error (not throwing the error anymore):
compile("org.springframework.security.oauth:spring-security-oauth2")
So something needs to be configured if you want to do Spring OAuth2 ... for you to find.
Suggest you add small building blocks at a time - you have a lot of stuff in the SpringBoot main app annotated. Spring will auto-configure defaults for all it can, but you might run into similar problems.
Add one annotation - write unit test class that will verify basic functionality of that specific annotation. Then enable the next one, write unit test.... unit all are working with basic test coverage.
This is because of spring and cloud version not compatible.
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.3.RELEASE</version>
<relativePath />
</parent>
The version of the parent should be an upgrade one or the same as cloud version.
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-oauth2</artifactId>
<version>2.1.3.RELEASE</version>
</dependency>

Gradle : Could not find org.codehaus.groovy:groovy:1.0.0

I am using gradle to compile my Groovy and Java code. today I update my groovy 2.5.4 and upgrade gradle to version 5.
gradle run command failing now with this error message.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileGroovy'.
> Could not resolve all files for configuration ':detachedConfiguration1'.
> Could not find org.codehaus.groovy:groovy:1.0.0.
Searched in the following locations:
- https://jcenter.bintray.com/org/codehaus/groovy/groovy/1.0.0/groovy-1.0.0.pom
- https://jcenter.bintray.com/org/codehaus/groovy/groovy/1.0.0/groovy-1.0.0.jar
- http://repository.apache.org/snapshots/org/codehaus/groovy/groovy/1.0.0/groovy-1.0.0.pom
- http://repository.apache.org/snapshots/org/codehaus/groovy/groovy/1.0.0/groovy-1.0.0.jar
Required by:
project :
* Try:
Here is the build.gradle file.
plugins {
id 'groovy'
id 'application'
}
repositories {
jcenter()
maven {
url "http://repository.apache.org/snapshots/"
}
}
dependencies {
// Use the latest Groovy version for building this library
implementation 'org.codehaus.groovy:groovy-all:2.5.4'
compile group: 'commons-cli', name: 'commons-cli', version: '1.4'
compile group: 'commons-io', name: 'commons-io', version: '2.6'
compile group: 'com.mashape.unirest', name: 'unirest-java', version: '1.4.9'
compile group: 'org.mongodb', name: 'mongo-java-driver', version: '3.6.1'
compile group: 'org.apache.directory', name: 'groovyldap', version: '0.1-SNAPSHOT'
// https://mvnrepository.com/artifact/ch.qos.logback/logback-classic
compile group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.3'
// https://mvnrepository.com/artifact/org.apache.directory.shared/shared-ldif
compile group: 'org.apache.directory.shared', name: 'shared-ldif', version: '0.9.19'
// https://mvnrepository.com/artifact/org.apache.directory.api/api-ldap-model
compile group: 'org.apache.directory.api', name: 'api-ldap-model', version: '1.0.0-M15'
// https://mvnrepository.com/artifact/com.opencsv/opencsv
compile group: 'com.opencsv', name: 'opencsv', version: '4.0'
// https://mvnrepository.com/artifact/org.jsoup/jsoup
compile group: 'org.jsoup', name: 'jsoup', version: '1.11.2'
compile group: 'mysql', name: 'mysql-connector-java', version: '8.0.11'
// https://mvnrepository.com/artifact/com.microsoft.sqlserver/mssql-jdbc
compile group: 'com.microsoft.sqlserver', name: 'mssql-jdbc', version: '6.4.0.jre8'
// https://mvnrepository.com/artifact/net.sourceforge.jtds/jtds
compile group: 'net.sourceforge.jtds', name: 'jtds', version: '1.3.1'
// https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient
compile group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.6'
// https://mvnrepository.com/artifact/org.yaml/snakeyaml
compile group: 'org.yaml', name: 'snakeyaml', version: '1.21'
// https://mvnrepository.com/artifact/com.rubiconproject.oss/jchronic
compile group: 'com.rubiconproject.oss', name: 'jchronic', version: '0.2.8'
compile group: 'io.github.http-builder-ng', name: 'http-builder-ng-core', version: '1.0.3'
// Use the awesome Spock testing and specification framework
testImplementation 'org.spockframework:spock-core:1.2-groovy-2.5'
}
// Define the main class for the application
mainClassName = 'ssl.test.App'
any help to resolve this error message?
Thanks
SR
You can replace your groovyldap dependency declaration with the following (as already mentioned by #paul-king in the comments):
compile(group: 'org.apache.directory', name: 'groovyldap', version: '0.1-SNAPSHOT') {
exclude group: 'groovy', module: 'groovy'
}
This will at least help you get rid of the dependency resolution error.
I don’t know if your groovyldap dependency will still work with Groovy 2.5.4 but it’s definitely worth a try.

SparkJava cannot work together with some Google Youtube API's

We decided to use SparkJava, Kotlin and Mustache for a commercial web product. And our product needs to be integrated with Google (YouTube) API’s.
The project’s all endpoints were working properly. (Backoffice, CRUD operations etc.) And we started to implement integrations of YouTube and I had to add Google libraries into my project for kickoff. (Not to add any of extra code, just added the library google-oauth-client-jetty.)
You can find my Gradle libraries below :
dependencies {
// Below library is a part of the requirements or YouTube Integration
compile group: 'com.google.oauth-client', name: 'google-oauth-client-jetty', version: '1.11.0-beta'
// And these are the others
compile fileTree(include: ['*.jar'], dir: 'lib')
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
compile group: 'com.sparkjava', name: 'spark-core', version: '2.7.0'
compile 'com.google.code.gson:gson:2.8.1'
compile group: 'commons-codec', name: 'commons-codec', version: '1.9'
compile 'com.github.jkcclemens:khttp:0.1.0' // -SNAPSHOT
compile 'com.beust:klaxon:0.30'
compile group: 'org.bouncycastle', name: 'bcprov-jdk15on', version: '1.58'
compile group: 'org.hibernate', name: 'hibernate-gradle-plugin', version: '5.2.10.Final'
compile group: 'org.hibernate', name: 'hibernate-core', version: '5.2.10.Final'
compile group: 'org.hibernate', name: 'hibernate-entitymanager', version: '5.2.10.Final'
compile group: 'org.hibernate', name: 'hibernate-validator', version: '6.0.0.CR3'
compile group: 'mysql', name: 'mysql-connector-java', version: '6.0.6'
compile group: 'org.hibernate', name: 'hibernate-c3p0', version: '4.1.0.Final'
compile 'io.sentry:sentry-log4j:1.4.0'
compile group: 'javax.mail', name: 'mail', version: '1.4.1'
compile group: 'org.apache.commons', name: 'commons-dbcp2', version: '2.0'
compile group: 'commons-validator', name: 'commons-validator', version: '1.4.0'
compile "org.testng:testng:6.9.10"
compile "org.apache.httpcomponents:httpclient:4.5.2"
compile "org.apache.httpcomponents:httpcore:4.4.4"
compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.0'
compile group: 'com.sparkjava', name: 'spark-template-mustache', version: '2.5.5'
compile group: 'org.slf4j', name: 'slf4j-simple', version: '1.7.25'
testCompile group: 'junit', name: 'junit', version: '4.11'
}
When I especially add library 'google-oauth-client-jetty', version: '1.11.0-beta’ into the project, I cannot reach the endpoints via http (GET, POST, PUT none of them). I enabled SparkJava's logs and I am facing with the logs below.
For example, I am calling
http://localhost:3000/admin
And the result is :
[qtp1864334028-15] WARN org.eclipse.jetty.server.HttpChannel - /admin
java.lang.NoSuchMethodError: javax.servlet.http.HttpServletResponse.getHeaders(Ljava/lang/String;)Ljava/util/Collection;
at spark.utils.GzipUtils.checkAndWrap(GzipUtils.java:67)
at spark.http.matching.Body.serializeTo(Body.java:69)
at spark.http.matching.MatcherFilter.doFilter(MatcherFilter.java:189)
at spark.embeddedserver.jetty.JettyHandler.doHandle(JettyHandler.java:50)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1568)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
at org.eclipse.jetty.server.Server.handle(Server.java:564)
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:317)
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:251)
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:279)
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:110)
at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:124)
at org.eclipse.jetty.util.thread.Invocable.invokePreferred(Invocable.java:128)
at org.eclipse.jetty.util.thread.Invocable$InvocableExecutor.invoke(Invocable.java:222)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:294)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.produce(EatWhatYouKill.java:126)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:673)
at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:591)
at java.lang.Thread.run(Thread.java:745)
As It seems, it is quite mandatory to use method "LocalServerReceiver() in the google-oauth-client-jetty library".
We need any help to move on.
I found the problem :
google-oauth-client-jetty (LocalServerReceiver) was using the org.mortbay.jetty which has the old version of servlet-api. (2.5.**)
I excluded and changed LocalServerReceiver class.. Put in my package. And changed jetty to org.eclipse.jetty.

Unable to compile jrxml containing highchart component with JasperCompileManager.compileReport()

I would like to compile a jrxml containing a highchart component (jasper pro) using Java.
Therefore I created a build.gradle with all the dependencies it requires.
My dependencies look like:
dependencies {
compile group: 'commons-beanutils', name: 'commons-beanutils', version: '1.9.3'
compile group: 'commons-collections', name: 'commons-collections', version: '3.2.2'
compile group: 'commons-digester', name: 'commons-digester', version: '2.1'
compile 'net.sf.jasperreports:jasperreports:6.3.1'
compile fileTree(dir: 'lib', include: '**/*.jar')
compile 'org.codehaus.groovy:groovy-all:2.4.1'
compile "org.spockframework:spock-core:1.1-groovy-2.4-rc-2"
testCompile 'junit:junit:4.12'
testCompile 'org.hamcrest:hamcrest-core:1.3'
compile group: 'joda-time', name: 'joda-time', version: '2.9.4'
compile group: 'commons-logging', name: 'commons-logging', version: '1.2'
compile group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: '2.8.4'
compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.8.4'
compile group: 'javax.servlet', name: 'javax.servlet-api', version: '3.1.0'
compile group: 'org.mozilla', name: 'rhino', version: '1.7.7.1'
compile group: 'jfree', name: 'jfreechart', version: '1.0.13'
compile group: 'org.olap4j', name: 'olap4j', version: '1.2.0'
compile group: 'bouncycastle', name: 'bcprov-jdk14', version: '1.50'
compile group: 'com.lowagie', name: 'itext', version: '2.1.7'
}
The JasperReports pro libraries are located in lib.
But I got stuck when compiling as it says the license file is invalid.
I am using my jasperserver.licence file, but somehow it is not capable in reading it properly
net.sf.jasperreports.engine.JRException: Error compiling report design.
at net.sf.jasperreports.engine.design.JRAbstractCompiler.compileReport(JRAbstractCompiler.java:247)
at net.sf.jasperreports.engine.JasperCompileManager.compile(JasperCompileManager.java:357)
at net.sf.jasperreports.engine.JasperCompileManager.compile(JasperCompileManager.java:290)
at net.sf.jasperreports.engine.JasperCompileManager.compileReport(JasperCompileManager.java:575)
at ch.prospective.jasperreports.wekklyreports.WeeklyReports.fetch report(WeeklyReports.groovy:16)
Caused by: com.jaspersoft.jasperreports.license.LicenseException: License is in invalid state
at com.jaspersoft.jasperreports.license.BaseLicenseProviderImpl.requireLicense(BaseLicenseProviderImpl.java:189)
at com.jaspersoft.jasperreports.license.BaseLicenseProviderImpl.requireFeature(BaseLicenseProviderImpl.java:196)
at com.jaspersoft.jasperreports.license.LicenseManager.requireFeature(LicenseManager.java:113)
at com.jaspersoft.jasperreports.highcharts.HighChartsUtils.requireHighchartsFeature(HighChartsUtils.java:43)
at com.jaspersoft.jasperreports.highcharts.charts.StandardChartComponent.(StandardChartComponent.java:73)
at com.jaspersoft.jasperreports.highcharts.charts.ChartCompiler.toCompiledComponent(ChartCompiler.java:69)
at net.sf.jasperreports.engine.base.JRBaseComponentElement.(JRBaseComponentElement.java:59)
at net.sf.jasperreports.engine.base.JRBaseObjectFactory.visitComponentElement(JRBaseObjectFactory.java:1736)
at net.sf.jasperreports.engine.design.JRDesignComponentElement.visit(JRDesignComponentElement.java:105)
at net.sf.jasperreports.engine.JRAbstractObjectFactory.getVisitResult(JRAbstractObjectFactory.java:88)
at net.sf.jasperreports.engine.base.JRBaseElementGroup.(JRBaseElementGroup.java:83)
at net.sf.jasperreports.engine.base.JRBaseBand.(JRBaseBand.java:84)
at net.sf.jasperreports.engine.base.JRBaseObjectFactory.getBand(JRBaseObjectFactory.java:533)
at net.sf.jasperreports.engine.base.JRBaseReport.(JRBaseReport.java:242)
Does someone have got experience in this ?
I've linked the whole project to this question as zip file. Just extract and run.
The zip file can be found here:
https://www.dropbox.com/s/1zvbjgehtnfc1wn/jasper-reports-with-highcharts.zip?dl=0
Simply call
gradle test
or run the testcase within your IDE.

Categories

Resources