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

spring boot 2.0.1 migration issue. #27

Closed
mkmyla opened this issue May 11, 2018 · 14 comments
Closed

spring boot 2.0.1 migration issue. #27

mkmyla opened this issue May 11, 2018 · 14 comments
Assignees

Comments

@mkmyla
Copy link

mkmyla commented May 11, 2018

After migrating to spring boot 2.0.1 version, i started getting below error

Caused by: java.io.FileNotFoundException: class path resource [org/springframework/boot/web/support/SpringBootServletInitializer.class] cannot be opened because it does not exist

upon checking the issue could be because of wrong import in FF4JWebConfiguration for SpringBootServletInitializer

Is there a version of ff4j compatible with spring boot 2.0.1 I am using latest ff4j version 1.7.1

@paul58914080 paul58914080 self-assigned this May 12, 2018
@paul58914080
Copy link
Member

paul58914080 commented May 12, 2018

Hello,

This is because SpringBootServletInitializer was moved to a different classpath in spring boot 2.x org.springframework.boot.web.**servlet**.support.SpringBootServletInitializerthan it used to be in spring boot 1.5.x. org.springframework.boot.web.support.SpringBootServletInitializer

As a workaround you could try to have the following dependencies for a spring boot starter parent with version 2.x

<dependency>
   <groupId>org.ff4j</groupId>
   <artifactId>ff4j-spring-boot-web-api</artifactId>
   <version>1.7.1</version>
</dependency>
<dependency>
   <groupId>org.ff4j</groupId>
   <artifactId>ff4j-web</artifactId>
   <version>1.7.1</version>
</dependency>
<dependency>
   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>

and the following configuration gist in your project

I have already started upgrading the ff4j-spring-boot-starter to spring boot 2.x and kotlin and should be released as part of 2.0.RC1

@mkmyla
Copy link
Author

mkmyla commented May 14, 2018

Thank you for reply. Will wait for 2.0.RC1

@StellaB24
Copy link

Hi,
Any ETC for 2.0RC1?
Thanks.

@paul58914080
Copy link
Member

Hello,

Mostly I have fixed the broken code

https://github.com/paul58914080/ff4j-spring-boot-starter-parent

I would have to integrate it as part of ff4j version 2.

@clun any thoughts about the 2.0RC1 ?

@jorgerod
Copy link

Hello,

Any ETC for 2.0RC1?

Thanks.

@dvelopp
Copy link

dvelopp commented Jan 15, 2019

Hello, any updates on this? Do you support Spring Boot 2 with its SpringBootServletInitializer moved to another package?

@paul58914080
Copy link
Member

Started with the movement https://github.com/ff4j/ff4j-spring-boot-starter-parent.

Will try to release a RC (ReleaseCanditate) version within this week.

@xucw
Copy link

xucw commented Feb 22, 2019

Hi Paul, any updates on the RC version ? and when will the RC version release? thanks.

@paul58914080
Copy link
Member

Planning to release it next week.

@drizztguen77
Copy link

drizztguen77 commented Feb 22, 2019

I tried following the changes above and explained in gist

The only change I made was I used FF4jDispatcherServlet instead of ConsoleServlet to get the new UI. It starts up fine but when I hit the URL it gets the following exception:

Receiver class org.ff4j.web.thymeleaf.CustomMessageResolver does not define or inherit an implementation of the resolved method abstract resolveMessage(Lorg/thymeleaf/context/ITemplateContext;Ljava/lang/Class;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String; of interface org.thymeleaf.messageresolver.IMessageResolver.
java.lang.AbstractMethodError: Receiver class org.ff4j.web.thymeleaf.CustomMessageResolver does not define or inherit an implementation of the resolved method abstract resolveMessage(Lorg/thymeleaf/context/ITemplateContext;Ljava/lang/Class;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String; of interface org.thymeleaf.messageresolver.IMessageResolver.

I have the thymeleaf dependency defined in my pom file.

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-thymeleaf</artifactId>
    </dependency>

Any ideas what I can do to get this to work?

@paul58914080
Copy link
Member

paul58914080 commented Feb 22, 2019

There has been a lot of breaking changes after the updates from spring-boot 2.x.

I have decided that I will be removing the support of auto-configuration of the console(ff4j-web) which uses old dependencies and is causing a lot of conflicts with spring-boot 2.x.

To help you resolve the configuration, I have updated the sample project

In the SpringBootApplication I had to exclude the ThymeleafAutoConfiguration. Refer

@SpringBootApplication(exclude = ThymeleafAutoConfiguration.class)
public class Application {
    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }
}

The following dependencies were added explicitly

        <dependency>
            <groupId>org.ff4j</groupId>
            <artifactId>ff4j-web</artifactId>
            <version>1.7.3</version>
        </dependency>
        <dependency>
            <groupId>org.thymeleaf</groupId>
            <artifactId>thymeleaf</artifactId>
            <version>2.1.4.RELEASE</version>
        </dependency>

The FF4JWebConfiguration.java

@Configuration
@ConditionalOnClass({ConsoleServlet.class, FF4jDispatcherServlet.class})
@AutoConfigureAfter(FF4JConfiguration.class)
public class FF4JWebConfiguration extends SpringBootServletInitializer {

    @Bean
    public ServletRegistrationBean servletRegistrationBean(ConsoleServlet ff4jConsoleServlet) {
        return new ServletRegistrationBean(ff4jConsoleServlet, "/ff4j-console");
    }

    @Bean
    @ConditionalOnMissingBean
    public ConsoleServlet getFF4jServlet(FF4j ff4j) {
        ConsoleServlet ff4jConsoleServlet = new ConsoleServlet();
        ff4jConsoleServlet.setFf4j(ff4j);
        return ff4jConsoleServlet;
    }

    @Bean
    public ServletRegistrationBean ff4jDispatcherServletRegistrationBean(FF4jDispatcherServlet ff4jDispatcherServlet) {
        return new ServletRegistrationBean(ff4jDispatcherServlet, "/ff4j-web-console/*");
    }

    @Bean
    @ConditionalOnMissingBean
    public FF4jDispatcherServlet getFF4jDispatcherServlet(FF4j ff4j) {
        FF4jDispatcherServlet ff4jConsoleServlet = new FF4jDispatcherServlet();
        ff4jConsoleServlet.setFf4j(ff4j);
        return ff4jConsoleServlet;
    }
}

Let me know if this helps.

@drizztguen77
Copy link

That did the trick. I couldn't use ff4j-spring-boot-starter still with spring boot 2 but I did get it working without the starter. Thank you very much for your help.

@paul58914080
Copy link
Member

paul58914080 commented Feb 28, 2019

Hello,

Please use the latest release i.e. 1.8.

The sample project has also be updated.

Please note: With the release of 1.8 the support of web console auto-configuration is not supported. How I have demonstrated the usage in the sample

@paul58914080
Copy link
Member

@paul58914080 paul58914080 transferred this issue from ff4j/ff4j Feb 28, 2019
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

7 participants