7 Replies Latest reply on Jun 23, 2011 5:26 PM by mgvanbochove

    SeamResourceBundle or injected messages are always null

    dish13

      I'm trying to inject Seam messages into a Seam component (EJB) but no matter where I place the messages.properties (currently I have in the WEB-INF/classes) the variable is always null. I've also tried placing the messages.properties file in the ejbModule but it is always null.


      Any recommendations?

        • 1. Re: SeamResourceBundle or injected messages are always null
          babazs
          WEB-INf/classs should be a good place for this.

          And you must define the following lines in the components.xml too:

               <core:resource-loader>
                    <core:bundle-names>
                         <value>messages_first</value>
                         <value>messages_second</value>
                    </core:bundle-names>
               </core:resource-loader>
          • 2. Re: SeamResourceBundle or injected messages are always null
            dish13

            I don't understand; why messagesfirst and messagessecond? I have only one property file (messages.properties).

            • 3. Re: SeamResourceBundle or injected messages are always null
              ranophoenix
              It was only an example (you can have more than one property file). In your case use:

              <core:resource-loader>
                <core:bundle-names>
                 <value>messages</value>
                </core:bundle-names>
              </core:resource-loader>
              • 4. Re: SeamResourceBundle or injected messages are always null
                dish13

                Yes, but my resource bundle is already define in my components.xml and still when I inject the messages is null.
                I've tried @In(value="#{messages['test']}") private String testMsg; and I have no problems.

                • 5. Re: SeamResourceBundle or injected messages are always null
                  blabno

                  Amy, please post your full class code where you do injection. For entire map of messages it should be :


                  @In
                  private Map<String,String> messages;



                  I also do not understand the last sentence. Do you mean that injecting particular message works and injecting whole bundle fails ?

                  • 6. Re: SeamResourceBundle or injected messages are always null
                    dish13

                    Yes, I have no problems with injecting a particular message. I only have problems when injecting the message map.


                    Here's the class:




                    
                    @Stateful
                    @Name("pos")
                    @Scope(ScopeType.CONVERSATION)
                    @Interceptors( { org.jboss.seam.ejb.SeamInterceptor.class })
                    public class POSActionBean implements POSAction, Serializable {
                    
                         private static final long serialVersionUID = 20100125L;
                         @Logger
                         private Log log;
                         @In
                         StatusMessages statusMessages;
                         @In
                         EntityManager entityManager;
                         @In(scope=ScopeType.SESSION)
                         private Employee currEmployee;
                         @In
                         private Map<String, String> messages;
                    
                         @Begin(join = true, flushMode = FlushModeType.MANUAL)
                         public String begin() {
                              return "pos";
                         }
                    
                         public String next() {
                              return "services";
                         }
                    
                         @End
                         public String end() {
                              return "end";
                         }
                    
                         @Destroy
                         @Remove
                         public void destroy() {
                         };
                    }




                    • 7. Re: SeamResourceBundle or injected messages are always null
                      mgvanbochove

                      Hi,


                      I had a simular problem. I think I know how you can solve your problem (unless you solved it already).
                      Change the lines which inject your messages Map with:


                        @In(value="#{messages}")
                        private Map<String, String> messages;

                      You use a EJB (like I did). The EJB is not created by Seam and I think the @In doesn't work well for the built in resource bundle seam component configured in components.xml. Maybe this is a bug?
                      It also explains why injecting a single message works, because the el expression for messages is used.