4 Replies Latest reply on Nov 27, 2007 6:19 PM by Arbi Sookazian

    core resource-loader for resource bundles

    Arbi Sookazian Master

      This is on pg. 156 of SEAM2.0 reference pdf. Does this go in the components.xml? I didn't see any reference to "resource-loader" in my seam-gen'd project...

      <core:resource-loader>
      <core:bundle-names>
      <value>mycompany_messages</value>
      <value>standard_messages</value>
      </core:bundle-names>
      </core:resource-loader>


        • 1. Re: core resource-loader for resource bundles
          Pete Muir Master

          Yes. By default messages is loaded so seam-gen doesn't need to specify this.

          • 2. Re: core resource-loader for resource bundles
            Arbi Sookazian Master

            Contents of securityAudit.properties is as follows in myProject/resources folder:

            test1=Arbi
            test2=Sookazian
            test3=Britney Spears


            I added following xml to my components.xml:

            <core:resource-loader>
             <core:bundle-names>
             <value>securityAudit</value>
             </core:bundle-names>
             </core:resource-loader>


            The following snippet is from my SFSB:

            import java.util.ResourceBundle;
            import org.jboss.seam.core.ResourceLoader;
            
            ResourceLoader resourceLoader = ResourceLoader.instance();
            
             String[] bundleNames = resourceLoader.getBundleNames();
            
             ResourceBundle resourceBundle = resourceLoader.loadBundle("securityAudit");


            In the debugger after the last line of code executes above, resourceBundle is null even though bundleNames[0] is "securityAudit". There is no exception in the log after entering the method so not sure what's wrong here...

            Do you need to supply the path as follows?

            resourceLoader.loadBundle("resources/securityAudit")


            • 3. Re: core resource-loader for resource bundles
              Pierre Raoul Novice

              You can use directly something like:

              java.util.ResourceBundle resourceBundle = org.jboss.seam.core.ResourceBundle.instance();
              String message = resourceBundle.getString(key);
              


              • 4. Re: core resource-loader for resource bundles
                Arbi Sookazian Master

                I tried that and got the below stack trace. How will it know which resource bundle to process???

                Exception during request processing:
                Caused by javax.servlet.ServletException with message: "#{securityAuditAction.submit}: javax.ejb.EJBTransactionRolledbackException: Can't find resource for bundle org.jboss.seam.core.SeamResourceBundle, key test1"
                javax.faces.webapp.FacesServlet.service(FacesServlet.java:256)
                org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
                org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                jcifs.http.NtlmHttpFilter.doFilter(NtlmHttpFilter.java:118)
                org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
                org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
                org.jboss.seam.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:68)
                org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:85)
                org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
                org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:44)
                org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:141)
                org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:281)
                org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:60)
                org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:58)
                org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
                org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
                org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
                org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
                org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
                org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
                org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
                org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433)
                org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
                org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
                org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
                org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
                org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
                org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:241)
                org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
                org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:580)
                org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
                java.lang.Thread.run(Unknown Source)