Bug 34131 - Regression: cannot create JavaMail sessions with MailSessionFactory in Tomcat 5.5.8
Summary: Regression: cannot create JavaMail sessions with MailSessionFactory in Tomcat...
Alias: None
Product: Tomcat 5
Classification: Unclassified
Component: Catalina (show other bugs)
Version: 5.5.8
Hardware: Other Windows XP
: P2 blocker (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
: 34001 (view as bug list)
Depends on:
Reported: 2005-03-22 16:59 UTC by Chris Brown
Modified: 2005-03-23 06:08 UTC (History)
1 user (show)


Note You need to log in before you can comment on or make changes to this bug.
Description Chris Brown 2005-03-22 16:59:02 UTC
This is a regression: no such error occurs with Tomcat 5.5.4 (or earlier).  It
occurs on Tomcat 5.5.8, maybe on other versions after 5.5.4 too.

Whenever I attempt to access a JavaMail session, an exception occurs.  The
application in question follows the technique described in:


...and yes, I have ensured that the "activation" and "javamail" JARs are ONLY
present in "%CATALINA_HOME%\common\lib" (and not in the application's
"/WEB-INF/lib" folder or anything else like that).  I use the same version of
JavaMail with Tomcat 5.5.4 and 5.5.8 (that's JavaMail 1.3.2).

Anyway, here's the stacktrace.

javax.naming.NamingException: Cannot create resource instance
        at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304)
        at org.apache.naming.NamingContext.lookup(NamingContext.java:792)
        at org.apache.naming.NamingContext.lookup(NamingContext.java:139)
        at org.apache.naming.NamingContext.lookup(NamingContext.java:780)
        at org.apache.naming.NamingContext.lookup(NamingContext.java:152)
        at ...

The web application is called "open", deployed as a directory in
"%CATALINA_HOME%\webapps".  In "%CATALINA_HOME%\conf\Catalina\localhost", I've
placed the file "open.xml", which is read in.  Here's the document content:

<?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>
<Context unpackWARs="false" docBase="open">

 <Environment name="someKey" type="java.lang.String" value="someValue" />

 <Resource name="jdbc/OpenAGE" auth="Container" type="javax.sql.DataSource"

 <Resource name="mail/OpenAGE" auth="Container"


The environment entries are readable, the datasource is too.  It's only the
JavaMail Session factory that isn't working.  An appropriate resource reference
is defined in /WEB-INF/web.xml (and worked fine with Tomcat 5.5.4).

I looked into this a little further.  It appears that Tomcat does indeed bind


...but Tomcat's ResourceFactory throws "javax.naming.NamingException: Cannot
create resource instance" when any attempt is made to access it.  If I call
Context.list("") on the context "java:comp/env/mail", the returned
NamingEnumeration lists "OpenAGE" as a NameClassPair, but throws an exception
when attempting to perform the lookup() to get access to the mail session.
Comment 1 Remy Maucherat 2005-03-22 17:02:48 UTC
*** Bug 34001 has been marked as a duplicate of this bug. ***
Comment 2 Remy Maucherat 2005-03-22 17:11:24 UTC
No surprise, it's simply the mail factory didn't get packaged in the release
(see the naming-factory.jar). However, it *is* present in 5.5.7, so please do
not file bogus reports.
Comment 3 Chris Brown 2005-03-23 13:52:33 UTC
(In reply to comment #2)
> No surprise, it's simply the mail factory didn't get packaged in the release
> (see the naming-factory.jar). However, it *is* present in 5.5.7, so please do
> not file bogus reports.

The bugzilla form doesn't appear to have an option for 5.5.8, so I took the next
best option (5.5.7).  I didn't have the time to verify against nightly builds or
5.5.7... I did look at the source code, which included the factory class in
question.  Hope this bug report at least helps to ensure that the packaging
issue is resolved for 5.5.8-final.

With regards to naming-factory.jar, I see that the MailSessionFactory class is
missing in 5.5.8-alpha's JAR, but IS still present in the "-src" package as a
".java" file.  I assume that it's just an oversight and not an intentional change?

In any case, thanks for your quick reply.
Comment 4 Yoav Shapira 2005-03-23 15:08:35 UTC
Chris, thanks for reporting this and sorry for the inconvenience.  I
accidentally left out the JavaMail/JAF jars when building 5.5.8-alpha, so the
factory got dropped.  It was a clean build setup and I've already fixed it for
5.5.9, which will have the factory as before.  We'll hopefully release
5.5.9-alpha this weekend.

I've also added reporting options for issues against 5.5.8 and 5.5.9.  I'm
modifying this bug to be against 5.5.8, and closing it as it's already been
resolved in my build environment.  Thanks again.