getMountContentBaseBean returns null

I’m making a new rest service under cm.modules and the first few lines are

        public void saveDocument(
                @Context HttpServletRequest servletRequest,
                @Context HttpServletResponse servletResponse,
                @Context UriInfo uriInfo) {
            HstRequestContext requestContext =
                    getRequestContext(servletRequest);
            try {
                WorkflowPersistenceManager wpm = (WorkflowPersistenceManager)
                        getPersistenceManager(requestContext);
                HippoFolderBean contentBaseFolder =
                        getMountContentBaseBean(requestContext);
                String productFolderPath = contentBaseFolder.getPath() +
                        "/products";

What needs to be passed in from the client to get a valid result from getMountContentBaseBean(requestContext)? I’m using soapui to test

getResolvedMount().getMount().getContentPath() is null in HstRequestContextImpl line 923

Thank you :slight_smile:

Hi Joshua,

To get a valid result from getMountContentBaseBean(requestContext), you need to ensure that the HstRequestContext is properly set up with a valid mount. The issue you are encountering, where getResolvedMount().getMount().getContentPath() is null, indicates that the HstRequestContext might not be correctly initialized or the mount is not resolved properly.

Here are a few steps to troubleshoot and resolve this issue:

  1. Check the Request URL: Ensure that the URL you are using in SoapUI to test the service is correctly mapped to a valid mount in your HST configuration. The URL should correspond to a valid site or content mount.
  2. Verify HST Configuration: Make sure that the HST configuration in your project is correctly set up. This includes the hst:hosts and hst:mounts configurations in the repository. The mount should have a valid content path.
  3. Initialize HstRequestContext: Ensure that the HstRequestContext is properly initialized in your test setup. This might involve setting up the request context in a way that it resolves the mount correctly.
  4. Debugging: Add debugging statements or use a debugger to inspect the HstRequestContext object at runtime. Check if the resolvedMount and mount properties are correctly populated.
  5. Check for Null Values: Ensure that none of the components involved in setting up the HstRequestContext return null values. This includes the HstRequestContextProvider, ResolvedMount, and Mount objects.

By following these steps, you should be able to identify why getResolvedMount().getMount().getContentPath() is returning null and ensure that getMountContentBaseBean(requestContext) returns a valid result.

Kindly please let me know is this helpful or not?

Thanks and Regards,
Rajesh S