1 Reply Latest reply on Jul 25, 2006 11:55 AM by gavin.king

    Logging using component from different contexts

      I'm using JBoss 4.0.4.GA + Seam 1.0.1.GA

      I try to log some debug information in a remote method of a SFSB.
      When I use:
      log.debug("***** The user name is : " + user.getName()); // [1]

      Everything is fine.

      When I use:
      log.debug("***** The user name is : #{user.name}"); // [2]

      I get a NullPointerException. I use this in some other places and
      it works fine.
      Looking again at the doc, I came to the conclusion that [2] works only if the seam components are in the same context (which is not the case here).

      If someone can confirm this, so I don't need to worry about something wrong in the code, that would be great.


      Thanks.

      Below is the code and stacktrace.



      @Stateful
      @Name("test")
      @Scope(ScopeType.EVENT)
      public class TestAction implements Test {
      
       @In(create = true)
       @Out(scope = ScopeType.SESSION)
       private User user;
      
       public String doSomething() {
      
       if ((user.getName() == null) || (user.getName().equals(""))) {
       log.debug("***** No user name");
       return "";
       }
       log.debug("***** The user name is : #{user.name}"); // throws an exception
       log.debug("***** The user name is : " + user.getName()); // works fine
       return user.getName();
       }
      
       @Destroy
       @Remove
       public void destroy() {
       }
      }
      
      


      @Local
      public interface Sites {
      
       @WebRemote
       public String doSomething();
      
       public void destroy();
      }
      


      @Stateless
      @Name("user")
      @Scope(ScopeType.SESSION)
      public class UserBean implements User {
      
       private String name = null;
      
       public UserBean() {
       }
      
       public UserBean(String name) {
       this.name = name;
       }
      
       public String getName() {
       return name;
       }
      
       public void setName(String name) {
       this.name = name;
       }
      }
      
      


      @Local
      public interface User extends Serializable {
      
       public String getName();
       public void setName(String name);
      }
      
      


      I get the following exception:

      2006-07-25 11:16:34,000 WARN [org.jboss.seam.core.Interpolator] exception interpolating string: ***** The user name is : #{user.name}
      java.lang.NullPointerException
       at org.jboss.seam.core.Interpolator.interpolate(Interpolator.java:70)
       at org.jboss.seam.log.LogImpl.interpolate(LogImpl.java:158)
       at org.jboss.seam.log.LogImpl.debug(LogImpl.java:78)
       at com.myapp.app.actions.header.TestAction.doSomething(TestAction.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:585)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:112)
       at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:166)
       at org.jboss.seam.interceptors.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
       at org.jboss.seam.interceptors.ValidationInterceptor.validateTargetComponent(ValidationInterceptor.java:64)
       at sun.reflect.GeneratedMethodAccessor342.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.jboss.seam.util.Reflections.invoke(Reflections.java:13)
       at org.jboss.seam.interceptors.Interceptor.aroundInvoke(Interceptor.java:90)
       at org.jboss.seam.interceptors.SeamInvocationContext.proceed(SeamInvocationContext.java:60)
       at org.jboss.seam.interceptors.OutcomeInterceptor.interceptOutcome(OutcomeInterceptor.java:21)
       at sun.reflect.GeneratedMethodAccessor341.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.jboss.seam.util.Reflections.invoke(Reflections.java:13)
       at org.jboss.seam.interceptors.Interceptor.aroundInvoke(Interceptor.java:90)
       at org.jboss.seam.interceptors.SeamInvocationContext.proceed(SeamInvocationContext.java:60)
       at org.jboss.seam.interceptors.RollbackInterceptor.rollbackIfNecessary(RollbackInterceptor.java:30)
       at sun.reflect.GeneratedMethodAccessor340.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.jboss.seam.util.Reflections.invoke(Reflections.java:13)
       at org.jboss.seam.interceptors.Interceptor.aroundInvoke(Interceptor.java:90)
       at org.jboss.seam.interceptors.SeamInvocationContext.proceed(SeamInvocationContext.java:60)
       at org.jboss.seam.interceptors.BijectionInterceptor.bijectTargetComponent(BijectionInterceptor.java:33)
       at sun.reflect.GeneratedMethodAccessor339.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.jboss.seam.util.Reflections.invoke(Reflections.java:13)
       at org.jboss.seam.interceptors.Interceptor.aroundInvoke(Interceptor.java:90)
       at org.jboss.seam.interceptors.SeamInvocationContext.proceed(SeamInvocationContext.java:60)
       at org.jboss.seam.interceptors.ConversationInterceptor.endOrBeginLongRunningConversation(ConversationInterceptor.java:82)
       at sun.reflect.GeneratedMethodAccessor338.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.jboss.seam.util.Reflections.invoke(Reflections.java:13)
       at org.jboss.seam.interceptors.Interceptor.aroundInvoke(Interceptor.java:90)
       at org.jboss.seam.interceptors.SeamInvocationContext.proceed(SeamInvocationContext.java:60)
       at org.jboss.seam.interceptors.BusinessProcessInterceptor.manageBusinessProcessContext(BusinessProcessInterceptor.java:60)
       at sun.reflect.GeneratedMethodAccessor337.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.jboss.seam.util.Reflections.invoke(Reflections.java:13)
       at org.jboss.seam.interceptors.Interceptor.aroundInvoke(Interceptor.java:90)
       at org.jboss.seam.interceptors.SeamInvocationContext.proceed(SeamInvocationContext.java:60)
       at org.jboss.seam.interceptors.RemoveInterceptor.removeIfNecessary(RemoveInterceptor.java:39)
       at sun.reflect.GeneratedMethodAccessor336.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.jboss.seam.util.Reflections.invoke(Reflections.java:13)
       at org.jboss.seam.interceptors.Interceptor.aroundInvoke(Interceptor.java:90)
       at org.jboss.seam.interceptors.SeamInvocationContext.proceed(SeamInvocationContext.java:60)
       at org.jboss.seam.ejb.SeamInterceptor.aroundInvokeInContexts(SeamInterceptor.java:73)
       at org.jboss.seam.ejb.SeamInterceptor.aroundInvoke(SeamInterceptor.java:45)
       at sun.reflect.GeneratedMethodAccessor326.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:118)
       at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.entity.ExtendedPersistenceContextPropagationInterceptor.invoke(ExtendedPersistenceContextPropagationInterceptor.java:57)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:79)
       at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:197)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.stateful.StatefulInstanceInterceptor.invoke(StatefulInstanceInterceptor.java:81)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:78)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:47)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.stateful.StatefulContainer.localInvoke(StatefulContainer.java:188)
       at org.jboss.ejb3.stateful.StatefulLocalProxy.invoke(StatefulLocalProxy.java:98)
       at $Proxy386.getCurrentLocation(Unknown Source)
       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:585)
       at org.jboss.seam.remoting.Call.execute(Call.java:121)
       at org.jboss.seam.remoting.ExecutionHandler.handle(ExecutionHandler.java:92)
       at org.jboss.seam.remoting.SeamRemotingServlet.doPost(SeamRemotingServlet.java:56)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.jboss.seam.servlet.SeamExceptionFilter.doFilter(SeamExceptionFilter.java:45)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
       at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
       at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
       at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
       at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
       at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
       at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
       at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
       at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
       at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
       at java.lang.Thread.run(Thread.java:595)
      2006-07-25 11:16:34,093 DEBUG [com.myapp.app.actions.header.TestAction] ***** The user name is :