4 Replies Latest reply on Jun 26, 2006 12:23 PM by Johannes Behrndt

    Problem injecting default resource bundle to session bean

    Johannes Behrndt Newbie

      Hello,

      I'm just starting with seam and managed to set up my project integrating ADF faces with facelets, MyFaces and Seam. Everything works so far but now I ran into a problem using the resource bundle in a session bean.
      I am using the default messages.properties and it works in my pages using EL #{messages.hello}

      Now I want to use the message directly in my session bean and tried to inject it as described in the reference doc:

      @In("#{messages['hello']}") private String hello;


      But it doesn't get injected, the string is still null.
      Even tried

      @In("#{messages.hello}") private String hello;


      which gives the same result.
      When I inject the messages Map

      @In(create=true) private Map<String, String> messages;


      a NullPointerException is thrown as soon as I try to access the map by

      private String hello = messages.get("hello");



      Does anyone have a hint for me?

      Thanks,
      johnnybe

        • 1. Re: Problem injecting default resource bundle to session bea
          Gavin King Master

          Show me the stack trace of the NPE, does it come from your code, of inside Seam?

          Does org.jboss.seam.core.Messages.getMessages() ever get called? (Try putting a breakpoint there.

          • 2. Re: Problem injecting default resource bundle to session bea
            Johannes Behrndt Newbie

            Hi gavin,

            the stack trace of the NPE is following:

            javax.faces.el.EvaluationException: /subscribe.xhtml @18,215 value="#{subscribe.email}": Exception getting value of property email of base of type : $Proxy113
             at com.sun.facelets.el.LegacyValueBinding.getValue(LegacyValueBinding.java:60)
             at oracle.adf.view.faces.bean.FacesBeanImpl.getProperty(FacesBeanImpl.java:55)
             at oracle.adfinternal.view.faces.renderkit.core.xhtml.ValueRenderer.getValue(ValueRenderer.java:63)
             at oracle.adfinternal.view.faces.renderkit.core.xhtml.ValueRenderer.getConvertedString(ValueRenderer.java:32)
             at oracle.adfinternal.view.faces.renderkit.core.xhtml.EditableValueRenderer.getConvertedString(EditableValueRenderer.java:135)
             at oracle.adfinternal.view.faces.renderkit.core.xhtml.SimpleInputTextRenderer.encodeAllAsElement(SimpleInputTextRenderer.java:100)
             at oracle.adfinternal.view.faces.renderkit.core.xhtml.FormElementRenderer.encodeAll(FormElementRenderer.java:48)
             at oracle.adfinternal.view.faces.renderkit.core.CoreRenderer.delegateRenderer(CoreRenderer.java:271)
             at oracle.adfinternal.view.faces.renderkit.core.xhtml.InputLabelAndMessageRenderer.renderFieldCellContents(InputLabelAndMessageRenderer.java:115)
             at oracle.adfinternal.view.faces.renderkit.core.xhtml.LabelAndMessageRenderer._renderFieldCell(LabelAndMessageRenderer.java:293)
             at oracle.adfinternal.view.faces.renderkit.core.xhtml.LabelAndMessageRenderer.encodeAll(LabelAndMessageRenderer.java:163)
             at oracle.adfinternal.view.faces.renderkit.core.xhtml.InputLabelAndMessageRenderer.encodeAll(InputLabelAndMessageRenderer.java:94)
             at oracle.adfinternal.view.faces.renderkit.core.CoreRenderer.encodeEnd(CoreRenderer.java:159)
             at oracle.adf.view.faces.component.UIXComponentBase.encodeEnd(UIXComponentBase.java:624)
             at oracle.adfinternal.view.faces.renderkit.RenderUtils.encodeRecursive(RenderUtils.java:54)
             at oracle.adfinternal.view.faces.renderkit.core.CoreRenderer.encodeChild(CoreRenderer.java:232)
             at oracle.adfinternal.view.faces.renderkit.core.CoreRenderer.encodeAllChildren(CoreRenderer.java:255)
             at oracle.adfinternal.view.faces.renderkit.core.xhtml.PanelPartialRootRenderer.renderContent(PanelPartialRootRenderer.java:65)
             at oracle.adfinternal.view.faces.renderkit.core.xhtml.BodyRenderer.renderContent(BodyRenderer.java:117)
             at oracle.adfinternal.view.faces.renderkit.core.xhtml.PanelPartialRootRenderer.encodeAll(PanelPartialRootRenderer.java:147)
             at oracle.adfinternal.view.faces.renderkit.core.xhtml.BodyRenderer.encodeAll(BodyRenderer.java:60)
             at oracle.adfinternal.view.faces.renderkit.core.CoreRenderer.encodeEnd(CoreRenderer.java:159)
             at oracle.adf.view.faces.component.UIXComponentBase.encodeEnd(UIXComponentBase.java:624)
             at com.sun.facelets.tag.jsf.ComponentSupport.encodeRecursive(ComponentSupport.java:242)
             at com.sun.facelets.tag.jsf.ComponentSupport.encodeRecursive(ComponentSupport.java:239)
             at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:554)
             at oracle.adfinternal.view.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:157)
             at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:384)
             at javax.faces.webapp.FacesServlet.service(FacesServlet.java:138)
             at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
             at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
             at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:144)
             at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
             at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
             at oracle.adfinternal.view.faces.webapp.AdfFacesFilterImpl._invokeDoFilter(AdfFacesFilterImpl.java:367)
             at oracle.adfinternal.view.faces.webapp.AdfFacesFilterImpl._doFilterImpl(AdfFacesFilterImpl.java:336)
             at oracle.adfinternal.view.faces.webapp.AdfFacesFilterImpl.doFilter(AdfFacesFilterImpl.java:196)
             at oracle.adf.view.faces.webapp.AdfFacesFilter.doFilter(AdfFacesFilter.java:87)
             at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
             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.seam.servlet.SeamRedirectFilter.doFilter(SeamRedirectFilter.java:30)
             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)
            Caused by: javax.faces.el.EvaluationException: Bean: $Proxy113, property: email
             at org.apache.myfaces.el.PropertyResolverImpl.getProperty(PropertyResolverImpl.java:442)
             at org.apache.myfaces.el.PropertyResolverImpl.getValue(PropertyResolverImpl.java:82)
             at com.sun.facelets.el.LegacyELContext$LegacyELResolver.getValue(LegacyELContext.java:141)
             at com.sun.el.parser.AstValue.getValue(AstValue.java:117)
             at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:192)
             at com.sun.facelets.el.TagValueExpression.getValue(TagValueExpression.java:71)
             at com.sun.facelets.el.LegacyValueBinding.getValue(LegacyValueBinding.java:56)
             ... 61 more
            Caused by: java.lang.reflect.InvocationTargetException
             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.apache.myfaces.el.PropertyResolverImpl.getProperty(PropertyResolverImpl.java:438)
             ... 67 more
            Caused by: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
             at org.jboss.ejb3.EJBContainer.construct(EJBContainer.java:471)
             at org.jboss.ejb3.AbstractPool.create(AbstractPool.java:62)
             at org.jboss.ejb3.ThreadlocalPool.get(ThreadlocalPool.java:48)
             at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:54)
             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.inv
            16:19:37,312 ERROR [STDERR] oke(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.stateless.StatelessContainer.localInvoke(StatelessContainer.java:181)
             at org.jboss.ejb3.stateless.StatelessLocalProxy.invoke(StatelessLocalProxy.java:79)
             at $Proxy113.getEmail(Unknown Source)
             ... 72 more
            Caused by: java.lang.reflect.InvocationTargetException
             at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
             at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
             at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
             at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
             at org.jboss.ejb3.EJBContainer.construct(EJBContainer.java:459)
             ... 85 more
            Caused by: java.lang.NullPointerException
             at de.teachers24.ejb3.session.SubscribeBean.<init>(SubscribeBean.java:29)
             ... 90 more


            So the NPE comes from my code and it's thrown in the line:

            private String email = messages.get("enterEmail");


            This is following right after:

            @In(create=true) private Map<String, String> messages;


            which tells me that the messages-map seems not to be injected.

            When I use the simpler syntax with just one line:

            @In("#{messages['enterEmail']}") private String email;


            org.jboss.seam.core.Messages.getMessages() does not get called.
            Though it does get called when evaluating the EL expressions with messages inside my xhtml.
            So it looks to me like injection for session beans is somehow not working.

            • 3. Re: Problem injecting default resource bundle to session bea
              Johannes Behrndt Newbie

              I just found out that it is not just a problem of injecting the messages bundle, since no injections at all are working within my bean.
              I checked everything I found in the forum for injection and nothing works for me.
              My JNDI pattern is set correctly and @Intercept(ALWAYS) doesn't work either.
              Strange thing is that there are no exceptions thrown concerning injection, i just get the NPE as soon as I try to acces one of the injected fields' methods.
              I can reconstruct this problem with the EntityManager. When I use @PersistenceContext it gets injected, when I use @In(create=true) it is null.

              • 4. Re: Problem injecting default resource bundle to session bea
                Johannes Behrndt Newbie

                I'm sorry. Tracked down the error to a mistake on my side. My packaging configuration was broken, so the Seam ejb-interceptor was not properly registered.

                Thanks for your patience with a newbie :-)