Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Spring Boot 2.2.0 #71

Closed
paulcwarren opened this issue May 13, 2019 · 16 comments
Closed

Add support for Spring Boot 2.2.0 #71

paulcwarren opened this issue May 13, 2019 · 16 comments

Comments

@paulcwarren
Copy link
Owner

paulcwarren commented May 13, 2019

@arya6000 raised this issue against spring-content-examples.

We should prep for and add support Spring Boot 2.2.0. However, 2.2.0 depends on Spring Moore which depends on spring-hateoas 1.0.0 with a significantly updated API that is backward incompatible with older versions.

@paulcwarren
Copy link
Owner Author

paulcwarren commented Jun 15, 2019

I decided that I am going to release this as a 1.0.0.M1 when ready. A 1.0 is probably overdue, at least from a functionality perspective. Before releasing a 1.0 I did want to clean up the REST module amongst other things BUT if we are to support SB 2.2.0 which pulls in spring-hateoas and its breaking changes I need to get onto a versioning strategy where we can mirror real the spring projects. Makes sense to just do that now.

@paulcwarren
Copy link
Owner Author

paulcwarren commented Jun 15, 2019

Currently blocked on DATAREST-1397.

/cc @arya6000

@davidmacsix
Copy link

Hi @paulcwarren ,
I've just recently integrated spring-content into my current project. It's amazing, and saved me a ton of work! Thanks for your efforts.

However, to get round an issue in spring-data-rest, I'm looking to upgrade to Spring Boot 2.2 M1. Do you have an idea of when support might be added?

Thanks.

David.

@paulcwarren
Copy link
Owner Author

Hi @Davidm76,

Firstly, thanks for using Spring Content.

Unfortunately, Spring Boot 2.2.M1 has the aforementioned but above (DATAREST-1397).

That said, 2.2 M5 depends on Spring Data Moore RC2 that, I believe, will have the bug fix for DATAREST-1397.

So, I think we would be in a position to release our 1.0.0.M1 based on 2.2M5 and Moore RC2. This will presumably have the bug fix you need to. Is there a reason you wanted to pin to 2.2.M1? Or is 2.2.M5 fine too?

@davidmacsix
Copy link

Thanks for getting back to me @paulcwarren . Yes, 2.2.M5 would work. M1 was I typo!
Cheers.
David.

@paulcwarren
Copy link
Owner Author

paulcwarren commented Aug 6, 2019

OK. Sounds good. So, I've got an upcoming 0.10.0 release. Then I'll merge the 0.10.0 changes across and do a 1.0.0.M1 release for you. Give me a couple of weeks to tidy some things up.

@davidmacsix
Copy link

Thanks @paulcwarren , it's very much appreciated.

@paulcwarren
Copy link
Owner Author

Spring Content 1.0.0.M1 is now available supporting Spring Boot 2.2. Please let me know if you have any problems consuming it, or if this doesn't address your needs as you expected.

cc/ @Davidm76, @arya6000.

@davidmacsix
Copy link

Thanks @paulcwarren
I'll give it a try.

@davidmacsix
Copy link

Hi @paulcwarren ,

I've upgraded my POM as follows:

   <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.2.0.M5</version>
    </parent>
     <dependency>
            <groupId>com.github.paulcwarren</groupId>
            <artifactId>spring-content-fs-boot-starter</artifactId>
            <version>1.0.0.M1</version>
        </dependency>
        <dependency>
            <groupId>com.github.paulcwarren</groupId>
            <artifactId>spring-content-rest-boot-starter</artifactId>
            <version>1.0.0.M1</version>
        </dependency>
        <dependency>
            <groupId>com.github.paulcwarren</groupId>
            <artifactId>spring-content-jpa</artifactId>
            <version>1.0.0.M1</version>
        </dependency>

I no longer get the ClassNotFoundException, which is great, however, my ContentStore bean does not seems to have been created.

I have the following ContentStore:

@StoreRestResource
public interface ScaleableVectorContentStore extends ContentStore<SymbolVector, String> {
}

However, the allocation fails to start:

***************************
APPLICATION FAILED TO START
***************************

Description:

Parameter 6 of constructor in com.yambay.vizserver.services.SymbolService required a bean of type 'com.yambay.vizserver.domain.repositories.ScaleableVectorContentStore' that could not be found.


Action:

Consider defining a bean of type 'com.yambay.vizserver.domain.repositories.ScaleableVectorContentStore' in your configuration.


Process finished with exit code 1

It looks like the interface hasn't been inflated.

Any ideas?

Thanks.

David.

@paulcwarren
Copy link
Owner Author

We recently added strict resolution mode to allow multiple Store modules (of different types) to be used at once.

So the one thing I can spot from your snippets above is that you are including spring-content-fs-boot-starter and spring-content-jpa; i.e. you have two storage modules on your classpath. SC will, therefore, enter strict resolution mode.

But at the same time you have defined ScaleableVectorContentStore to extend ContentStore.

So I believe SC will be unable to determine which storage module that you wish to use, and rather than make an artibtrary choice that might be wrong, instead won't use any.

If you don't need both then you could try removing one of the storage modules from the classpath, or make your Store extend either FilesystemContentStore or JpaContentStore to tell SC with storage module you want this store to implement.

Let me know if this works.

@davidmacsix
Copy link

Hi @paulcwarren

I tried removing spring-content-fs-boot-starter.

If I do that the application fails to start with the following exception:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'halLinkDisocoverer' defined in class path resource [org/springframework/hateoas/mediatype/hal/HalMediaTypeConfiguration.class]: Post-processing of merged bean definition failed; nested exception is java.lang.IllegalStateException: Failed to introspect Class [org.springframework.hateoas.client.JsonPathLinkDiscoverer] from ClassLoader [sun.misc.Launcher$AppClassLoader@18b4aac2]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:572) ~[spring-beans-5.2.0.RC1.jar:5.2.0.RC1]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517) ~[spring-beans-5.2.0.RC1.jar:5.2.0.RC1]
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323) ~[spring-beans-5.2.0.RC1.jar:5.2.0.RC1]
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.2.0.RC1.jar:5.2.0.RC1]
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321) ~[spring-beans-5.2.0.RC1.jar:5.2.0.RC1]
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-5.2.0.RC1.jar:5.2.0.RC1]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:877) ~[spring-beans-5.2.0.RC1.jar:5.2.0.RC1]
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:877) ~[spring-context-5.2.0.RC1.jar:5.2.0.RC1]
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549) ~[spring-context-5.2.0.RC1.jar:5.2.0.RC1]
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141) ~[spring-boot-2.2.0.M5.jar:2.2.0.M5]
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:746) [spring-boot-2.2.0.M5.jar:2.2.0.M5]
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:396) [spring-boot-2.2.0.M5.jar:2.2.0.M5]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) [spring-boot-2.2.0.M5.jar:2.2.0.M5]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1225) [spring-boot-2.2.0.M5.jar:2.2.0.M5]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1214) [spring-boot-2.2.0.M5.jar:2.2.0.M5]
	at com.yambay.vizserver.VizServerApplication.main(VizServerApplication.java:43) [classes/:na]
Caused by: java.lang.IllegalStateException: Failed to introspect Class [org.springframework.hateoas.client.JsonPathLinkDiscoverer] from ClassLoader [sun.misc.Launcher$AppClassLoader@18b4aac2]
	at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:476) ~[spring-core-5.2.0.RC1.jar:5.2.0.RC1]
	at org.springframework.util.ReflectionUtils.doWithLocalMethods(ReflectionUtils.java:317) ~[spring-core-5.2.0.RC1.jar:5.2.0.RC1]
	at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.buildPersistenceMetadata(PersistenceAnnotationBeanPostProcessor.java:437) ~[spring-orm-5.2.0.RC1.jar:5.2.0.RC1]
	at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.findPersistenceMetadata(PersistenceAnnotationBeanPostProcessor.java:408) ~[spring-orm-5.2.0.RC1.jar:5.2.0.RC1]
	at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.postProcessMergedBeanDefinition(PersistenceAnnotationBeanPostProcessor.java:335) ~[spring-orm-5.2.0.RC1.jar:5.2.0.RC1]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyMergedBeanDefinitionPostProcessors(AbstractAutowireCapableBeanFactory.java:1095) ~[spring-beans-5.2.0.RC1.jar:5.2.0.RC1]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:569) ~[spring-beans-5.2.0.RC1.jar:5.2.0.RC1]
	... 15 common frames omitted
Caused by: java.lang.NoClassDefFoundError: com/jayway/jsonpath/JsonPath
	at java.lang.Class.getDeclaredMethods0(Native Method) ~[na:1.8.0_212]
	at java.lang.Class.privateGetDeclaredMethods(Class.java:2729) ~[na:1.8.0_212]
	at java.lang.Class.getDeclaredMethods(Class.java:2003) ~[na:1.8.0_212]
	at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:458) ~[spring-core-5.2.0.RC1.jar:5.2.0.RC1]
	... 21 common frames omitted
Caused by: java.lang.ClassNotFoundException: com.jayway.jsonpath.JsonPath
	at java.net.URLClassLoader.findClass(URLClassLoader.java:382) ~[na:1.8.0_212]
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_212]
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349) ~[na:1.8.0_212]
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_212]
	... 25 common frames omitted

The strange thing is, when I look at the dependencies of spring-content-fs-boot-starter, |I can't see JsonPath included.

If I add JsonPath into my POM, I still get the same issue.

Not sure what's going on.

Thanks.

David.

@paulcwarren
Copy link
Owner Author

Hi David,

I wonder if your jsonpath jar library got corrupted during download? From a dependency perspective it looks like it is there but when the classloader actually tries to load classes from it, it can't? I have seen this plenty over the years.

As for spring-content-fs-boot-starter "fixing" it. Not sure either. If it is corrupted then maybe adding it is changing the classpath just enough to drag in a different version of jsonpath (an uncorrupted version) or something like that?

If that isnt it then can you run mvn dependency:tree and post the output? Maybe I can spot something in that.

@davidmacsix
Copy link

Hi @paulcwarren ,
I got it sorted. I was using json-path already in my integration tests, so it has a scope of test, effectively meaning it was removed from the class path at runtime. It's all working.

Thanks so much for you're help.

David.

@modikanisha
Copy link

Hello @paulcwarren ,
Sir I need your help. I am upgrading the springboot version to 2.2.2. Currently I am facing issue which described in this link issue.

Please help me.It would be a grateful.TIA.

@ghost
Copy link

ghost commented Feb 11, 2020

@modikanisha I think what he did was changing

<dependency>
    <groupId>com.jayway.jsonpath</groupId>
    <artifactId>json-path</artifactId>
    <scope>test</scope>
</dependency>

to

<dependency>
    <groupId>com.jayway.jsonpath</groupId>
    <artifactId>json-path</artifactId>
</dependency>

At least that worked for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants