1

El error es este:

> ADVERTENCIA:   /paginas/correo/correo.xhtml @52,102
> target="#{correoControlador.enviar}": The class
> 'com.pigbreding.modelo.ManageBeans.CorreoControlador' does not have
> the property 'enviar'. javax.el.PropertyNotFoundException:
> /paginas/correo/correo.xhtml @52,102
> target="#{correoControlador.enviar}": The class
> 'com.pigbreding.modelo.ManageBeans.CorreoControlador' does not have
> the property 'enviar'.    at
> com.sun.faces.facelets.el.TagValueExpression.getType(TagValueExpression.java:88)
>   at
> com.sun.faces.facelets.tag.jsf.core.SetPropertyActionListenerHandler$SetPropertyListener.processAction(SetPropertyActionListenerHandler.java:200)
>   at javax.faces.event.ActionEvent.processListener(ActionEvent.java:96)
>   at
> javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:514)
>   at javax.faces.component.UICommand.broadcast(UICommand.java:235)    at
> javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:871)
>   at
> javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1419)
>   at
> com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:82)
>   at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)    at
> com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:201)
>   at
> javax.faces.webapp.FacesServlet.executeLifecyle(FacesServlet.java:731)
>   at javax.faces.webapp.FacesServlet.service(FacesServlet.java:475)   at
> org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1622)
>   at
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:258)
>   at
> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160)
>   at
> org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:654)
>   at
> org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:593)
>   at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99)   at
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:159)
>   at
> org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:371)
>   at
> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:238)
>   at
> com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:516)
>   at
> com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:213)
>   at
> org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:206)
>   at
> org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:180)
>   at
> org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:242)
>   at
> org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
>   at
> org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:284)
>   at
> org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:201)
>   at
> org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:133)
>   at
> org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:112)
>   at
> org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
>   at
> org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:539)
>   at
> org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112)
>   at
> org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117)
>   at
> org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56)
>   at
> org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137)
>   at
> org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:593)
>   at
> org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:573)
>   at java.lang.Thread.run(Thread.java:748) Caused by:
> javax.el.PropertyNotFoundException: The class
> 'com.pigbreding.modelo.ManageBeans.CorreoControlador' does not have
> the property 'enviar'.    at
> javax.el.BeanELResolver.getBeanProperty(BeanELResolver.java:731)  at
> javax.el.BeanELResolver.getType(BeanELResolver.java:301)  at
> com.sun.faces.el.DemuxCompositeELResolver._getType(DemuxCompositeELResolver.java:220)
>   at
> com.sun.faces.el.DemuxCompositeELResolver.getType(DemuxCompositeELResolver.java:248)
>   at com.sun.el.parser.AstValue.getType(AstValue.java:92)     at
> com.sun.el.ValueExpressionImpl.getType(ValueExpressionImpl.java:201)
>   at
> org.jboss.weld.module.web.el.WeldValueExpression.getType(WeldValueExpression.java:93)
>   at
> com.sun.faces.facelets.el.TagValueExpression.getType(TagValueExpression.java:86)
>   ... 39 more
> 
> FATAL:   JSF1073: se ha interceptado javax.faces.FacesException
> durante el procesamiento de INVOKE_APPLICATION 5 :
> UIComponent-ClientId=, Mensaje=/paginas/correo/correo.xhtml @52,102
> target="#{correoControlador.enviar}": The class
> 'com.pigbreding.modelo.ManageBeans.CorreoControlador' does not have
> the property 'enviar'. FATAL:   /paginas/correo/correo.xhtml @52,102
> target="#{correoControlador.enviar}": The class
> 'com.pigbreding.modelo.ManageBeans.CorreoControlador' does not have
> the property 'enviar'. javax.faces.FacesException:
> /paginas/correo/correo.xhtml @52,102
> target="#{correoControlador.enviar}": The class
> 'com.pigbreding.modelo.ManageBeans.CorreoControlador' does not have
> the property 'enviar'.    at
> com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:90)
>   at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)    at
> com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:201)
>   at
> javax.faces.webapp.FacesServlet.executeLifecyle(FacesServlet.java:731)
>   at javax.faces.webapp.FacesServlet.service(FacesServlet.java:475)   at
> org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1622)
>   at
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:258)
>   at
> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160)
>   at
> org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:654)
>   at
> org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:593)
>   at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99)   at
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:159)
>   at
> org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:371)
>   at
> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:238)
>   at
> com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:516)
>   at
> com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:213)
>   at
> org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:206)
>   at
> org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:180)
>   at
> org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:242)
>   at
> org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
>   at
> org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:284)
>   at
> org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:201)
>   at
> org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:133)
>   at
> org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:112)
>   at
> org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
>   at
> org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:539)
>   at
> org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112)
>   at
> org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117)
>   at
> org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56)
>   at
> org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137)
>   at
> org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:593)
>   at
> org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:573)
>   at java.lang.Thread.run(Thread.java:748) Caused by:
> javax.el.PropertyNotFoundException: /paginas/correo/correo.xhtml
> @52,102 target="#{correoControlador.enviar}": The class
> 'com.pigbreding.modelo.ManageBeans.CorreoControlador' does not have
> the property 'enviar'.    at
> com.sun.faces.facelets.el.TagValueExpression.getType(TagValueExpression.java:88)
>   at
> com.sun.faces.facelets.tag.jsf.core.SetPropertyActionListenerHandler$SetPropertyListener.processAction(SetPropertyActionListenerHandler.java:200)
>   at javax.faces.event.ActionEvent.processListener(ActionEvent.java:96)
>   at
> javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:514)
>   at javax.faces.component.UICommand.broadcast(UICommand.java:235)    at
> javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:871)
>   at
> javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1419)
>   at
> com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:82)
>   ... 32 more Caused by: javax.el.PropertyNotFoundException: The class
> 'com.pigbreding.modelo.ManageBeans.CorreoControlador' does not have
> the property 'enviar'.    at
> javax.el.BeanELResolver.getBeanProperty(BeanELResolver.java:731)  at
> javax.el.BeanELResolver.getType(BeanELResolver.java:301)  at
> com.sun.faces.el.DemuxCompositeELResolver._getType(DemuxCompositeELResolver.java:220)
>   at
> com.sun.faces.el.DemuxCompositeELResolver.getType(DemuxCompositeELResolver.java:248)
>   at com.sun.el.parser.AstValue.getType(AstValue.java:92)     at
> com.sun.el.ValueExpressionImpl.getType(ValueExpressionImpl.java:201)
>   at
> org.jboss.weld.module.web.el.WeldValueExpression.getType(WeldValueExpression.java:93)
>   at
> com.sun.faces.facelets.el.TagValueExpression.getType(TagValueExpression.java:86)
>   ... 39 more

El html es este

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:h="http://xmlns.jcp.org/jsf/html"
                xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
                template="/WEB-INF/template/main-form.xhtml"
                xmlns:f="http://xmlns.jcp.org/jsf/core"
                xmlns:a="http://xmlns.jcp.org/jsf/passthrough">

    <ui:define name="estilos">
        <link rel="stylesheet" href="#{request.contextPath}/resources/css/porquinansa.css"/>
        <link rel="stylesheet" href="#{request.contextPath}/resources/css/rpt-cerdo.css"/>
    </ui:define>
    <ui:define name="contenido">


        <h1 class="titulomenu col-sm-12 col-md-12 col-lg-12 col-xl-12">Enviar Correo
        </h1>

        <h:form class="container" id="frmAsignaTareas" >

            <div class="form-group">



                <div class="col-md-12">
                    <h:outputLabel class="control-label" for="destinatario" value="Para"> 
                    </h:outputLabel>

                    <h:inputText    class="form-control" 
                                   value="#{correoControlador.destinatario}" />
                </div>

                <div class="col-md-12">
                    <h:outputLabel class="control-label" for="asunto" value="Asunto"> 
                    </h:outputLabel>

                    <h:inputText   class="form-control" 
                                   value="#{correoControlador.asunto}" />
                </div>

                <div class="col-md-12">
                    <h:outputLabel class="control-label" for="cuerpo" value="Mensaje"> 
                    </h:outputLabel>

                    <h:inputTextarea    class="form-control" 
                                       value="#{correoControlador.cuerpo}" />
                </div>

                <div class="form-group">
                    <h:commandButton type="submit" class="btn btn-dark btn-lg btn-block " value="Enviar" action="#{correoControlador.enviar()}">
                        
                    </h:commandButton>
                </div>
            </div>
        </h:form>
    </ui:define>
    <ui:define name="scripts-propios">
        <script src="resources/js/scripts.js"></script>
    </ui:define>

</ui:composition>

El controlador de Mail es este

package com.pigbreding.modelo.ManageBeans;

import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.Properties;
import javax.mail.BodyPart;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Multipart;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeBodyPart;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMultipart;

public class MailControlador {

    private final static String KEY_SMTP_SERVER = "mail.smtp.host";
    private final static String KEY_FROM = "mail.smtp.user";
    private final static String KEY_PASSWORD = "mail.smtp.password";

    private static Properties props;

    private static void loadConfig() {
        if (props == null) {

            props = new Properties();
            props.put(KEY_SMTP_SERVER, "smtp.gmail.com"); //El servidor SMTP de google 
            props.put(KEY_FROM, "CORREO"); //Correo desde vamos a enviar el correo
            props.put(KEY_PASSWORD, "CLAVE");//la clave de la cuenta de correo desde donde se enviara el correo
            props.put("mail.smtp.auth", "true");//Usar autenticacion mediante usuario y clave
            props.put("mail.smtp.ssl.trust", "smtp.gmail.com");
            props.put("mail.smtp.starttls.enable", "true");// para conectar de manera segura al servidor SMTP
            props.put("mail.smtp.port", "25"); //el puerto smtp seguro de google, el puerto por default es el 25

        }
    }

    public static void sendMail(String destinatario, String asunto, String cuerpo) {
        loadConfig();
        Session session = Session.getDefaultInstance(props);
        MimeMessage message = new MimeMessage(session);

        try {
            message.setFrom(new InternetAddress(props.getProperty(KEY_FROM)));
            message.addRecipient(Message.RecipientType.TO,
                    new InternetAddress(destinatario));//Se podrian añadir varios de la misma manera
            message.setSubject(asunto);
            message.setText(cuerpo);
            
            Transport trans = session.getTransport("smtp");
            trans.connect(props.getProperty(KEY_SMTP_SERVER),
                    props.getProperty(KEY_FROM),
                    props.getProperty(KEY_PASSWORD));
            trans.sendMessage(message,message.getAllRecipients());
            trans.close();
        } catch (MessagingException  me) {
            me.printStackTrace(); //Si se produce error
            
        }
      
      
       
    }
    public static void sendMailHTML(String destinatarios, String asuntos, String cuerpoHTML) {
        loadConfig();
        Session session = Session.getDefaultInstance(props);
        MimeMessage message = new MimeMessage(session);

        try {
            message.setFrom(new InternetAddress(props.getProperty(KEY_FROM)));
            message.addRecipients(Message.RecipientType.TO,destinatarios);
            message.setSubject(asuntos);
            Multipart parts = new MimeMultipart();
            BodyPart bodyMail = new MimeBodyPart();
            bodyMail.setContent(cuerpoHTML, "text/html");
            parts.addBodyPart(bodyMail);
            message.setContent(parts);
            Transport transport = session.getTransport("smtp");
            transport.connect(props.getProperty(KEY_SMTP_SERVER),
                    props.getProperty(KEY_FROM),
                    props.getProperty(KEY_PASSWORD));
            transport.sendMessage(message,message.getAllRecipients());
            transport.close();
        } catch (MessagingException  me) {
            me.printStackTrace(); //Si se produce error
            
        }
      
        
       
    }
    
     public static void sendMailHTML(String destinatarios, String asuntos, String cuerpoHTML, List<File> files) throws IOException {
        loadConfig();
        Session session = Session.getDefaultInstance(props);
        MimeMessage message = new MimeMessage(session);

        try {
            message.setFrom(new InternetAddress(props.getProperty(KEY_FROM)));
            message.addRecipients(Message.RecipientType.TO,destinatarios);
            message.setSubject(asuntos);
            Multipart parts = new MimeMultipart();
            BodyPart bodyMail = new MimeBodyPart();
            bodyMail.setContent(cuerpoHTML, "text/html");
            parts.addBodyPart(bodyMail);
            for (File file : files){
                MimeBodyPart attached = new MimeBodyPart();
                attached.attachFile(file);
                parts.addBodyPart(attached);   
            }
            message.setContent(parts);
            Transport transport = session.getTransport("smtp");
            transport.connect(props.getProperty(KEY_SMTP_SERVER),
                    props.getProperty(KEY_FROM),
                    props.getProperty(KEY_PASSWORD));
            transport.sendMessage(message,message.getAllRecipients());
            transport.close();
        } catch (MessagingException  me) {
            me.printStackTrace(); //Si se produce error
            
        }  
    }
    }

Y donde tengo el controlador para hacer el método de enviar es este

    /*
     * To change this license header, choose License Headers in Project Properties.
     * To change this template file, choose Tools | Templates
     * and open the template in the editor.
     */
    package com.pigbreding.modelo.ManageBeans;
    
    import java.io.Serializable;
    import javax.inject.Named;
    import javax.faces.view.ViewScoped;
    
    /**
     *
     * @author jennt_000
     */
    @Named(value = "correoControlador")
    @ViewScoped
    public class CorreoControlador implements Serializable {

    /*private String from;*/
    private String destinatario;
    private String asunto;
    private String cuerpo;

    public CorreoControlador() {
    }

    /*public String getFrom() {
        return from;
    }

    public void setFrom(String from) {
        this.from = from;
    }*/
    public String getAsunto() {
        return asunto;
    }

    public void setAsunto(String asunto) {
        this.asunto = asunto;
    }

    public String getDestinatario() {
        return destinatario;
    }

    public void setDestinatario(String destinatario) {
        this.destinatario = destinatario;
    }

    public String getCuerpo() {
        return cuerpo;
    }

    public void setCuerpo(String cuerpo) {
        this.cuerpo = cuerpo;
    }

    public String enviar() {
        try {
            System.out.println(destinatario);
            System.out.println(asunto);
            System.out.println(cuerpo);
            MailControlador mailControlador = new MailControlador();
            mailControlador.sendMail(destinatario, asunto, cuerpo);

        } catch (Exception e) {
        }
        return null;
    }
    }
1
  • El controlador de Mail le borre la contraseña y correo por razones de seguridad, ya que este es un sitio publico. Gracias Commented el 18 may. 2018 a las 5:10

1 respuesta 1

1

El error que veo en el stacktrace es

/paginas/correo/correo.xhtml @52,102 target="#{correoControlador.enviar}": The class 'com.pigbreding.modelo.ManageBeans.CorreoControlador' does not have the property 'enviar'. javax.el.PropertyNotFoundException: /paginas/correo/correo.xhtml @52,102 target="#{correoControlador.enviar}": The class 'com.pigbreding.modelo.ManageBeans.CorreoControlador' does not have the property 'enviar'.

Esto se da típicamente cuando queremos mostrar un atributo de nuestro bean y no existe el respectivo getter de dicho atributo. Veo que el error se dá en la vista correo.xhtml. El fragmento de xhtml que pegaste, ¿Pertenece al archivo que te digo?

Tu Respuesta

By clicking “Publica tu respuesta”, you agree to our terms of service and acknowledge you have read our privacy policy.

¿No es la respuesta que buscas? Examina otras preguntas con la etiqueta o formula tu propia pregunta.