failed to build spingboot with swagger 2.0 - spring-boot

I am relatively new to spring. I tried to add API documentation with Swagger-2.0 and I no longer able to build
I failed to build with "gradlew build"
> getProductById FAILED
java.lang.IllegalStateException
Caused by: org.springframework.context.ApplicationContextException
Caused by: java.lang.NoSuchMethodError
Caused by: org.springframework.context.ApplicationContextException: Failed to start bean 'documentationPluginsBootstrapper'; nested exception is java.lang.NoSuchMethodError: 'org.springframework.plugin.core.Plugin org.springframework.plugin.core.PluginRegistry.getPluginOrDefaultFor(java.lang.Object, org.springframework.plugin.core.Plugin)'
Caused by: java.lang.NoSuchMethodError: 'org.springframework.plugin.core.Plugin org.springframework.plugin.core.PluginRegistry.getPluginOrDefaultFor(java.lang.Object, org.springframework.plugin.core.Plugin)'
In build.gradle I added :
repositories {
mavenCentral()
maven { url "https://repo.spring.io/snapshot" }
maven { url "https://repo.spring.io/milestone" }
maven { url 'http://oss.jfrog.org/artifactory/oss-snapshot-local/' }
}
dependencies {
implementation project(':api')
implementation project(':util')
implementation('org.springframework.boot:spring-boot-starter-actuator')
implementation('org.springframework.boot:spring-boot-starter-webflux')
implementation('io.springfox:springfox-swagger2:3.0.0-SNAPSHOT')
implementation('io.springfox:springfox-swagger-ui:3.0.0-SNAPSHOT')
implementation('io.springfox:springfox-spring-webflux:3.0.0-SNAPSHOT')
testImplementation('org.springframework.boot:spring-boot-starter-test')
testImplementation('io.projectreactor:reactor-test')
}
Where should I look to find the root cause ?

Related

Gradle build fails with MalformedJsonException

After the migration from jcenter to maven-central repository, like
//from
repositories {
jcenter()
}
//to
repositories {
mavenCentral()
}
I got:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':my-module:compileJava'.
...
Caused by: org.gradle.api.internal.artifacts.ivyservice.DefaultLenientConfiguration$ArtifactResolveException: Could not resolve all files for configuration ':my-module:compileClasspath'.
...
project :my-module > org.junit.jupiter:junit-jupiter-api:5.7.1 > org.junit:junit-bom:5.7.1
Caused by: org.gradle.internal.resolve.ModuleVersionResolveException: Could not resolve org.junit.jupiter:junit-jupiter-params:5.7.1.
Caused by: org.gradle.api.internal.artifacts.ivyservice.ivyresolve.parser.MetaDataParseException: Could not parse module metadata https://everon.jfrog.io/everon/libs-release/org/junit/jupiter/junit-jupiter-params/5.7.1/junit-jupiter-params-5.7.1.module
How to fix it?
After the change, Gradle misused the metadata file and the solution would be to explicitly declare artifacts metadata sources:
repositories {
maven {
metadataSources {
mavenPom() //use maven pom
artifact() //look directly for the artifact
ignoreGradleMetadataRedirection() //it fixes the issue actually
}
}
}
See https://docs.gradle.org/current/userguide/dependency_management.html#sec:supported_metadata_sources for more

Failed to initialize CastContext in exoplayer

I tried exoplayer-cast demo app and it was working fine, then i added demo files in my project i get following error
i keep on getting following error i used same dependencies from exoplayer-cast demo app to my app but still i keep getting error and app crashes on start.
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.exocastplayer/com.example.exocastplayer.MainActivity}: java.lang.IllegalStateException: Failed to initialize CastContext.
2021-09-25 09:29:44.379 26831-26831/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.exocastplayer, PID: 26831
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.exocastplayer/com.example.exocastplayer.MainActivity}: java.lang.IllegalStateException: Failed to initialize CastContext.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3303)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3411)
at android.app.ActivityThread.-wrap12(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1994)
at android.os.Handler.dispatchMessage(Handler.java:108)
at android.os.Looper.loop(Looper.java:166)
at android.app.ActivityThread.main(ActivityThread.java:7529)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:245)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:921)
Caused by: java.lang.IllegalStateException: Failed to initialize CastContext.
at com.google.android.gms.cast.framework.CastContext.zzg(com.google.android.gms:play-services-cast-framework##20.0.0:11)
at com.google.android.gms.cast.framework.CastContext.getSharedInstance(com.google.android.gms:play-services-cast-framework##20.0.0:4)
at com.example.exocastplayer.MainActivity.onCreate(MainActivity.java:69)
at android.app.Activity.performCreate(Activity.java:7383)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1218)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3256)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3411) 
at android.app.ActivityThread.-wrap12(Unknown Source:0) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1994) 
at android.os.Handler.dispatchMessage(Handler.java:108) 
at android.os.Looper.loop(Looper.java:166) 
at android.app.ActivityThread.main(ActivityThread.java:7529) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:245) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:921) 
Caused by: java.lang.ClassNotFoundException: com.example.exocastplayer.DefaultCastOptionsProvider
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:453)
at java.lang.Class.forName(Class.java:378)
at com.google.android.gms.cast.framework.CastContext.zzg(com.google.android.gms:play-services-cast-framework##20.0.0:7)
at com.google.android.gms.cast.framework.CastContext.getSharedInstance(com.google.android.gms:play-services-cast-framework##20.0.0:4) 
at com.example.exocastplayer.MainActivity.onCreate(MainActivity.java:69) 
at android.app.Activity.performCreate(Activity.java:7383) 
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1218) 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3256) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3411) 
at android.app.ActivityThread.-wrap12(Unknown Source:0) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1994) 
at android.os.Handler.dispatchMessage(Handler.java:108) 
at android.os.Looper.loop(Looper.java:166) 
at android.app.ActivityThread.main(ActivityThread.java:7529) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:245) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:921) 
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.exocastplayer.DefaultCastOptionsProvider" on path: DexPathList[[zip file "/data/app/com.example.exocastplayer-UGhOFJxDWgemfANNsc8fww==/base.apk"],nativeLibraryDirectories=[/data/app/com.example.exocastplayer-UGhOFJxDWgemfANNsc8fww==/lib/arm64, /system/lib64, /vendor/lib64, /product/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:93)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at java.lang.Class.classForName(Native Method) 
at java.lang.Class.forName(Class.java:453) 
at java.lang.Class.forName(Class.java:378) 
at com.google.android.gms.cast.framework.CastContext.zzg(com.google.android.gms:play-services-cast-framework##20.0.0:7) 
at com.google.android.gms.cast.framework.CastContext.getSharedInstance(com.google.android.gms:play-services-cast-framework##20.0.0:4) 
at com.example.exocastplayer.MainActivity.onCreate(MainActivity.java:69) 
at android.app.Activity.performCreate(Activity.java:7383) 
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1218) 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3256) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3411) 
at android.app.ActivityThread.-wrap12(Unknown Source:0) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1994) 
at android.os.Handler.dispatchMessage(Handler.java:108) 
at android.os.Looper.loop(Looper.java:166) 
at android.app.ActivityThread.main(ActivityThread.java:7529) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:245) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:921) 
and here is my project gradle and app gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath "com.android.tools.build:gradle:7.0.2"
//classpath "com.google.gms:google-services:4.3.10"
classpath 'com.google.android.gms:strict-version-matcher-plugin:1.2.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
App gradle :
plugins {
id 'com.android.application'
}
android {
compileSdk 31
defaultConfig {
applicationId "com.example.exocastplayer"
minSdk 21
targetSdk 31
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.1'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
def exoplayerVersion = '2.15.1'
implementation "com.google.android.exoplayer:exoplayer-core:$exoplayerVersion"
implementation "com.google.android.exoplayer:exoplayer-ui:$exoplayerVersion"
implementation "com.google.android.exoplayer:extension-cast:$exoplayerVersion"
}
apply plugin: 'com.google.android.gms.strict-version-matcher-plugin'

org.spockframework.runtime.SpockEngine Unable to get public no-arg constructor encountered while upgrading Groovy and Spock

Using Gradle 7.1.1, Java 16, Groovy 3.0.8 and Spock 2.0-groovy-3.0
I'm getting this error when running ./gradlew clean test
Caused by: java.util.ServiceConfigurationError: org.junit.platform.engine.TestEngine: org.spockframework.runtime.SpockEngine Unable to get public no-arg constructor
at java.base/java.util.ServiceLoader.fail(ServiceLoader.java:582)
at java.base/java.util.ServiceLoader.getConstructor(ServiceLoader.java:673)
at java.base/java.util.ServiceLoader$LazyClassPathLookupIterator.hasNextService(ServiceLoader.java:1232)
at java.base/java.util.ServiceLoader$LazyClassPathLookupIterator.hasNext(ServiceLoader.java:1264)
at java.base/java.util.ServiceLoader$2.hasNext(ServiceLoader.java:1299)
at java.base/java.util.ServiceLoader$3.hasNext(ServiceLoader.java:1383)
at java.base/java.lang.Iterable.forEach(Iterable.java:74)
at org.junit.platform.launcher.core.LauncherFactory.create(LauncherFactory.java:95)
at org.junit.platform.launcher.core.LauncherFactory.create(LauncherFactory.java:75)
at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor$CollectAllTestClassesExecutor.processAllTestClasses(JUnitPlatformTestClassProcessor.java:97)
at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor$CollectAllTestClassesExecutor.access$000(JUnitPlatformTestClassProcessor.java:79)
at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor.stop(JUnitPlatformTestClassProcessor.java:75)
at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.stop(SuiteTestClassProcessor.java:61)
... 25 more
Caused by: java.lang.NoClassDefFoundError: org/junit/platform/engine/support/discovery/SelectorResolver
at java.base/java.lang.Class.getDeclaredConstructors0(Native Method)
at java.base/java.lang.Class.privateGetDeclaredConstructors(Class.java:3305)
at java.base/java.lang.Class.getConstructor0(Class.java:3510)
at java.base/java.lang.Class.getConstructor(Class.java:2238)
at java.base/java.util.ServiceLoader$1.run(ServiceLoader.java:660)
at java.base/java.util.ServiceLoader$1.run(ServiceLoader.java:657)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:554)
at java.base/java.util.ServiceLoader.getConstructor(ServiceLoader.java:668)
... 36 more
Caused by: java.lang.ClassNotFoundException: org.junit.platform.engine.support.discovery.SelectorResolver
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:636)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:182)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:519)
... 44 more
This is the build.gradle for the module where error is reported:
dependencies {
implementation 'io.rest-assured:rest-assured'
implementation 'org.yaml:snakeyaml'
implementation 'com.fasterxml.jackson.core:jackson-databind'
testImplementation 'org.junit.jupiter:junit-jupiter'
testImplementation('org.spockframework:spock-core') {
transitive = false
}
}
Parent module build.gradle file:
ext {
jupiterVersion = '5.7.2'
}
jar.enabled = false
subprojects {
apply plugin: 'java'
apply plugin: 'groovy'
apply plugin: 'codenarc'
jar.enabled = true
codenarc {
toolVersion = '1.4'
reportFormat = 'html'
configFile = new File('../../tool/codenarc/groovy-ruleset.groovy')
}
dependencyManagement {
imports {
mavenBom("org.springframework.boot:spring-boot-dependencies:2.5.1") {
bomProperties(['selenium.version' : '3.141.59',
'rest-assured.version': '4.1.1'])
}
}
dependencies {
dependency 'org.codehaus.groovy.modules.http-builder:http-builder:0.7.1'
dependency 'org.spockframework:spock-core:2.0-groovy-3.0'
dependency 'com.athaydes:spock-reports:2.0-groovy-3.0'
dependency 'com.codeborne:selenide:5.3.1'
dependency 'org.hamcrest:hamcrest:2.1'
dependencySet(group: 'org.junit.jupiter', version: jupiterVersion) {
entry 'junit-jupiter'
entry 'junit-jupiter-api'
}
dependencySet(group: 'org.slf4j', version: '1.7.28') {
entry 'jcl-over-slf4j'
entry 'jul-to-slf4j'
}
dependencySet(group: 'org.aspectj', version: '1.9.4') {
entry 'aspectjrt'
entry 'aspectjweaver'
}
dependency 'io.rest-assured:rest-assured:4.1.1'
dependency 'org.postgresql:postgresql:42.2.8'
dependency 'org.yaml:snakeyaml:1.25'
dependency 'org.apache.poi:poi-ooxml:4.1.1'
dependency 'com.opencsv:opencsv:4.0'
dependency 'org.junit.platform:junit-platform-launcher:1.4.0'
}
}
test {
useJUnitPlatform()
}
}
Any help would be appreciated.
PS. This was working with Java 11, Groovy 2.5 and Spock 1.3-groovy-2.5
Have you added useJUnitPlatform()?
https://github.com/spockframework/spock-example/blob/master/build.gradle#L34
test {
useJUnitPlatform()
}
It was a problem with the parent project's build.gradle file.
I recently upgraded the spring boot version to 2.5.1.
After updating this entry in the build.gradle file the error went away.
imports {
mavenBom("org.springframework.boot:spring-boot-dependencies:2.5.1") {
bomProperties(['selenium.version' : '3.141.59',
'rest-assured.version': '4.1.1'])
}
}

Quarkus - Unsatisfied dependency for type org.eclipse.microprofile.jwt

I was trying to implement the JWT token for one my Quarkus application but somehow getting an exception - Unsatisfied dependency for type org.eclipse.microprofile.jwt.JsonWebToken and qualifiers [#Default]
My Quarkus application is fairly simple and having one rest endpoint -
#Path("/jwt")
#RequestScoped
public class JWTRestController {
#Inject
JsonWebToken jwt;
#GET()
#Path("permit-all")
#PermitAll
#Produces(MediaType.TEXT_PLAIN)
public String hello(#Context SecurityContext ctx) {
Principal caller = ctx.getUserPrincipal();
String name = caller == null ? "anonymous" : caller.getName();
String helloReply = String.format("hello + %s, isSecure: %s, authScheme: %s", name, ctx.isSecure(), ctx.getAuthenticationScheme());
return helloReply;
}
}
But when i try to run my quarkus application -
gradlew quarkusDev
Log stacktrace
> Task :quarkusDev
Port 5005 in use, not starting in debug mode
2020-04-05 15:57:49,789 INFO [org.jbo.threads] (main) JBoss Threads version 3.0.1.Final
2020-04-05 15:57:50,158 ERROR [io.qua.dev.DevModeMain] (main) Failed to start Quarkus: java.lang.RuntimeException: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
[error]: Build step io.quarkus.arc.deployment.ArcProcessor#validate threw an exception: javax.enterprise.inject.spi.DeploymentException: javax.enterprise.inject.UnsatisfiedResolutionException: Unsatisfied dependency for type org.eclipse.microprofile.jwt.JsonWebToken and qual
ifiers [#Default]
- java member: com.jhooq.JWTRestController#jwt
- declared on CLASS bean [types=[com.jhooq.JWTRestController, java.lang.Object], qualifiers=[#Default, #Any], target=com.jhooq.JWTRestController]
at io.quarkus.arc.processor.BeanDeployment.processErrors(BeanDeployment.java:910)
at io.quarkus.arc.processor.BeanDeployment.init(BeanDeployment.java:232)
at io.quarkus.arc.processor.BeanProcessor.initialize(BeanProcessor.java:130)
at io.quarkus.arc.deployment.ArcProcessor.validate(ArcProcessor.java:291)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
Am i really missing something here?
Here is my build.gradle
plugins {
id 'java'
id 'io.quarkus'
}
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
implementation enforcedPlatform("${quarkusPlatformGroupId}:${quarkusPlatformArtifactId}:${quarkusPlatformVersion}")
implementation 'io.quarkus:quarkus-resteasy'
testImplementation 'io.quarkus:quarkus-junit5'
testImplementation 'io.rest-assured:rest-assured'
testImplementation 'io.quarkus:quarkus-smallrye-jwt'
testImplementation 'io.quarkus:quarkus-resteasy-jsonb'
implementation 'org.eclipse.microprofile.jwt:microprofile-jwt-auth-api:1.1.1'
}
group 'com.jhooq'
version '1.0.0-SNAPSHOT'
compileJava {
options.compilerArgs << '-parameters'
}
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
The problem lies here:
testImplementation 'io.quarkus:quarkus-smallrye-jwt'
testImplementation 'io.quarkus:quarkus-resteasy-jsonb'
implementation 'org.eclipse.microprofile.jwt:microprofile-jwt-auth-api:1.1.1'
The quarkus-smallrye-jwt and quarkus-resteasy-jsonb dependencies are part of the application, not part of tests. These must be implementation, not testImplementation.
At the same time, you can remove implementation 'org.eclipse.microprofile.jwt:microprofile-jwt-auth-api:1.1.1', this it's brought in transitively by quarkus-smallrye-jwt.

Spring Data Rest and spring-data-rest-hal-browser integration using Spring Boot

Problem
The Spring Data REST Reference Documentation says that
dependencies {
compile 'org.springframework.data:spring-data-rest-hal-browser'
}
is enough to integrate HAL browser with Spring Data Rest while using Spring Boot but Gradle complains this dependency cannot be found unless I specify particular version so I fixed it by specifying the latest one available in central repository (there is no other version available in the repository). After specifying the version the dependency is resolved but I get an error during Spring Boot container initialization:
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.data.repository.support.Repositories]: Factory method 'repositories' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cameraRepository': Invocation of init method failed; nested exception is java.lang.AbstractMethodError: org.springframework.data.repository.core.support.RepositoryFactorySupport.getTargetRepository(Lorg/springframework/data/repository/core/RepositoryInformation;)Ljava/lang/Object;
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588)
... 151 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cameraRepository': Invocation of init method failed; nested exception is java.lang.AbstractMethodError: org.springframework.data.repository.core.support.RepositoryFactorySupport.getTargetRepository(Lorg/springframework/data/repository/core/RepositoryInformation;)Ljava/lang/Object;
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1572)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:966)
at org.springframework.data.repository.support.Repositories.cacheRepositoryFactory(Repositories.java:95)
at org.springframework.data.repository.support.Repositories.populateRepositoryFactoryInformation(Repositories.java:88)
at org.springframework.data.repository.support.Repositories.<init>(Repositories.java:81)
at org.springframework.data.rest.webmvc.config.RepositoryRestMvcConfiguration.repositories(RepositoryRestMvcConfiguration.java:182)
at org.springframework.boot.autoconfigure.data.rest.SpringBootRepositoryRestMvcConfiguration$$EnhancerBySpringCGLIB$$b6ea42c0.CGLIB$repositories$11(<generated>)
at org.springframework.boot.autoconfigure.data.rest.SpringBootRepositoryRestMvcConfiguration$$EnhancerBySpringCGLIB$$b6ea42c0$$FastClassBySpringCGLIB$$ec6a4119.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:309)
at org.springframework.boot.autoconfigure.data.rest.SpringBootRepositoryRestMvcConfiguration$$EnhancerBySpringCGLIB$$b6ea42c0.repositories(<generated>)
at sun.reflect.NativeMetssorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162)
... 152 more
Caused by: java.lang.AbstractMethodError: org.springframework.data.repository.core.support.RepositoryFactorySupport.getTargetRepository(Lorg/springframework/data/repository/core/RepositoryInformation;)Ljava/lang/Object;
at org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:185)
at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.initAndReturn(RepositoryFactoryBeanSupport.java:251)
at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.afterPropertiesSet(RepositoryFactoryBeanSupport.java:237)
at org.springframework.data.jpa.repository.support.JpaRepositoryFactoryBean.afterPropertiesSet(JpaRepositoryFactoryBean.java:92)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1631)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1568)
... 173 more
However my application initializes successfully and works as expected if I remove spring-data-rest-hal-browser:2.4.0.RELEASE dependency.
Question
How can I setup my build.gradle correctly to have my application integrated with HAL browser properly?
build.gradle
buildscript {
ext {
springBootVersion = '1.2.7.RELEASE'
}
repositories {
mavenCentral()
}
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
classpath('io.spring.gradle:dependency-management-plugin:0.5.2.RELEASE')
}
[...]
repositories {
mavenCentral()
flatDir {
dirs 'lib'
}
}
dependencies {
compile('org.springframework.boot:spring-boot-starter-actuator')
compile('org.springframework.boot:spring-boot-starter-data-jpa')
compile('org.springframework.boot:spring-boot-starter-data-rest')
compile('org.springframework.boot:spring-boot-starter-remote-shell')
compile('org.springframework.data:spring-data-rest-hal-browser:2.4.0.RELEASE')
compile('org.projectlombok:lombok:1.16.6')
compile name: 'ojdbc6'
testCompile('org.springframework.boot:spring-boot-starter-test')
testCompile('org.springframework.restdocs:spring-restdocs-mockmvc:1.0.0.RELEASE')
}
The automatic version management for the HAL browser only works starting with Spring Boot 1.3.0 which is at the release candidate stage and should be released very soon. The release candidate is very stable for me, so you may consider giving that a try by updating your build to 1.3.0.RC1 which I would expect would fix the issue, something like this:
buildscript {
ext {
springBootVersion = '1.3.0.RC1'
}
repositories {
mavenCentral()
maven { url 'https://repo.spring.io/milestone/' }
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
classpath "io.spring.gradle:dependency-management-plugin:0.5.2.RELEASE"
}
}
repositories {
mavenCentral()
flatDir {
dirs 'lib'
}
}
dependencies {
compile('org.springframework.boot:spring-boot-starter-actuator')
compile('org.springframework.boot:spring-boot-starter-data-jpa')
compile('org.springframework.boot:spring-boot-starter-data-rest')
compile('org.springframework.boot:spring-boot-starter-remote-shell')
compile('org.springframework.data:spring-data-rest-hal-browser')
compile('org.projectlombok:lombok:1.16.6')
compile name: 'ojdbc6'
testCompile('org.springframework.boot:spring-boot-starter-test')
testCompile('org.springframework.restdocs:spring-restdocs-mockmvc')
}
You can see the managed dependency versions for 1.3.0.RC1 here:
http://docs.spring.io/spring-boot/docs/1.3.0.RC1/reference/htmlsingle/#appendix-dependency-versions
You'll notice if you look at the managed dependency versions for 1.2.7 that neither spring-data-rest-hal-browser nor spring-restdocs-mockmvc are present.
The package was renamed to spring-data-rest-hal-explorer. Here's an example of a modern configuration of HAL with Spring Boot 2 with automatic version management.
Maven example:
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-rest-hal-explorer</artifactId>
</dependency>
Gradle example:
plugins {
id "io.spring.dependency-management" version <<version>>
}
dependencies {
implementation('org.springframework.data:spring-data-rest-hal-explorer')
}

Resources