1 Reply Latest reply on Dec 18, 2007 4:44 PM by Pete Muir

    ERROR:  #{messages} is not Serializable

    Daniel Hinojosa Master

      I am creating a custom validator that uses component injection for the first time, this one just check that there are no links in the entry. Here is the validator:

      @Name("noLinkValidator")
      //@BypassInterceptors
      @Validator
      public class NoLinkValidator implements javax.faces.validator.Validator, Serializable {
       @In("messages")
       private Map<String, String> messages;
      
      
       public void validate(FacesContext facesContext,
       UIComponent uiComponent,
       Object o) throws ValidatorException {
       if (!(o instanceof String)) throw new IllegalArgumentException("Value is expected is a String");
       String value = (String) o;
       Reader reader = new StringReader(value);
       BufferedReader bufferedReader = new BufferedReader(reader);
       String line;
       boolean fails = false;
       try {
       while ((line = bufferedReader.readLine()) != null) {
       if (line.contains("<a href")) fails = true;
       if (line.contains("[url")) fails = true;
       }
      
       } catch (IOException e) {
       //String summary = messages.get("value_cannot_be_read");
       //throw new ValidatorException(new FacesMessage(summary), e);
       }
      
       System.out.println(messages); //resolves to null
      
       if (fails) {
       //String summary = resourceBundle.getResourceBundle().getString("value_contains_links");
       //String detail = resourceBundle.getResourceBundle().getString("value_contains_link_detail");
       throw new ValidatorException
       (new FacesMessage(FacesMessage.SEVERITY_ERROR, "value_contains_links", "value_contains_link_detail"));
       }
       }
      }
      



      Here is the result
      java.io.NotSerializableException: org.jboss.seam.international.Messages$1
       at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1156)
       at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1509)
       at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1474)
       at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1392)
       at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1150)
       at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1509)
       at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1474)
       at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1392)
       at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1150)
       at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1509)
       at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1474)
       at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1392)
       at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1150)
       at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:326)
       at java.util.ArrayList.writeObject(ArrayList.java:570)
       at sun.reflect.GeneratedMethodAccessor1986.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:597)
       at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:945)
       at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1461)
       at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1392)
       at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1150)
       at java.io.ObjectOutputStream.writeArray(ObjectOutputStream.java:1338)
       at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1146)
       at java.io.ObjectOutputStream.writeArray(ObjectOutputStream.java:1338)
       at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1146)
       at java.io.ObjectOutputStream.writeArray(ObjectOutputStream.java:1338)
       at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1146)
       at java.io.ObjectOutputStream.writeArray(ObjectOutputStream.java:1338)
       at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1146)
       at java.io.ObjectOutputStream.writeArray(ObjectOutputStream.java:1338)
       at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1146)
       at java.io.ObjectOutputStream.writeArray(ObjectOutputStream.java:1338)
       at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1146)
       at java.io.ObjectOutputStream.writeArray(ObjectOutputStream.java:1338)
       at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1146)
       at java.io.ObjectOutputStream.writeArray(ObjectOutputStream.java:1338)
       at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1146)
       at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:326)
       at com.sun.faces.renderkit.ResponseStateManagerImpl.writeState(ResponseStateManagerImpl.java:244)
       at javax.faces.render.ResponseStateManager.writeState(ResponseStateManager.java:155)
       at com.sun.faces.application.StateManagerImpl.writeState(StateManagerImpl.java:298)
       at org.jboss.seam.jsf.SeamStateManager.writeState(SeamStateManager.java:70)
       at org.ajax4jsf.application.AjaxStateManager.writeState(AjaxStateManager.java:208)
       at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:620)
       at org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:108)
       at org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:216)
       at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:106)
       at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
       at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:144)
       at javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
       at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:85)
       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:44)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
       at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:141)
       at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:281)
       at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:60)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
       at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:58)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
       at org.jboss.seam.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:68)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
       at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
       at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
       at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
       at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433)
       at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
       at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
       at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
       at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:241)
       at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
       at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:580)
       at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
       at java.lang.Thread.run(Thread.java:619)
      



      Since nothing on the stack trace is under my domain, I assume it is a bug, is it?