Reply To: NPE in RewritePhaseListener.handlePhaseOperation

Splash Forums Rewrite Users NPE in RewritePhaseListener.handlePhaseOperation Reply To: NPE in RewritePhaseListener.handlePhaseOperation



So I grabbed your source code and built 2.0.9.Final-SNAPSHOT.

I added log messages to RewritePhaseListener:

                  public void performInSubflow(ServletRewrite<?, ?> rewriteEvent, EvaluationContext context)
                     try {
                        operation.performOperation((HttpServletRewrite) rewriteEvent, context);
System.out.println("rewrite.getRequest = " + rewriteEvent.getRequest());
System.out.println("rewrite.getRequest.getAttribute = " + rewriteEvent.getRequest().getAttribute(RewriteLifecycleContext.LIFECYCLE_CONTEXT_KEY));
                        List<RewriteResultHandler> resultHandlers = ((HttpRewriteLifecycleContext) ((HttpServletRewrite) rewriteEvent)
System.out.println("resultHandlers = " + resultHandlers);
                        int handlerCount = resultHandlers.size();
                        for (int i = 0; i < handlerCount; i++)
                          RewriteResultHandler handler = resultHandlers.get(i);
                           System.out.println("operation.getEvent = " + operation.getEvent());
                           if (handler.handles(operation.getEvent()))
                     catch (Exception e) {
                                 if (e instanceof NullPointerException) {
                                                                System.err.println("NullPointerException caught");
                                 else { 
                                throw new RewriteException("Failed to handle PhaseOperation [" + operation + "]", e);

      return flow;

The debug output indicates the InboundRewrite POST causes the NullPointerException to be thrown. If I catch the NPE (and not rethrow it), application navigations work correctly. I am not sure what is null. I assume the NPE is bubbling up from the handler methods. I hope this helps. I still contend this is a timing problem, because I never get an error on weblogic 12c apps. The tomcat derivatives like JBoss and Glassfish throw the errors. Also, IE 11 never causes the NPE to be thrown regardless of server.

23:58:31,363 INFO  [stdout] (http-localhost- rewrite.getRequest = http://localhost:8080/captor/glossary.jsf

23:58:31,363 INFO  [stdout] (http-localhost- rewrite.getRequest.getAttribute = org.ocpsoft.rewrite.servlet.impl.HttpRewriteContextImpl@682e8f6

23:58:31,363 INFO  [stdout] (http-localhost- resultHandlers = [org.ocpsoft.rewrite.servlet.impl.HttpRewriteResultHandler@7a9b0ccb]

23:58:31,363 INFO  [stdout] (http-localhost- operation.getEvent = InboundRewrite [POST url=http://localhost:8080/captor/project/2/glossary?cid=4, flow=UN_HANDLED, dispatchResource=/glossary.jsf]

23:58:31,363 ERROR [stderr] (http-localhost- NullPointerException caught