3 Replies Latest reply on Apr 10, 2009 3:53 AM by walterjwhite

    Null Pointer Exception with Seam Mail

    walterjwhite

      Hi all,


      When trying to send an email, I get an exception reporting emailAddress is not a property of HashSet which is the class I'm using to hold all the recipients.


      <ui:repeat value="#{recipients}" var="recipient">
           <m:to name="#{recipient.name}" address="#{recipient.emailAddress}"/>
      </ui:repeat>
      



      javax.el.PropertyNotFoundException: /email/template/default.xhtml @10,72 address="#{recipient.emailAddress}": The class 'java.util.HashSet' does not have the property 'emailAddress'.
      



      <ui:composition xmlns="http://www.w3.org/1999/xhtml"
                          xmlns:ui="http://java.sun.com/jsf/facelets"
                          xmlns:s="http://jboss.com/products/seam/taglib"
                          xmlns:m="http://jboss.com/products/seam/mail"
                          xmlns:h="http://java.sun.com/jsf/html"
                          xmlns:f="http://java.sun.com/jsf/core">
           <m:message>
                <m:from name="Website Email" address="websiteEmail@something.com" />
                <ui:repeat value="#{recipients}" var="recipient">
                     <m:to name="#{recipient.name}" address="#{recipient.emailAddress}"/>
                </ui:repeat>
                <m:replyTo name="Website Email" address="websiteEmail@something.com"/>
      
                <m:subject>
                     <ui:insert name="subject"/>
                </m:subject>
                <m:body>
                     <ui:insert name="body"/>
                </m:body>
           </m:message>
      </ui:composition>
      



      I tried simply putting this into a separate message without using a template and I get the same error.  Is there anything special I need to do in order to pass a list of users into this email message?



      Thanks,
      Walter

        • 1. Re: Null Pointer Exception with Seam Mail
          walterjwhite

          I started typing the wrong exception for the subject.


          It is a PropertyNotFoundException, the emailAddress property cannot be resolved on the recipient object which should be an instance of the User class.


          Walter

          • 2. Re: Null Pointer Exception with Seam Mail
            swd847

            ui:repeat does not support hashsets, only lists.

            • 3. Re: Null Pointer Exception with Seam Mail
              walterjwhite

              Hi,


              Thanks for your help, that was it.  I checked out later online to see that it does only support lists.  Can I ask the question, why aren't generic collections supported?


              It would be nice if I could use sets that way I wouldn't have to translate between a set and list.  I use a set to simply guarantee uniqueness.  I run a few different queries to get a list of recipients.


              Other than that, I am really happy with sending emails with Seam.  It works really well and allows me to easily create documents on the fly either in text, HTML, or PDF format.


              Thanks a bunch,
              Walter