2 Replies Latest reply on Feb 23, 2010 10:17 PM by samdoyle

    Expressions, Interpolate called from code throws NPE

      We're using Expressions to invoke methods, and we've recently tried to use both Expressions and Interpolate to evaluate EL to a String value through a SFSB.


      What we're finding is that we can't; we always receive a NullPointerException, but the stack trace is very unclear.  What is the NPE?  We've tried grabbing Expressions/Interpolator in many ways, including:
      - injection
      - grabbing Seam's instance of the components
      - Interpolator.instance()


      No matter what we do, we always receive an NPE.  We're running Seam 2.1.2.


      Lastly, we can use #{interpolator.interpolate} inside of JSF, and it works like a charm.  But we can't call it from Java code, period, without a resulting NPE.


      Here is a sample.




      Interpolator interpolator = (Interpolator) Component.getInstance(Interpolator.class, true);
      
                  try {
      
             log.debug(interpolator.interpolate("#{messages['validator.noUserSelected']}"));
      
                 }
                  catch (Exception e)
                  {
                      e.printStackTrace();
                  }



      NOTE: We once had this working on JBoss AS, but not we're using Weblogic 10.3.1.  The truth of the matter is that I don't think this is related, but it could be.  Everything else has been working fine under WebLogic.



      Thanks.

        • 1. Re: Expressions, Interpolate called from code throws NPE

          Just wanted to share the exception that we get....




          java.lang.NullPointerException
                  at com.bah.englink.authentication.CardAuthManager.authenticateCert(CardAuthManager.java:67)
                  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                  at java.lang.reflect.Method.invoke(Method.java:597)
                  at com.bea.core.repackaged.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:310)
                  at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
                  at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
                  at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)
          
                  at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119)
                  at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
                  at com.bea.core.repackaged.springframework.jee.spi.MethodInvocationVisitorImpl.visit(MethodInvocationVisitorImpl.java:37)
                  at weblogic.ejb.container.injection.EnvironmentInterceptorCallbackImpl.callback(EnvironmentInterceptorCallbackImpl.java:54)
                  at com.bea.core.repackaged.springframework.jee.spi.EnvironmentInterceptor.invoke(EnvironmentInterceptor.java:50)
                  at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
                  at com.bea.core.repackaged.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
                  at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
                  at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)
          
                  at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119)
                  at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
                  at com.bea.core.repackaged.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
                  at $Proxy179.authenticateCert(Unknown Source)
                  at com.bah.englink.authentication.CardAuthManager_wwndcw_CardAuthManagerLocalImpl.authenticateCert(CardAuthManager_wwndcw_CardAuthManagerLocal
          Impl.java:141)
                  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                  at java.lang.reflect.Method.invoke(Method.java:597)
                  at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
                  at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:32)
                  at org.jboss.seam.intercept.ClientSideInterceptor$1.proceed(ClientSideInterceptor.java:76)
                  at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
                  at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)
                  at org.jboss.seam.intercept.ClientSideInterceptor.invoke(ClientSideInterceptor.java:54)
                  at org.javassist.tmp.java.lang.Object_$$_javassist_seam_6.authenticateCert(Object_$$_javassist_seam_6.java)
                  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                  at java.lang.reflect.Method.invoke(Method.java:597)
                  at org.jboss.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:335)
                  at org.jboss.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:348)
                  at org.jboss.el.parser.AstPropertySuffix.invoke(AstPropertySuffix.java:58)
                  at org.jboss.el.parser.AstValue.invoke(AstValue.java:96)
                  at org.jboss.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)
                  at com.sun.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:68)
                  at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88)
                  at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
                  at javax.faces.component.UICommand.broadcast(UICommand.java:387)
                  at org.ajax4jsf.component.AjaxViewRoot.processEvents(AjaxViewRoot.java:324)
                  at org.ajax4jsf.component.AjaxViewRoot.broadcastEvents(AjaxViewRoot.java:299)
                  at org.ajax4jsf.component.AjaxViewRoot.processPhase(AjaxViewRoot.java:256)
                  at org.ajax4jsf.component.AjaxViewRoot.processApplication(AjaxViewRoot.java:469)
                  at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:82)
                  at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
                  at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
                  at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
                  at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
                  at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
                  at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:292)
                  at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
                  at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
                  at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
                  at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
                  at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
                  at org.jboss.seam.web.IdentityFilter.doFilter(IdentityFilter.java:40)
                  at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                  at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:90)
                  at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                  at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
                  at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                  at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
                  at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                  at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:178)
                  at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
                  at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:388)
                  at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:515)
                  at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:56)
                  at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                  at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:60)
                  at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                  at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
                  at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
                  at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27)
                  at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
                  at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3588)
                  at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
                  at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
                  at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2200)
                  at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2106)
                  at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1428)
                  at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
                  at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)



          • 2. Re: Expressions, Interpolate called from code throws NPE
            samdoyle
            Odd, you can try two alternatives:
            1.) Interpolator.instance(). ... which just does return (Interpolator) Component.getInstance(Interpolator.class, ScopeType.APPLICATION); if applicationcontext is active.
            2.) Interpolator interpolator = (Interpolator) Component.getInstance("org.jboss.seam.core.interpolator")