Details
-
Bug
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
1.1
-
None
-
None
-
Simple web application using the org.apache.commons.chain.web.servlet.ChainProcessor servlet with the PathInfoMapper. No configuration parameters differ from defaults.
Description
I found a NPE in your implementation of the PathInfoMapper command.
The exception is thrown when the PathInfoMapper tries to invoke the command he received from the request's pathInfo. This happens at following code:
// Map to the Command specified by the extra path info
Catalog catalog = (Catalog) context.get(getCatalogKey());
Command command = catalog.getCommand(pathInfo);
As you can see, the command tries to obtain the catalog using the "get" method from the context. The 'catalogKey' is defined to be the same as the one used by the ChainProcessor servlet:
private String catalogKey = ChainProcessor.CATALOG_DEFAULT;
The problem is that the catalog instance is set in the request scope, not inside the context instance. This is the piece of code from ChainProcessor that does that:
if (attribute == null) {
request.setAttribute(CATALOG_DEFAULT, theCatalog);
}
So, the PathInfoMapper always obtains a null reference from the command's context when it tries to obtain a catalog instance.