google maps sample app : display sales

I am trying to follow the sample app in the github here in my application: GitHub - cuba-platform/sample-google-map

The application is working and shows up salesperson, territory, polygon in the map perfectly except one. The map is not displaying any salesperson, image or anything and it seems there is an error.


13:47:50.471 WARN  o.s.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/myApplication/dispatch/getPhoto/72391a78-194f-eac7-4c98-25a7eb23d129-6.png] in DispatcherServlet with name 'dispatcher'
13:47:50.475 WARN  o.s.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/myApplication/dispatch/getPhoto/1ad829c8-3ec9-6f5c-6df8-ba5abfbf7239-5.png] in DispatcherServlet with name 'dispatcher'
13:47:50.476 WARN  o.s.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/myApplication/dispatch/getPhoto/21ed8dd6-5d00-3ace-d44a-57ab26a13fa4-4.png] in DispatcherServlet with name 'dispatcher'
13:47:51.434 WARN  o.s.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/myApplication/dispatch/getPhoto/21ed8dd6-5d00-3ace-d44a-57ab26a13fa4-4.png] in DispatcherServlet with name 'dispatcher'
13:47:51.434 WARN  o.s.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/myApplication/dispatch/getPhoto/72391a78-194f-eac7-4c98-25a7eb23d129-6.png] in DispatcherServlet with name 'dispatcher'
13:47:51.439 WARN  o.s.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/myApplication/dispatch/getPhoto/1ad829c8-3ec9-6f5c-6df8-ba5abfbf7239-5.png] in DispatcherServlet with name 'dispatcher'

Thing is, I have the procedure getPhoto() copied from demo app as follows:

@Controller
<b>public class </b>PhotoController {

    @Inject
    <b>private </b>LoginService <b>loginService</b>;

    @Inject
    <b>private </b>GlobalConfig <b>globalConfig</b>;

    @Inject
    <b>private </b>DataManager <b>dataManager</b>;

    @Inject
    <b>private </b>FileStorageService <b>fileStorageService</b>;

    <b>private </b>Logger <b>log </b>= LoggerFactory.<i>getLogger</i>(PhotoController.<b>class</b>);

    <i>/**
</i><i>     * HTTP endpoint for loading salesperson pictures.
</i><i>     *
</i><i>     * </i><b><i>@param </i></b><b><i>id        </i></b><i>salesperson ID
</i><i>     * </i><b><i>@param </i></b><b><i>version   </i></b><i>salesperson version. It is not used in code but required for changing URL to always display
</i><i>     *                  a new picture if it was changed.
</i><i>     * </i><b><i>@param </i></b><b><i>response  </i></b><i>response
</i><i>     */
</i><i>    </i>@RequestMapping(value = <b>"/getPhoto/{id}-{version}.png"</b>)
    <b>public </b>ResponseEntity getPhoto(@PathVariable String id,
                                   @SuppressWarnings(<b>"UnusedParameters"</b>) @PathVariable String version,
                                   HttpServletResponse response) <b>throws </b>IOException {
        <b>return </b>authenticated(response, () -> {
            <b>byte</b>&#91;&#93; bytes = <b>null</b>;

            <i>// Load a salesperson photo from File Storage
</i><i>            </i>Salesperson salesperson = <b>dataManager</b>.load(
                    LoadContext.<i>create</i>(Salesperson.<b>class</b>).setId(UUID.<i>fromString</i>(id)).setView(<b>"salesperson-photo"</b>));
            <b>if </b>(salesperson == <b>null</b>) {
                <b>log</b>.error(<b>"Salesperson {} not found"</b>, id);
                response.sendError(HttpServletResponse.<b><i>SC_NOT_FOUND</i></b>);
                <b>return null</b>;
            }
            <b>if </b>(salesperson.getPhoto() != <b>null</b>) {
                <b>try </b>{
                    bytes = <b>fileStorageService</b>.loadFile(salesperson.getPhoto());
                } <b>catch </b>(FileStorageException e) {
                    <b>log</b>.error(<b>"Error loading file"</b>, e);
                }
            }
            HttpHeaders headers = <b>new </b>HttpHeaders();
            headers.setContentType(MediaType.<b><i>IMAGE_PNG</i></b>);
            <b>if </b>(bytes == <b>null</b>) {
                <i>// If photo is not set, use a default image
</i><i>                </i>URL url = <b>new </b>URL(<b>globalConfig</b>.getDispatcherBaseUrl() + <b>"/static/noIcon.png"</b>);
                BufferedImage defaultImage = ImageIO.<i>read</i>(url);
                ByteArrayOutputStream baos = <b>new </b>ByteArrayOutputStream();
                ImageIO.<i>write</i>(defaultImage, <b>"png"</b>, baos);
                baos.flush();
                bytes = baos.toByteArray();
                baos.close();
            }
            <b>return new </b>ResponseEntity<>(bytes, headers, HttpStatus.<b><i>CREATED</i></b>);
        });
    }

    <i>/**
</i><i>     * Execute code on behalf of anonymous user.
</i><i>     *
</i><i>     * </i><b><i>@param </i></b><b><i>response  </i></b><i>response object
</i><i>     * </i><b><i>@param </i></b><b><i>callable  </i></b><i>code to execute
</i><i>     * </i><b><i>@param </i></b><b><i><T>       </i></b><i>type of return value
</i><i>     * </i><b><i>@return          </i></b><i>result
</i><i>     * </i><b><i>@throws </i></b><i>IOException  propagated from HttpServletResponse methods
</i><i>     */
</i><i>    </i><b>private </b><T> T authenticated(HttpServletResponse response, Callable<T> callable) <b>throws </b>IOException {
        UserSession anonymousUserSession = <b>loginService</b>.getSession(<b>globalConfig</b>.getAnonymousSessionId());
        <b>if </b>(anonymousUserSession == <b>null</b>) {
            response.sendError(HttpServletResponse.<b><i>SC_FORBIDDEN</i></b>);
            <b>return null</b>;
        }
        AppContext.<i>setSecurityContext</i>(<b>new </b>SecurityContext(anonymousUserSession));
        <b>try </b>{
            <b>return </b>callable.call();
        } <b>catch </b>(Exception e) {
            <b>log</b>.error(<b>"Error executing request"</b>, e);
            response.sendError(HttpServletResponse.<b><i>SC_INTERNAL_SERVER_ERROR</i></b>);
            <b>return null</b>;
        } <b>finally </b>{
            AppContext.<i>setSecurityContext</i>(<b>null</b>);
        }
    }
}

What could be the reason?

Hi,

Does the sample application work, and you have problems with only your application? If so, could you please send us a small sample project along with reproduction scenario that demonstrates the issue.

Regards,
Gleb