Upon requesting non-existent pages, both aem author and publish instances return blank page with 200 status code. The default 404 error page is not showing.
Solved! Go to Solution.
Do you have any custom filters that can possibly massage the response? You might want to stop your custom bundles in OSGi and use /system/console/requests to track recent requests.
See the following document:
Views
Replies
Total Likes
Thank you for your response. I tried the custom error handler, but the results are the same. The aem just returns blank page with 200 status code even if the request url is invalid. Not sure what is wrong?
Views
Replies
Total Likes
I never got the default 404 not found page working in my local author and publish instances. If the request url is invalid, the response would be a black page with 0 content length, while the HTTP status code is 200. Anyone met with the same problem?
Views
Replies
Total Likes
Sorry, a typo. The response is blank page.
Views
Replies
Total Likes
Do you see 404.html or 404.jsp in your AEM instance under /apps/sling/servlet/errorhandler/?
http://localhost:4502/crx/de/index.jsp#/apps/sling/servlet/errorhandler/404.html
Views
Replies
Total Likes
yes, I created a 404.html and ResponseStatus.java under /apps/sling/servlet/errorhandler
In the 404.html, the code is as:
<sly data-sly-use.responseStatus="apps.sling.servlet.errorhandler.ResponseStatus">
<sly data-sly-resource="/content/myproject/en/page-not-found.html"></sly>
</sly>
The code in ResponseStatus.java is:
package apps.sling.servlet.errorhandler;
import com.adobe.cq.sightly.WCMUsePojo;
public class ResponseStatus extends WCMUsePojo {
@Override
public void activate() throws Exception {
getResponse().setStatus(404);
}
}
Views
Replies
Total Likes
"/content/myproject/en/page-not-found.html" is a custom 404 error page.
Views
Replies
Total Likes
That does not look like a deafult behavior. AEM should give you a 404 for non existing nodes:
jbrar-macOS:~ jbrar$ curl -u admin:admin http://localhost:6333/content/geometrixx-outdoors/en/men/pants/fulani-noma -I
HTTP/1.1 404 Not Found
Date: Thu, 29 Aug 2019 21:08:49 GMT
X-Content-Type-Options: nosniff
Set-Cookie: cq-authoring-mode=TOUCH;Path=/;Expires=Thu, 05-Sep-2019 21:08:49 GMT;Max-Age=604800
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Content-Type: text/html;charset=utf-8
Transfer-Encoding: chunked
Can you check if you get the 404 response when running a curl command? If yes, the error handler implementation is wrong
Views
Replies
Total Likes
I am not able to get the 404 response when running a curl command to request a non-existent page. Nothing shows up in the terminal, however, I am able to get the correct page for a valid url using curl.
For example, requesting http://localhost:4503/content/myproject/en/search-results shows the html page content, however, requesting http://localhost:4503/content/myproject/en/no-page did not get any response.
Views
Replies
Total Likes
I never get a 404 response from the AEM, either in Author or in Publisher. That is very strange.
Views
Replies
Total Likes
Update for the curl command: I get 200 status for both the valid and invalid url request.
Response for requesting the valid url : http://localhost:4503/content/myproject/en/search-results.html
HTTP/1.1 200 OK
Date: Thu, 29 Aug 2019 21:45:38 GMT
X-Content-Type-Options: nosniff
Set-Cookie: cq-authoring-mode=TOUCH;Path=/;Expires=Thu, 05-Sep-2019 21:45:38 GMT
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Content-Type: text/html;charset=utf-8
Transfer-Encoding: chunked
Response for the invalid url: http://localhost:4503/content/myproject/en/no-page.html
HTTP/1.1 200 OK
Date: Thu, 29 Aug 2019 21:46:15 GMT
X-Content-Type-Options: nosniff
Set-Cookie: cq-authoring-mode=TOUCH;Path=/;Expires=Thu, 05-Sep-2019 21:46:15 GMT
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Content-Length: 0
Views
Replies
Total Likes
hi janellic4 ,
This link can help you understand why you are getting 200 and not 404 response .
Thanks
Views
Replies
Total Likes
That could be due to Response buffer size as well that you always get 200 instead of any other error code. If the rendered response buffer is more than defined one, then server send response back to browser in chunks and once it's sends a part of response, no matter if page works or not, if always return 200.
You can try increasing the buffer size by going into configuration:
Apache Felix Jetty Based Http Service |
"Response Buffer Size"
Increase the size and if page throws error then it should get displayed as well.
Views
Replies
Total Likes
Can you try creating the error pages using ACS commons error page handler.
https://adobe-consulting-services.github.io/acs-aem-commons/features/error-handler/index.html
In this article there is step by step process to create custom error pages and also settings in dispatcher.
Error Page Handler
https://adobe-consulting-services.github.io
Best,
Cal
Views
Replies
Total Likes
Hi, Umeshsondhi
Thank you for your reply. I have read the article you mentioned. In localhost, I do not use a dispatcher. It seems that a blank page would always be returned by Publish for invalid url request. I don't know how this blank page is created.
Views
Replies
Total Likes
Hi himanshusinghal,
Thank you for your response. I tried to increase the Response Buffer Size, then click Save. I got a request error as following:
Views
Replies
Total Likes
Hello cal-netsolutions,
Thank you for your suggestion. However, we have implemented a custom error handler. It works fine in Publish instance in another computer. It does not work in some computers and the stage. They have the same problem: invalid url always got 200 status code with blank page.
Views
Replies
Total Likes
Hi janellic4,
While saving the configuration, it displays the error but it saves the updated value. Try opening the value again and it should show updated "Response Buffer Size".
Even after increasing the response buffer size, do you still get the 200 status code?
Do you get any error as well in logs?
Views
Replies
Total Likes
Hi himanshusinghal,
Yes, I still got the 200 status code even after I doubled the response buffer size.
Views
Replies
Total Likes
Could you please try increasing the buffer size to lets say 10000 and try again?
Views
Replies
Total Likes