broadleaf-commerce

Broadleaf - running locally - problem getting started the API project


I'm trying to run Heat Clinic 6.0.1 locally following getting started tutorial: https://www.broadleafcommerce.com/docs/core/current/getting-started/running-locally

I managed to run admin and site but not the API project. The application starts without problems but when I go to http://localhost:8082/api/v1/swagger-ui.html I get a 404. In the log I see this exception:

javax.servlet.ServletException: Circular view path [error]: would dispatch back to the current handler URL [/error] again. Check your ViewResolver setup! (Hint: This may be the result of an unspecified view, due to default view name generation.)

Also trying to log in directly in the API with user broadleafapi and password gives 404.

My environment: Windows 10, jdk 8, maven 3.6

What's wrong? Can you help me? Thank you


Solution

  • Thanks for the report. I reproduced this and it looks like that with the update to Spring Boot 2.0, we did not appropriately override the updated property that specifies the servlet location to embedded Tomcat. Thus, when you went to /api/v1/swagger-ui.html, the application treats it exactly like that URL which is what gave the 404.

    Setting the server.servlet.contextPath=/api/v1 property appropriately stripped off this path as part of the servlet context and resolved the 404.

    I tested around a bit and was able to 'Authorize' the app (button at the top right of the Swagger page) with the credentials information that get spit out in the logs:

    Basic auth configured with user broadleafapi and password: <<generated>>
    

    then I was able to hit the API endpoints.

    The changes you will need to make locally in your project to consume the fix are at https://github.com/BroadleafCommerce/DemoSite/commit/422d1cdc37f847afd8bec0be477ab784cbad2e9d#diff-991c59b6dbb0f619b8570d8f8779eaddR11. You will notice that I moved the original definition in default.properties over to common.properties and I recommend that you do the same. To be clear, follow these steps:

    1. Delete the server.servlet.contextPath entry in `api/src/main/resources/runtime-properties/default.properties
    2. Change server.servletPath in api/src/main/resources/runtime-properties/common.properties to server.servlet.contextPath

    Thanks for trying out Broadleaf and the report, sorry for the rough early start!