AEM:: Error Handling using the acs-aem-commons package - aem

As defined here http://adobe-consulting-services.github.io/acs-aem-commons/features/errorpagehandler.html I am trying to confgure error pages for my application. Here is what I have done:
1) Created 404.jsp and default.jsp at /apps/sling/servlet/errorhandler as defined on the page.
2) Added below widget to the advanced tab:
<errorpages
jcr:primaryType="cq:Widget"
path="/apps/acs-commons/components/utilities/errorpagehandler/dialog/errorpages.infinity.json"
xtype="cqinclude"/>
3) Created /apps//config/com.adobe.acs.commons.errorpagehandler.impl.ErrorPageHandlerImpl.xml
with the following properties:
<?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:OsgiConfig"
prop.enabled="{Boolean}true"
prop.error-page.fallback-name="500"
prop.error-page.system-path="/content/error"
prop.error-page.extension="html"
ttl="{Long}300"/>
4) Created /content/myapp/en/errors using a fresh template. The template has only a parsys. Inside the /content/myapp/en/errors, I have created page 404 and 500 using the same template. In the video it is shown that when the speaker opens the pages 404.html and 500.html created under geometrixx from siteadmin he is able to see appropriate error messages. What I am not able to understand is that if my template consists of only a parsys how will the 404 and 500 pages show the error messge. From where are those messages being generated ? Am I missing something here ? Do I have to create any component ?
5) In the Page Properties of the page /content/myapp/en , I have configured /content/myapp/en/errors as the Error Page. To generate a 404 error when I try to access the URL /content/myapp/ent.html instead of /content/myapp/en.html it throws a
No resource found
Cannot serve request to /content/myapp/ent.html in /apps/sling/servlet/errorhandler/404.jsp
Not sure how do I get he nice looking pages as shown in the video.
5) How can I make the error messages authorable ?
Thanks in advance

No need to follow so many steps. The ACS commons package with the error handler is available as a package. Down load this package from This ACS commons git hub site
The name of the file is --> acs-aem-commons-content-1.9.6.zip(2.3 MB).
Then just create sling:OsgiConfig node in your /apps/myapp/config with
name --> com.adobe.acs.commons.wcm.impl.ComponentErrorHandlerImpl. Then put the below configuration into the node.
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:cq="http://www.day.com/jcr/cq/1.0"
xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0"
jcr:primaryType="sling:OsgiConfig"
prop.edit.enabled="{Boolean}true"
prop.edit.html="/apps/acs-commons/components/utilities/component-error-handler/edit.html"
prop.preview.enabled="{Boolean}false"
prop.preview.html="/apps/acs-commons/components/utilities/component-error-handler/preview.html"
prop.publish.enabled="{Boolean}false"
prop.publish.html="/dev/null"
/>
Below is the configure component in crxde lite
Thats all. You need not do anything else.You will get proper error pages or messages for all 500 or 404 errors

As you said in 5th step In the Page Properties of the page /content/myapp/en , you have configured /content/myapp/en/errors as the Error Page. This error pages are work for for child pages under this path /content/myapp/en . In your case it will be work for all the childs under /content/myapp/en/*.html
Ex. It will work for /content/myapp/en/{invalidurl}.html

The question was about the page error handler, the answer is provided about in: component error handler. These two different things altogether.
the CEH handles the exception in component scope where as EPH handles it in request scope
when component fails and the exception is not handled by CEH and response is written as 500, it will be handled by EPH

For point 4) The template has only a parsys.
Yes you have to configure the components and place them in the parsys as you would do for your content pages that will display in case of error pages. The error handler gives you the flexibility to modify what shows up in error pages by keeping them authorable. You can change the look and feel of error pages for each of the valid HTTP errors.
For example, whatever I create in my content/error/404.html page will show up when the actual 404 is returned by the errorhandler.
In case of an invalid URL:
For point 5) In the Page Properties of the page /content/myapp/en , I have configured /content/myapp/en/errors as the Error Page. To generate a 404 error when I try to access the URL /content/myapp/ent.html instead of /content/myapp/en.html it throws an error.
The mistake that you did here was that you are trying to access a parent page url.
One solution would be to place the custom error pages at a level higher than the content pages for your website.
You can do this more than once. As in keep separate error page for global errors, some other for myapp, some others for myapp/en and so on.
So if you have seen there is a tab in page properties where you can author the error pages root url. This can be leveraged to give different URLs as per requirement.
For example,
If you want an error page for /content/myapp/ent.html then place a separate set of error handler pages at content/myapp in addition to those at content/myapp/en.
Then goto myapp.html and in Page Properties override the error page url to content/myapp/error.
For each parent whenever you need a separate error page url author those in page properties.
So now I have two renditions of my error page: One for content/myapp and other for content/myapp/en
As shown below:
path - /content/test.html (Global)
path - /content/myapp/ent.html (Myapp):
Config node:
Sample template to show the difference:

Related

How to create cascading page error handlers for a TYPO3 site

Currently it is only possible to add one error handler per HTTP status code in the site configuration, e.g. for 404 or 403. Alternatively you can always write your custom error handler. But this makes it a bit inflexible.
Imagine the following scenario:
default 404 handling would be a specific page, e.g. 12
in a custom error handler I have a cache of URI-to-page mapping. If this gets a hit, the page from that should be displayed. If not, the generic error page 12
which page is displayed should be configurable in the site configuration
or
for 403 I have an error handler which can redirect to a login page
however this may not work in some cases where it should default to standard 403 page
Nice would be if you could configure this for the site so you have something like this:
404
| - custom error handler 1
| - custom error handler 2
| - page error handler
Keeping your extension with the custom error handlers, you could just replace the "page error handler" with a Fluid template for the last step via site configuration.
However, the site module only allows for one error handler per status code (e.g. 404).
I am thinking it might be useful to change this in the TYPO3 core.
But would like to know how others would solve this first.

Zend framework 1.2 handling 404

I am having one requirement that I want to manage 404 error differently.
When a system found 404, so before moving it to errorController, it should first check in a table which saves data for special urls and internal project url, if an entry found then it should internally execute that internal url and show the output on the page without changing url.
If no entry found in the table then it should move to error controller as it is.
Please help me on this, I have tried and succeeded using dynamic routing from db, but it is pushing route entries each time page initialize and I want to check this only on 404 to avoid useless load on system.
Thanks

Unable to use Liferay Freindly URL Mapper

I was following this document from Liferay Website to work Map Firendly URL Mappings
http://www.liferay.com/documentation/liferay-portal/6.1/development/-/ai/adding-friendly-url-mapping-to-the-portlet
I am using Liferay version=6.1.0
During HyperLink navigation , i was getting the following url
http://localhost:8080/web/guest/what-we-do?p_p_id=sai_WAR_Saiportlet&
p_p_lifecycle=0&p_p_state=normal&p_p_mode=view&p_p_col_id=column-1
&_sai_WAR_Saiportlet_jspPage=%2Fhtml%2Fsai%2Fedit.jsp
To modify the above i have tried to use Friendly URL Mapper and i have done the following way
Inside liferay-portlet.xml file .
<portlet>
<portlet-name>sai</portlet-name>
<icon>/icon.png</icon>
<friendly-url-mapper-class>com.liferay.portal.kernel.portlet.DefaultFriendlyURLMapper</friendly-url-mapper-class>
<friendly-url-mapping>sai</friendly-url-mapping>
<friendly-url-routes>com/test/sai-friendly-url-routes.xml</friendly-url-routes>
<instanceable>false</instanceable>
<header-portlet-css>/css/main.css</header-portlet-css>
<footer-portlet-javascript>
/js/main.js
</footer-portlet-javascript>
<css-class-wrapper>sai-portlet</css-class-wrapper>
</portlet>
Created a new file by name sai-friendly-url-routes.xml inside
D:\liferay-plugins-sdk-6.1.0-SNAPSHOT\portlets\Sai-portlet\docroot\WEB-INF\src\com\test\sai-friendly-url-routes.xml
The content inside sai-friendly-url-routes.xml is
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE routes PUBLIC "-//Liferay//DTD Friendly URL Routes 6.1.0//EN" "http://www.liferay.com/dtd/liferay-friendly-url-routes_6_1_0.dtd">
<routes>
<route>
<pattern>/{mvcPathName}</pattern>
<generated-parameter name="mvcPath">/{mvcPathName}.jsp</generated-parameter>
</route>
</routes>
But i observed there is no change in the url
http://localhost:8080/web/guest/what-we-do?p_p_id=sai_WAR_Saiportlet&p_p_lifecycle=0&p_p_state=normal&p_p_mode=view&p_p_col_id=column-1&p_p_col_count=1&_sai_WAR_Saiportlet_jspPage=%2Fhtml%2Fsai%2Fedit.jsp
Please let me know where exactly i am doing mistake .
You leave the values as they are. That is, you leave {mvcPathName} and "mvcPath" as-is.
When the friendly URL is generated, it parses mvcPath (i.e., edit.jsp or view.jsp) from the URL and then the pattern is applied, replacing .../edit.jsp with .../edit.
This example works for the edit JSP. And it works for the view page; but NOT when clicking Save ... which is something I could look into. However, if you go to edit and then click the back link, the friendly URL will show for the view JSP.
I've created a ticket to complete this example so that it also goes to a friendly URL when clicking save. I'll update this section when we've made the fix.
Thanks.

Drupal 7 some non-existing URLs are not Redirecting to 404?

In Drupal 7, some of (non-existing) URLs are not redirecting to 404 or any error page it should. Instead, it still remains showing its Top Parent Folder. For example like:
www.mywebsite.com/items/aaaaaaaaaaaaa
www.mywebsite.com/items/bbbbbbbbbbbbbbbbbb
Every WRONG URLs under /items/ i put like above, are showing the Page of its parent:
www.mywebsite.com/items instead of get redirected to 404
I don't want its parent to be shown if there is no page really.
But the strange thing is, it is NOT happening on every patterns. I mean, another different parents like:
www.mywebsite.com/users/aaaaaaaaaaaaa
www.mywebsite.com/users/bbbbbbbbbbbbbbbbb
For the wrong url typed-in under this /users/ parent path, it is CORRECTLY redirecting to the 404 page.
What is it please?
If I understand your question correctly, it's not a problem at all.
That's because how your/contributed/core modules hooks Drupal menu system.
If a menu item (menu router item to be specific. Think about a path like "admin/config/development/performance") has no "%" sign in it, menu callback function will be executed.
For an example, if a module registers "items" path example.com/items path would not be a 404, and the appropriate menu callback function of the menu item will be fired. That callback function can make use of further URL parts (example.com/items/123) if given.
'node' is a good example. (technically they are different menu router items though) .
Opening example.com/node will not fire a 404.
If a module registers 'items/%' , then, example.com/items will fire a 404. In other words, the second URL part is required in order to execute the menu callback function.
If the problem you are facing is related to a custom module, make sure you register the correct version of your router items. If the second URL part is required, register items/%.
You can execute a 404 by calling drupal_not_found().
Look at this, really helpfull
http://peterpetrik.com/blog/2009/11/non-existent-urls-views-2
Are you using Views for that path (/items)?
Here is an issue for Views: Prevent duplicate content (because Views returns 200 instead of 400 404)
You could create a Contextual filter to prevent this.
merlinofchaos wrote:
If you don't want this behavior, add the Global: NULL argument to Views and use the setting to validate that the argument is empty.
For Drupal 6, the module Views 404 might help.
You can configure your drupal installation to redirect to a specefic 404 page that you create..
Go to www.yoursite.com/admin/config/system/site-information and enter your 404 page .

404 when post submitted; found when directly called

I have a ColdFusion enabled form (for validation) submitting to a separate page. When this form is submitted it is showing me a 404 on the action page, yet when I directly load the action url into the address bar it shows up (errors appear, but that's ok). This is by far one of the most odd issues I have encountered.
Form page: http://www.jefferson.edu/population_health/_archive/contact_me.cfm
Action page: http://www.jefferson.edu/population_health/_archive/contact_action.cfm
Even if I try passing the form variables via URL it gives me a 404.
My gut is that there is another service on that machine that is trying to take over the request whenever you submit data and binding it to another webserver...which, of course, it can't find the right page based on it's own webroot.
If you click http://www.jefferson.edu/population_health/_archive/contact_me.cfm, it loads fine and returns 200 header with IIS as the server, but if you click http://www.jefferson.edu/population_health/_archive/contact_me2.cfm it throws a 404, as expected, but it's properly handled with a custom 404 and the header response is still IIS. But if you click http://www.jefferson.edu/population_health/_archive/contact_me.cfm?foo=bar, it returns an ApacheSling default 404 and header information saying the server is "Day-Servlet-Engine/4.1.12".
Your page is posting to the page contact_action.cfm ... in your question you indicate that the proper page should be "mailaction.cfm".
If the action page is actually mailaction.cfm then you simply need to change the action attribute of your cfform.