bowman
bowman copied to clipboard
Client incompatible with Spring Boot 2.6
The Bowman client is not compatible with Spring Boot versions 2.6 and later. The ResourceDeserializer class references an EntityModel constructor that was deprecated in Spring HATEOAS 1.1 and removed in Spring HATEOAS 1.4. Spring Boot 2.6 uses this new version of Spring HATEOAS.
class uk.co.blackpepper.bowman.ResourceDeserializer tried to access protected method org.springframework.hateoas.EntityModel.<init>(Ljava/lang/Object;Ljava/lang/Iterable;)V (uk.co.blackpepper.bowman.ResourceDeserializer and org.springframework.hateoas.EntityModel are in unnamed module of loader 'app')
java.lang.IllegalAccessError: class uk.co.blackpepper.bowman.ResourceDeserializer tried to access protected method org.springframework.hateoas.EntityModel.<init>(Ljava/lang/Object;Ljava/lang/Iterable;)V (uk.co.blackpepper.bowman.ResourceDeserializer and org.springframework.hateoas.EntityModel are in unnamed module of loader 'app')
at uk.co.blackpepper.bowman.ResourceDeserializer.deserialize(ResourceDeserializer.java:52)
at uk.co.blackpepper.bowman.ResourceDeserializer.deserialize(ResourceDeserializer.java:21)
at com.fasterxml.jackson.databind.ObjectMapper._convert(ObjectMapper.java:4389)
at com.fasterxml.jackson.databind.ObjectMapper.convertValue(ObjectMapper.java:4345)
at uk.co.blackpepper.bowman.RestOperations.getResource(RestOperations.java:58)
at uk.co.blackpepper.bowman.Client.get(Client.java:80)
at com.example.issue.BowmanBootIssueTest.request(BowmanBootIssueTest.java:21)
To Reproduce
build.gradle
plugins {
id 'org.springframework.boot' version '2.6.1' // Works if changed to 2.5.7
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
id 'java'
}
group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter'
implementation 'uk.co.blackpepper.bowman:bowman-client:0.9.0'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
test {
useJUnitPlatform()
}
import uk.co.blackpepper.bowman.annotation.RemoteResource;
@RemoteResource("/users")
public class User {
private Integer id;
public Integer getId() { return id; }
public void setId(Integer id) { this.id = id; }
}
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import uk.co.blackpepper.bowman.Client;
import uk.co.blackpepper.bowman.ClientFactory;
import uk.co.blackpepper.bowman.Configuration;
import java.net.URI;
@SpringBootTest
class BowmanBootIssueTest {
@Test
void request() {
ClientFactory clientFactory = Configuration.builder()
.setBaseUri("http://reqres.in/api").build().buildClientFactory();
Client<User> userClient = clientFactory.create(User.class);
// Not actually HAL, but this still triggers the IllegalAccessError
userClient.get(URI.create("http://reqres.in/api/users/2"));
}
}