JavaMail API для получения электронной почты - PullRequest
0 голосов
/ 16 апреля 2020

Я хочу получать почту и количество непрочитанных писем с сервера gmail. Я посетил несколько постов и веб-сайтов, посвященных stackoverflow, но все приведенные коды не работали на моей стороне. Был бы признателен, если бы вы могли помочь мне с этим, так как я не знаю, что не так в коде. Ниже приведены мои коды:

public void getEmailNumber() throws NoSuchProviderException, MessagingException {
    final Properties props = new Properties();
    props.setProperty("mail.pop3.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
    props.setProperty("mail.pop3.socketFactory.fallback", "false");
    props.setProperty( "mail.pop3.host", "pop.gmail.com" );
    props.setProperty( "mail.pop3.user", "username");
    props.setProperty( "mail.pop3.password", "password");
    props.setProperty( "mail.pop3.ssl.enable", "true");
    props.setProperty( "mail.pop3.port", "995" );
    props.setProperty( "mail.pop3.auth", "true" );      
    props.setProperty("mail.pop3.starttls.enable", "true"); 

    Session session  = Session.getInstance(props);
    session.setDebug(true);

    Store store = session.getStore("pop3");
    store.connect("username", "password");         
    Folder folder = store.getDefaultFolder();
    folder.open(Folder.READ_ONLY);
    Message message[] = folder.getMessages();
    for ( int i = 0; i < message.length; i++ )
    {
      Message m = message[i];
          System.out.println( "-------------------------\nNachricht: " + i );
          System.out.println( "From: " + Arrays.toString(m.getFrom()) );
          System.out.println( "Topic: " + m.getSubject() );   


      if ( m.isMimeType("text/plain") )
        try {
            System.out.println( m.getContent() );
      } catch (IOException ex) {
          Logger.getLogger(AdminLoginManagedBean.class.getName()).log(Level.SEVERE, null, ex);
      }
    }
    folder.close( false );
    store.close();
}

Ошибка, которую я продолжал иметь:

    Severe:   Error Rendering View[/index.xhtml]
javax.enterprise.inject.CreationException
    at sun.reflect.GeneratedConstructorAccessor1175.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at java.lang.Class.newInstance(Class.java:442)
    at org.jboss.weld.security.NewInstanceAction.run(NewInstanceAction.java:33)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.jboss.weld.injection.Exceptions.rethrowException(Exceptions.java:40)
    at org.jboss.weld.injection.Exceptions.rethrowException(Exceptions.java:50)
    at org.jboss.weld.injection.Exceptions.rethrowException(Exceptions.java:90)
    at org.jboss.weld.injection.ConstructorInjectionPoint.newInstance(ConstructorInjectionPoint.java:127)
    at org.jboss.weld.injection.ConstructorInjectionPoint.invokeAroundConstructCallbacks(ConstructorInjectionPoint.java:92)
    at org.jboss.weld.injection.ConstructorInjectionPoint.newInstance(ConstructorInjectionPoint.java:78)
    at org.jboss.weld.injection.producer.AbstractInstantiator.newInstance(AbstractInstantiator.java:28)
    at org.jboss.weld.injection.producer.BasicInjectionTarget.produce(BasicInjectionTarget.java:112)
    at org.jboss.weld.injection.producer.BeanInjectionTarget.produce(BeanInjectionTarget.java:180)
    at org.jboss.weld.bean.ManagedBean.create(ManagedBean.java:158)
    at org.jboss.weld.contexts.AbstractContext.get(AbstractContext.java:96)
    at org.jboss.weld.bean.ContextualInstanceStrategy$DefaultContextualInstanceStrategy.get(ContextualInstanceStrategy.java:100)
    at org.jboss.weld.bean.ContextualInstanceStrategy$CachingContextualInstanceStrategy.get(ContextualInstanceStrategy.java:177)
    at org.jboss.weld.bean.ContextualInstance.get(ContextualInstance.java:50)
    at org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:676)
    at org.jboss.weld.module.web.el.AbstractWeldELResolver.lookup(AbstractWeldELResolver.java:107)
    at org.jboss.weld.module.web.el.AbstractWeldELResolver.getValue(AbstractWeldELResolver.java:90)
    at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:147)
    at com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:156)
    at com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:184)
    at com.sun.el.parser.AstIdentifier.getValue(AstIdentifier.java:92)
    at com.sun.el.parser.AstValue.getBase(AstValue.java:126)
    at com.sun.el.parser.AstValue.getValue(AstValue.java:175)
    at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:202)
    at org.jboss.weld.module.web.el.WeldValueExpression.getValue(WeldValueExpression.java:50)
    at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:73)
    at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:170)
    at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:157)
    at javax.faces.component.UIOutput.getValue(UIOutput.java:140)
    at javax.faces.component.UIInput.getValue(UIInput.java:287)
    at org.primefaces.util.ComponentUtils.getValueToRender(ComponentUtils.java:109)
    at org.primefaces.util.ComponentUtils.getValueToRender(ComponentUtils.java:73)
    at org.primefaces.component.inputtext.InputTextRenderer.encodeMarkup(InputTextRenderer.java:92)
    at org.primefaces.component.inputtext.InputTextRenderer.encodeEnd(InputTextRenderer.java:62)
    at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:595)
    at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:286)
    at com.sun.faces.renderkit.html_basic.GridRenderer.renderRow(GridRenderer.java:162)
    at com.sun.faces.renderkit.html_basic.GridRenderer.encodeChildren(GridRenderer.java:105)
    at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:566)
    at org.primefaces.renderkit.CoreRenderer.renderChild(CoreRenderer.java:82)
    at org.primefaces.renderkit.CoreRenderer.renderChildren(CoreRenderer.java:69)
    at org.primefaces.component.dialog.DialogRenderer.encodeContent(DialogRenderer.java:200)
    at org.primefaces.component.dialog.DialogRenderer.encodeMarkup(DialogRenderer.java:123)
    at org.primefaces.component.dialog.DialogRenderer.encodeEnd(DialogRenderer.java:54)
    at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:595)
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1654)
    at javax.faces.render.Renderer.encodeChildren(Renderer.java:152)
    at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:566)
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1647)
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1650)
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1650)
    at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:468)
    at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:170)
    at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:132)
    at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:102)
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:76)
    at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:199)
    at javax.faces.webapp.FacesServlet.executeLifecyle(FacesServlet.java:708)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:451)
    at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1540)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:297)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:167)
    at web.filter.SecurityFilter.doFilter(SecurityFilter.java:59)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:209)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:167)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:215)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:119)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:611)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:550)
    at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:75)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:114)
    at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:332)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:199)
    at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:439)
    at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:144)
    at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:182)
    at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:156)
    at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:218)
    at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:95)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:260)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:177)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:109)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:88)
    at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:53)
    at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:515)
    at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:89)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:94)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:33)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:114)
    at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:569)
    at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:549)
    at java.lang.Thread.run(Thread.java:748)
Caused by: javax.mail.MessagingException: Connect failed;
  nested exception is:
    javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
    at com.sun.mail.pop3.POP3Store.protocolConnect(POP3Store.java:195)
    at javax.mail.Service.connect(Service.java:342)
    at javax.mail.Service.connect(Service.java:222)
    at javax.mail.Service.connect(Service.java:243)
    at jsf.managedBean.AdminLoginManagedBean.getEmailNumber(AdminLoginManagedBean.java:81)
    at jsf.managedBean.AdminLoginManagedBean.<init>(AdminLoginManagedBean.java:38)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at org.jboss.weld.injection.ConstructorInjectionPoint.newInstance(ConstructorInjectionPoint.java:119)
    ... 88 more
Caused by: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
    at sun.security.ssl.Alerts.getSSLException(Alerts.java:192)
    at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1946)
    at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:316)
    at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:310)
    at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1688)
    at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:216)
    at sun.security.ssl.Handshaker.processLoop(Handshaker.java:1038)
    at sun.security.ssl.Handshaker.process_record(Handshaker.java:966)
    at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1064)
    at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1367)
    at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1395)
    at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1379)
    at com.sun.mail.util.SocketFetcher.configureSSLSocket(SocketFetcher.java:602)
    at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:376)
    at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:193)
    at com.sun.mail.pop3.Protocol.<init>(Protocol.java:94)
    at com.sun.mail.pop3.POP3Store.getPort(POP3Store.java:247)
    at com.sun.mail.pop3.POP3Store.protocolConnect(POP3Store.java:189)
    ... 98 more
    Suppressed: java.lang.NullPointerException
        at com.sun.mail.pop3.Protocol.cleanupAndThrow(Protocol.java:124)
        at com.sun.mail.pop3.Protocol.<init>(Protocol.java:98)
        ... 100 more
Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
    at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:397)
    at sun.security.validator.PKIXValidator.engineValidate(PKIXValidator.java:302)
    at sun.security.validator.Validator.validate(Validator.java:262)
    at sun.security.ssl.X509TrustManagerImpl.validate(X509TrustManagerImpl.java:330)
    at sun.security.ssl.X509TrustManagerImpl.checkTrusted(X509TrustManagerImpl.java:237)
    at sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:132)
    at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1670)
    ... 111 more
Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
    at sun.security.provider.certpath.SunCertPathBuilder.build(SunCertPathBuilder.java:141)
    at sun.security.provider.certpath.SunCertPathBuilder.engineBuild(SunCertPathBuilder.java:126)
    at java.security.cert.CertPathBuilder.build(CertPathBuilder.java:280)
    at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:392)
    ... 117 more

Warning:   StandardWrapperValve[Faces Servlet]: Servlet.service() for servlet Faces Servlet threw exception
sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
    at sun.security.provider.certpath.SunCertPathBuilder.build(SunCertPathBuilder.java:141)
    at sun.security.provider.certpath.SunCertPathBuilder.engineBuild(SunCertPathBuilder.java:126)
    at java.security.cert.CertPathBuilder.build(CertPathBuilder.java:280)
    at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:392)
    at sun.security.validator.PKIXValidator.engineValidate(PKIXValidator.java:302)
    at sun.security.validator.Validator.validate(Validator.java:262)
    at sun.security.ssl.X509TrustManagerImpl.validate(X509TrustManagerImpl.java:330)
    at sun.security.ssl.X509TrustManagerImpl.checkTrusted(X509TrustManagerImpl.java:237)
    at sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:132)
    at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1670)
    at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:216)
    at sun.security.ssl.Handshaker.processLoop(Handshaker.java:1038)
    at sun.security.ssl.Handshaker.process_record(Handshaker.java:966)
    at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1064)
    at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1367)
    at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1395)
    at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1379)
    at com.sun.mail.util.SocketFetcher.configureSSLSocket(SocketFetcher.java:602)
    at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:376)
    at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:193)
    at com.sun.mail.pop3.Protocol.<init>(Protocol.java:94)
    at com.sun.mail.pop3.POP3Store.getPort(POP3Store.java:247)
    at com.sun.mail.pop3.POP3Store.protocolConnect(POP3Store.java:189)
    at javax.mail.Service.connect(Service.java:342)
    at javax.mail.Service.connect(Service.java:222)
    at javax.mail.Service.connect(Service.java:243)
    at jsf.managedBean.AdminLoginManagedBean.getEmailNumber(AdminLoginManagedBean.java:81)
    at jsf.managedBean.AdminLoginManagedBean.<init>(AdminLoginManagedBean.java:38)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at org.jboss.weld.injection.ConstructorInjectionPoint.newInstance(ConstructorInjectionPoint.java:119)
    at org.jboss.weld.injection.ConstructorInjectionPoint.invokeAroundConstructCallbacks(ConstructorInjectionPoint.java:92)
    at org.jboss.weld.injection.ConstructorInjectionPoint.newInstance(ConstructorInjectionPoint.java:78)
    at org.jboss.weld.injection.producer.AbstractInstantiator.newInstance(AbstractInstantiator.java:28)
    at org.jboss.weld.injection.producer.BasicInjectionTarget.produce(BasicInjectionTarget.java:112)
    at org.jboss.weld.injection.producer.BeanInjectionTarget.produce(BeanInjectionTarget.java:180)
    at org.jboss.weld.bean.ManagedBean.create(ManagedBean.java:158)
    at org.jboss.weld.contexts.AbstractContext.get(AbstractContext.java:96)
    at org.jboss.weld.bean.ContextualInstanceStrategy$DefaultContextualInstanceStrategy.get(ContextualInstanceStrategy.java:100)
    at org.jboss.weld.bean.ContextualInstanceStrategy$CachingContextualInstanceStrategy.get(ContextualInstanceStrategy.java:177)
    at org.jboss.weld.bean.ContextualInstance.get(ContextualInstance.java:50)
    at org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:676)
    at org.jboss.weld.module.web.el.AbstractWeldELResolver.lookup(AbstractWeldELResolver.java:107)
    at org.jboss.weld.module.web.el.AbstractWeldELResolver.getValue(AbstractWeldELResolver.java:90)
    at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:147)
    at com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:156)
    at com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:184)
    at com.sun.el.parser.AstIdentifier.getValue(AstIdentifier.java:92)
    at com.sun.el.parser.AstValue.getBase(AstValue.java:126)
    at com.sun.el.parser.AstValue.getValue(AstValue.java:175)
    at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:202)
    at org.jboss.weld.module.web.el.WeldValueExpression.getValue(WeldValueExpression.java:50)
    at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:73)
    at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:170)
    at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:157)
    at javax.faces.component.UIOutput.getValue(UIOutput.java:140)
    at javax.faces.component.UIInput.getValue(UIInput.java:287)
    at org.primefaces.util.ComponentUtils.getValueToRender(ComponentUtils.java:109)
    at org.primefaces.util.ComponentUtils.getValueToRender(ComponentUtils.java:73)
    at org.primefaces.component.inputtext.InputTextRenderer.encodeMarkup(InputTextRenderer.java:92)
    at org.primefaces.component.inputtext.InputTextRenderer.encodeEnd(InputTextRenderer.java:62)
    at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:595)
    at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:286)
    at com.sun.faces.renderkit.html_basic.GridRenderer.renderRow(GridRenderer.java:162)
    at com.sun.faces.renderkit.html_basic.GridRenderer.encodeChildren(GridRenderer.java:105)
    at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:566)
    at org.primefaces.renderkit.CoreRenderer.renderChild(CoreRenderer.java:82)
    at org.primefaces.renderkit.CoreRenderer.renderChildren(CoreRenderer.java:69)
    at org.primefaces.component.dialog.DialogRenderer.encodeContent(DialogRenderer.java:200)
    at org.primefaces.component.dialog.DialogRenderer.encodeMarkup(DialogRenderer.java:123)
    at org.primefaces.component.dialog.DialogRenderer.encodeEnd(DialogRenderer.java:54)
    at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:595)
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1654)
    at javax.faces.render.Renderer.encodeChildren(Renderer.java:152)
    at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:566)
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1647)
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1650)
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1650)
    at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:468)
    at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:170)
    at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:132)
    at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:102)
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:76)
    at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:199)
    at javax.faces.webapp.FacesServlet.executeLifecyle(FacesServlet.java:708)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:451)
    at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1540)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:297)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:167)
    at web.filter.SecurityFilter.doFilter(SecurityFilter.java:59)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:209)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:167)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:215)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:119)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:611)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:550)
    at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:75)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:114)
    at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:332)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:199)
    at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:439)
    at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:144)
    at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:182)
    at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:156)
    at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:218)
    at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:95)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:260)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:177)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:109)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:88)
    at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:53)
    at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:515)
    at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:89)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:94)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:33)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:114)
    at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:569)
    at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:549)
    at java.lang.Thread.run(Thread.java:748)

Ответы [ 2 ]

0 голосов
/ 17 апреля 2020

Программа InstallCert поможет импортировать сертификат. Поскольку вы работаете на сервере приложений, вам необходимо обязательно импортировать сертификат в хранилище ключей сервера приложений.

0 голосов
/ 16 апреля 2020

Похоже, что проблема PKIX при подключении к удаленному серверу с помощью SSL.

Caused by: javax.mail.MessagingException: Connect failed;
  nested exception is:
    javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

Вы можете решить эту ошибку, импортировав сертификат SSL с помощью keytool:

keytool -import -file <the cert file> -alias <some meaningful name> -keystore <path to cacerts file>
...