Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

AEM Custom Servlet Post Working in HTTP but not HTTPs

pa_dc
Level 2
Level 2

*Reposted since I am not able to see this post

 

Hi everyone,

I have a custom servlet which I am using to return folder information. I am able to return the information when I attempting to hit the servlet directly with HTTP and specifying the port number. However, we are setting AEM to be SSL by Default and I am unable to get the same information to be returned through HTTPS and when I do not specify the port which is the case I want. I'm assuming it has to do with the mapping I have in place but I am unsure.

 

I have updated the Apache Felix Jetty Based Http Service to enable HTTPS and messed around with the Sling Mapping but am getting nowhere. I have added error log information and some configuration information below when I attempt to hit the servlet from Postman.

Any help would be awesome.

 

Error Log Information

0 TIMER_START{Request Processing}
      2 COMMENT timer_end format is {<elapsed microseconds>,<timer name>} <optional message>
     12 LOG Method=POST, PathInfo=null
     16 TIMER_START{handleSecurity}
   2016 TIMER_END{1996,handleSecurity} authenticator org.apache.sling.auth.core.impl.SlingAuthenticator@576d3546 returns true
   2298 TIMER_START{ResourceResolution}
   6162 TIMER_END{3862,ResourceResolution} URI=/api/assets/v1/jobFolderInfo resolves to Resource=NonExistingResource, path=/api/assets/v1/jobFolderInfo
   6175 LOG Resource Path Info: SlingRequestPathInfo: path='/api/assets/v1/jobFolderInfo', selectorString='null', extension='null', suffix='null'
   6176 TIMER_START{ServletResolution}
   6182 TIMER_START{resolveServlet(/api/assets/v1/jobFolderInfo)}
   8231 LOG {0}: no servlet found
   8245 TIMER_END{2061,resolveServlet(/api/assets/v1/jobFolderInfo)} Using servlet org.apache.sling.servlets.post.impl.SlingPostServlet
   8251 TIMER_END{2074,ServletResolution} URI=/api/assets/v1/jobFolderInfo handled by Servlet=org.apache.sling.servlets.post.impl.SlingPostServlet
   8259 LOG Applying Requestfilters
   8265 LOG Calling filter: com.adobe.granite.resourceresolverhelper.impl.ResourceResolverHelperImpl
   8274 LOG Calling filter: org.apache.sling.i18n.impl.I18NFilter

Sling Mapping

<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
jcr:primaryType="sling:Mapping"
sling:internalRedirect="/content/dam/site.$1.json"
sling:match="aem.site.com.4502/api/assets/v1/(.*)" />

Servlet Information

/**
* Servlet for creating folder using DAM assets APIs.
*/
@Component(service = Servlet.class,
property = {
Constants.SERVICE_DESCRIPTION + "=Get Job Folder Info API",
"sling.servlet.methods=" + HttpConstants.METHOD_POST,
"sling.servlet.resourceTypes=" + "sling/servlet/default",
"sling.servlet.selectors=" + "jobFolderInfo",
"sling.servlet.extensions=" + APIConstants.JSON_EXTENSION_TYPE
})
public class JobFolderInfoServlet extends SlingAllMethodsServlet {

 

1 Accepted Solution
BrianKasingli
Correct answer by
Community Advisor
Community Advisor

Hello,

I don't think you can make a sling:internalRedirect with servlets; as this property causes the current path to be modified internally to continue with resource resolution; not script resolution. Documentation: https://sling.apache.org/documentation/the-sling-engine/mappings-for-resource-resolution.html

Intern Solution:
Apache Redirects:

RewriteRule ^/api/assets/v1/(.*)$ /content/dam/site.$1.json [PT,L]

Documentation: https://sourcedcode.com/sugar-coating-servlet-scripts-and-paths

Hope this helps.

View solution in original post

4 Replies
pa_dc
Level 2
Level 2

Just wanted to add more to this in terms of recent request log.

0 TIMER_START{Request Processing}
      3 COMMENT timer_end format is {<elapsed microseconds>,<timer name>} <optional message>
     15 LOG Method=POST, PathInfo=null
     19 TIMER_START{handleSecurity}
   2006 TIMER_END{1985,handleSecurity} authenticator org.apache.sling.auth.core.impl.SlingAuthenticator@66bb9cb returns true
   2326 TIMER_START{ResourceResolution}
   4772 TIMER_END{2444,ResourceResolution} URI=/api/assets/v1/jobFolderInfo resolves to Resource=NonExistingResource, path=/api/assets/v1/jobFolderInfo
   4783 LOG Resource Path Info: SlingRequestPathInfo: path='/api/assets/v1/jobFolderInfo', selectorString='null', extension='null', suffix='null'
   4784 TIMER_START{ServletResolution}
   4789 TIMER_START{resolveServlet(/api/assets/v1/jobFolderInfo)}
   5722 LOG {0}: no servlet found
   5734 TIMER_END{943,resolveServlet(/api/assets/v1/jobFolderInfo)} Using servlet org.apache.sling.servlets.post.impl.SlingPostServlet
   5740 TIMER_END{955,ServletResolution} URI=/api/assets/v1/jobFolderInfo handled by Servlet=org.apache.sling.servlets.post.impl.SlingPostServlet
   5747 LOG Applying Requestfilters
   5753 LOG Calling filter: com.adobe.granite.resourceresolverhelper.impl.ResourceResolverHelperImpl
   5762 LOG Calling filter: org.apache.sling.i18n.impl.I18NFilter
   5766 LOG Calling filter: com.adobe.granite.httpcache.impl.InnerCacheFilter
   5775 LOG Calling filter: org.apache.sling.rewriter.impl.RewriterFilter
   5780 LOG Calling filter: com.adobe.cq.mcm.campaign.servlets.CampaignCopyTracker
   5784 LOG Calling filter: com.adobe.cq.history.impl.HistoryRequestFilter
   5948 LOG Calling filter: com.day.cq.wcm.core.impl.WCMRequestFilter
   5962 LOG Calling filter: com.adobe.cq.wcm.core.components.internal.servlets.CoreFormHandlingServlet
   5968 LOG Calling filter: com.adobe.granite.optout.impl.OptOutFilter
   5977 LOG Calling filter: com.day.cq.wcm.foundation.forms.impl.FormsHandlingServlet
   5980 LOG Calling filter: com.adobe.cq.social.commons.cors.CORSAuthenticationFilter
   5984 LOG Calling filter: org.apache.sling.engine.impl.debug.RequestProgressTrackerLogFilter
   5986 LOG Calling filter: com.day.cq.wcm.mobile.core.impl.redirect.RedirectFilter
   5990 LOG Calling filter: com.day.cq.wcm.core.impl.AuthoringUIModeServiceImpl
   6295 LOG Calling filter: org.apache.sling.security.impl.ContentDispositionFilter
   6300 LOG Calling filter: com.adobe.granite.csrf.impl.CSRFFilter
   6310 LOG Calling filter: com.adobe.granite.rest.assets.impl.AssetContentDispositionFilter
   6314 LOG Calling filter: com.adobe.granite.requests.logging.impl.RequestLoggerImpl
   6320 LOG Calling filter: com.adobe.granite.rest.impl.servlet.ApiResourceFilter
   6366 LOG Including resource ApiResourceWrapper, type=granite/rest/core/resource, path=/api/assets/v1/jobFolderInfo, resource=[NonExistingResource, path=/api/assets/v1/jobFolderInfo] (SlingRequestPathInfo: path='/api/assets/v1/jobFolderInfo', selectorString='null', extension='null', suffix='null')
   6377 TIMER_START{resolveServlet(/api/assets/v1/jobFolderInfo)}
   6398 TIMER_END{20,resolveServlet(/api/assets/v1/jobFolderInfo)} Using servlet com.adobe.granite.rest.impl.servlet.DefaultServlet
   6405 LOG Applying Forwardfilters
   6408 LOG Calling filter: com.day.cq.personalization.impl.TargetComponentFilter
   6412 LOG Calling filter: org.apache.sling.i18n.impl.I18NFilter
   6415 LOG Calling filter: com.day.cq.wcm.core.impl.WCMComponentFilter
   6520 LOG Calling filter: com.day.cq.wcm.core.impl.WCMDebugFilter
   6538 LOG Calling filter: com.adobe.granite.rest.assets.impl.AssetContentDispositionFilter
   6549 TIMER_START{com.adobe.granite.rest.impl.servlet.DefaultServlet#0}
  11773 TIMER_END{5222,com.adobe.granite.rest.impl.servlet.DefaultServlet#0}
  11837 LOG Filter timing: filter=com.day.cq.dam.core.impl.servlet.DamContentDispositionFilter, inner=0, total=5, outer=5
  11842 LOG Filter timing: filter=com.adobe.granite.rest.assets.impl.AssetContentDispositionFilter, inner=5, total=5, outer=0
  11846 LOG Filter timing: filter=com.day.cq.wcm.core.impl.WCMDebugFilter, inner=5, total=5, outer=0
  11849 LOG Filter timing: filter=com.day.cq.wcm.core.impl.WCMComponentFilter, inner=5, total=6, outer=1
  11853 LOG Filter timing: filter=org.apache.sling.i18n.impl.I18NFilter, inner=6, total=6, outer=0
  12003 TIMER_END{12002,Request Processing} Request Processing
  12018 LOG Filter timing: filter=com.adobe.cq.dam.webdav.impl.io.DamWebdavRequestFilter, inner=0, total=0, outer=0
  12021 LOG Filter timing: filter=com.day.cq.wcm.core.impl.warp.TimeWarpFilter, inner=0, total=0, outer=0
  12025 LOG Filter timing: filter=com.adobe.cq.social.ugcbase.security.impl.SaferSlingPostServlet, inner=0, total=0, outer=0
  12028 LOG Filter timing: filter=com.day.cq.dam.core.impl.assetlinkshare.AdhocAssetShareAuthHandler, inner=0, total=0, outer=0
  12031 LOG Filter timing: filter=com.day.cq.dam.core.impl.servlet.ActivityRecordHandler, inner=0, total=0, outer=0
  12034 LOG Filter timing: filter=com.day.cq.dam.core.impl.servlet.DamContentDispositionFilter, inner=0, total=0, outer=0
  12037 LOG Filter timing: filter=com.adobe.granite.rest.impl.servlet.ApiResourceFilter, inner=0, total=6, outer=6
  12040 LOG Filter timing: filter=com.adobe.granite.requests.logging.impl.RequestLoggerImpl, inner=6, total=6, outer=0
  12042 LOG Filter timing: filter=com.adobe.granite.rest.assets.impl.AssetContentDispositionFilter, inner=6, total=6, outer=0
  12045 LOG Filter timing: filter=com.adobe.granite.csrf.impl.CSRFFilter, inner=6, total=6, outer=0
  12048 LOG Filter timing: filter=org.apache.sling.security.impl.ContentDispositionFilter, inner=6, total=6, outer=0
  12051 LOG Filter timing: filter=com.day.cq.wcm.core.impl.AuthoringUIModeServiceImpl, inner=6, total=6, outer=0
  12054 LOG Filter timing: filter=com.day.cq.wcm.mobile.core.impl.redirect.RedirectFilter, inner=6, total=6, outer=0
  12057 LOG Filter timing: filter=org.apache.sling.engine.impl.debug.RequestProgressTrackerLogFilter, inner=6, total=6, outer=0
  12059 LOG Filter timing: filter=com.adobe.cq.social.commons.cors.CORSAuthenticationFilter, inner=6, total=6, outer=0
  12062 LOG Filter timing: filter=com.day.cq.wcm.foundation.forms.impl.FormsHandlingServlet, inner=6, total=6, outer=0
  12065 LOG Filter timing: filter=com.adobe.granite.optout.impl.OptOutFilter, inner=6, total=6, outer=0
  12069 LOG Filter timing: filter=com.adobe.cq.wcm.core.components.internal.servlets.CoreFormHandlingServlet, inner=6, total=6, outer=0
  12072 LOG Filter timing: filter=com.day.cq.wcm.core.impl.WCMRequestFilter, inner=6, total=6, outer=0
  12075 LOG Filter timing: filter=com.adobe.cq.history.impl.HistoryRequestFilter, inner=6, total=6, outer=0
  12078 LOG Filter timing: filter=com.adobe.cq.mcm.campaign.servlets.CampaignCopyTracker, inner=6, total=6, outer=0
  12081 LOG Filter timing: filter=org.apache.sling.rewriter.impl.RewriterFilter, inner=6, total=6, outer=0
  12084 LOG Filter timing: filter=com.adobe.granite.httpcache.impl.InnerCacheFilter, inner=6, total=6, outer=0
  12087 LOG Filter timing: filter=org.apache.sling.i18n.impl.I18NFilter, inner=6, total=6, outer=0
  12091 LOG Filter timing: filter=org.apache.sling.distribution.servlet.DistributionAgentCreationFilter, inner=6, total=6, outer=0

 Looks as if maybe the servlet is found? I am not too sure. 

BrianKasingli
Correct answer by
Community Advisor
Community Advisor

Hello,

I don't think you can make a sling:internalRedirect with servlets; as this property causes the current path to be modified internally to continue with resource resolution; not script resolution. Documentation: https://sling.apache.org/documentation/the-sling-engine/mappings-for-resource-resolution.html

Intern Solution:
Apache Redirects:

RewriteRule ^/api/assets/v1/(.*)$ /content/dam/site.$1.json [PT,L]

Documentation: https://sourcedcode.com/sugar-coating-servlet-scripts-and-paths

Hope this helps.

View solution in original post

Arun_Patidar
Community Advisor
Community Advisor

Have you created sling mapping for both htttp and https nodes?

Log says, it is not able to find /api/..... that means mapping is missing.

pa_dc
Level 2
Level 2
I am new to AEM and was only able to figure it out after poking around and creating a mapping within a new folder named https which worked for me.