Bug 1163150

Summary: pop3 mail session throws a NoSuchProviderException
Product: [JBoss] JBoss Enterprise Application Platform 6 Reporter: JJ <jj.fliegenfaenger>
Component: MailAssignee: jboss-set
Status: CLOSED CURRENTRELEASE QA Contact: Martin Simka <msimka>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 6.3.0CC: msimka, myarboro
Target Milestone: DR10   
Target Release: EAP 6.4.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description JJ 2014-11-12 12:48:03 UTC
Description of problem:

When configuring a pop3 server in standalone.xml as, the following exception is thrown when reading the mailbox:

Caused by: javax.mail.NoSuchProviderException: Invalid protocol: null
	at javax.mail.Session.getProvider(Session.java:440) [mail-1.4.5-redhat-1.jar:1.4.5-redhat-1]
	at javax.mail.Session.getStore(Session.java:539) [mail-1.4.5-redhat-1.jar:1.4.5-redhat-1] 


Version-Release number of selected component (if applicable):


How reproducible:


Steps to Reproduce:
1. add a pop3 server in the mail section

            <mail-session jndi-name="java:/MyMail" from="xxx@xxx">
                <smtp-server outbound-socket-binding-ref="smtp-outbound">
                    <login name="xxx" password="xxx"/>
                </smtp-server>
                <pop3-server outbound-socket-binding-ref="pop3-outbound">
                    <login name="xxx" password="xxx"/>
                </pop3-server>
            </mail-session>


2. try to read the mailbox


Actual results:

Throws an javax.mail.NoSuchProviderException


Expected results:



Additional info:

The bug is probably in class org.jboss.as.mail.extension.MailSessionService, where no protocol for pop3 is set. 

Code snippet to make it work:

    private Properties getProperties() throws StartException {
        Properties props = new Properties();

        if (config.getSmtpServer() != null) {
            props.setProperty("mail.transport.protocol", "smtp");
            setServerProps(props, config.getSmtpServer(), "smtp");
        }
        if (config.getImapServer() != null) {
            props.setProperty("mail.store.protocol", "imap");
            setServerProps(props, config.getImapServer(), "imap");
        }
        if (config.getPop3Server() != null) {
            props.setProperty("mail.store.protocol", "pop3");   // THIS LINE WAS MISSED
            setServerProps(props, config.getPop3Server(), "pop3");
        }
        if (config.getCustomServers() != null) {
            configureCustomServers(props, config.getCustomServers());
        }
        if (config.getFrom() != null) {
            props.setProperty("mail.from", config.getFrom());
        }
        props.setProperty("mail.debug", String.valueOf(config.isDebug()));
        MailLogger.ROOT_LOGGER.tracef("props: %s", props);
        return props;
    }

Comment 2 Martin Simka 2014-12-01 15:53:39 UTC
verified on EAP 6.4.0.DR11