0

I am doing a Proof of Concept in feature toggle using Springboot and Togglz library. I have used a Maven project. i am facing a strange error. There are two workspace for eclipse. Both have the same toggle project. But, when I try to run the project, i am able to see toggle console in only one of the project. So, http://localhost:8080/togglz-console is showing up correct in one workspace. But when i try to stop this application, and run the same project from a different workspace, I get a Whitelabel error page. I am not using any properties or yml file as this is the default path and i believe it should get configured automatically.

I have even tried to change the port and the console path in the workspace where i am getting the error but there is no effect.

Any suggestions as to why the default toggle console is not working for another workspace will be of great help. This one is quite strange for me!

My Code-

'''

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

public enum Features implements Feature{
    
     @Label("just a description")
        @EnabledByDefault
        HELLO_WORLD,

        @Label("another descrition")
        @EnabledByDefault
        REVERSE_GREETING;

        public boolean isActive() {
            return FeatureContext.getFeatureManager().isActive(this);
        }

}

@RestController
public class HelloWorldController {
    
    @RequestMapping("/hello4")
    public ResponseEntity<?> index4() {
        System.out.println("inside hello4");
        System.out.println(Features.HELLO_WORLD.isActive());
        System.out.println(Features.REVERSE_GREETING.isActive());


        if (Features.HELLO_WORLD.isActive()) {
            StringBuilder sb = new StringBuilder("Greetings from Spring Boot!");
            if (Features.REVERSE_GREETING.isActive()) {
                sb.reverse();
            }
            return ResponseEntity.ok().body(sb.toString());
        }
        return ResponseEntity.notFound().build();
    }
}

@Configuration
public class TogglzConfiguration {
    @Bean
    public FeatureProvider featureProvider() {
        return new EnumBasedFeatureProvider(Features.class);
    }
}

'''

Puce
  • 34,375
  • 9
  • 72
  • 137

0 Answers0