Monday 28 September 2009

Jira, SSL and Gmail, what a faff!

I had cause today to verify correct operation of Jira with Gmail with JEMH. I had enough fun to want to write it down for future reference.

1. So Gmail needs SSL for POP and SMTP
The problem is that in order for Jira (Java actually) to setup even a single SSL connection, it needs to be able to trust the source.

Following the Connecting to SSL services page I recalled the nitty gritty of extracting the Gmail security cert, loading into the JRE cacerts file I remembered. Really usefully I was happy to the the old SSLPoke.class file I wrote to do testing ages ago still available, ironically able to use it to test my setup today! With a JRE now able to talk SSL to gmail, time to setup Jira.

2. Setup Jira
a) POP
Adding a popserver entry, with simple details, host as pop.gmail.com and valid username/password. The SSL bit comes in when setting up the handler
When adding a POP handler, ensure the gmail popserver is selected, the handler has a Uses SSL option, which needs setting true, and the port should be 995.

b) SMTP
Followed Configuring JIRA to send SMTP mail , so modified the config/server.xml file, all seemed fine, but this is where I hit a few snags, the most irritating was "java:comp/env....." not found. Turned out this was due to a space at the front of the " java:", gah, my kingdom for a trim().

I found JRA-12180 , so moved the two jars (mail / activation ) from atlassian-jira/WEB-INF/lib into common/lib. Q: Why isnt this already done as part of the standalone dist? huh.

And yet, it still didn't work. Hmm. So found an Atlassian knowledge base article
that indicated the "mail.smptp.socketFactoryClass" entry in the server.xml file that the earlier page instructed to be added.

Alls well that ends well. Gmail now working as SMTP/POP server over SSL,.

2 comments:

AK said...

hi i have been trying to configure JIRA to send email through smtp.gmail.com and i keep getting this wierd error

An error has occurred with sending the test email:
com.atlassian.mail.MailException: javax.naming.NameNotFoundException: Name mail is not bound in this Context
at com.atlassian.mail.server.impl.SMTPMailServerImpl.send(SMTPMailServerImpl.java:187)


any idea?

javahollic said...

Hi there,
two sources of this problem, a) the configuration in your server.xml is not present, or broken, and b) the exact JNDI lookup phrase used in Jira is not correct.

Here is an excerpt from Atlassian config page


The JNDI Location will depend on your application server and configuration. For example, in Tomcat 6 (the default application server that is bundled with JIRA Standalone ), your JNDI Location would be java:comp/env/mail/JiraMailServer, and you would add the following section in conf/server.xml , inside the node:


So if you followed the install guide on that page, what did you use for JNDI lookup?