Wednesday, January 14, 2015

WebSphere Commerce Search NullPointerException and Root Causes

You may see NullPointerException in Search server log when there are configuration problem.

The following is a list of the problems I have had so far:

1. wc-search.xml configuration problem:

If you did a APAR update or similar, the wc-search.xml in the com.ibm.comerce.catalog-ext maybe modified after the setupsearchindex.sh was executed

    <_config:server name="AdvancedConfiguration">
        <_config:common-http URL="http://localhost:10080/solr"
            allowCompression="true" connectionTimeout="15000"
            defaultMaxConnectionsPerHost="600" followRedirects="false"
            maxRetries="1" maxTotalConnections="600"
            reference="com.ibm.commerce.foundation.server.services.search.url"
            retryTimeInterval="1000" soTimeout="15000"/>
    </_config:server>
    <_config:cores>
        <_config:core catalog="11101" indexName="CatalogEntry"
            language="en_US" name="MC_11101_CatalogEntry_en_US"
            path="/MC_11101/en_US/CatalogEntry" serverName="BasicConfiguration"/>

then the serverName above does not match the one set in the _config:server, IBM code will throw a NullPointerException:

[1/14/15 11:48:27:150 PST] 000000b7 AbstractBaseR E com.ibm.commerce.foundation.rest.resourcehandler.AbstractBaseResourceHandler handleException(String, Exception, String) Caught unexpected exception, error is: {errors=[{errorCode=CWXFR0230E, errorKey=ERR_INTERNAL_SERVER_ERROR, errorLevel=SEVERE, errorMessage=CWXFR0230E: Internal server error. Details will be stored within the server logs.}]}
                                 com.ibm.commerce.foundation.internal.common.exception.FoundationApplicationException: An error has occurred.  If this problem persists, contact product support.
at com.ibm.commerce.foundation.server.services.search.SearchServiceFacade.performSearch(SearchServiceFacade.java:200)
at com.ibm.commerce.rest.search.handler.v2_0.AbstractSearchResourceHandler.executeSearch(AbstractSearchResourceHandler.java:333)
at com.ibm.commerce.rest.search.handler.v2_0.AbstractSearchResourceHandler.performSearch(AbstractSearchResourceHandler.java:165)
at com.ibm.commerce.rest.search.handler.v2_0.CategoryViewHandler.findSubCategories(CategoryViewHandler.java:482)
at com.ibm.commerce.rest.search.handler.v2_0.CategoryViewHandler.findTopCategories(CategoryViewHandler.java:268)
...
at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138)
at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204)
at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775)
at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:905)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1660)
Caused by: java.lang.NullPointerException
at java.util.concurrent.ConcurrentHashMap.put(ConcurrentHashMap.java:946)
at com.ibm.commerce.foundation.server.services.rest.search.processor.solr.SolrRESTSearchExpressionProcessor.performSearch(SolrRESTSearchExpressionProcessor.java:467)
at com.ibm.commerce.foundation.server.services.search.SearchServiceFacade.performSearch(SearchServiceFacade.java:193)
... 84 more

2. ibm-web-ext.xml flag setting


If the flag of the enable-file-serving is not set to true in the ibm-web-ext.xml file, and you customized the Search-Solr.war and tries to access files, you may have NullPointerException from Apache Solr package too, since the Apache Solr code fails to retrieve request path from ServletRequest: req.getServletPath()

[1/15/15 9:16:55:431 PST] 00000028 SolrDispatchF E org.apache.solr.common.SolrException log null:java.lang.NullPointerException
at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:196)
at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:155)
at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:190)

/usr/IBM/WebSphere/AppServer/v70/profiles/"instance name"/config/cells/cell01/applications/Search.ear/deployments/Search/Search-Solr.war/WEB-INF/ibm-web-ext.xml

<?xml version="1.0" encoding="UTF-8"?>

<web-ext xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://websphere.ibm.com/xml/ns/javaee"
    xsi:schemaLocation="http://websphere.ibm.com/xml/ns/javaee http://websphere.ibm.com/xml/ns/javaee/ibm-web-ext_1_0.xsd" version="1.0">
  <jsp-attribute name="reloadEnabled" value="true"/>
  <jsp-attribute name="reloadInterval" value="10"/>
  <reload-interval value="3"/>
  <enable-directory-browsing value="false"/>
  <enable-file-serving value="true"/>
  <enable-reloading value="false"/>
  <enable-serving-servlets-by-class-name value="false"/>
  <context-root uri="/solr"/>



</web-ext>



Here is a sample of full stack trace:

[2/11/15 17:17:42:268 PST] 0000002b SolrDispatchF E org.apache.solr.common.SolrException log null:java.lang.NullPointerException
        at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:196)
        at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:155)
        at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:190)
        at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:125)
        at com.ibm.ws.webcontainer.filter.WebAppFilterChain._doFilter(WebAppFilterChain.java:80)
        at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:908)
        at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:997)
        at com.ibm.ws.webcontainer.webapp.WebApp.invokeFilters(WebApp.java:4044)
        at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3971)
        at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:276)
        at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:945)
        at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1592)
        at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:191)
        at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:453)
        at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewRequest(HttpInboundLink.java:515)
        at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.processRequest(HttpInboundLink.java:306)
        at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:277)
        at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:214)
        at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:113)
        at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:175)
        at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
        at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
        at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138)
        at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204)
        at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775)
        at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:905)
        at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1656)

No comments:

Post a Comment