glassfish
  1. glassfish
  2. GLASSFISH-18610

JNDI lookup of javamail resource returns a type (javax.naming.Reference) that can not be cast to javax.mail.Session

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 4.0
    • Fix Version/s: 4.0_b42
    • Component/s: standalone_client
    • Labels:
      None

      Description

      There are a few CTS javamail tests that fail due to this issue.

      The following line in a JavaEE appclient program causes a ClassCastException: javax.naming.Reference cannot be cast to javax.mail.Session

      Session session = (Session) ic.lookup("java:comp/env/mail/MailSession");

      I attached a simple appclient program to reproduce it

      1. application-client.xml
        0.6 kB
        Dennis MacConnell
      2. glassfish-application-client.xml
        0.4 kB
        Dennis MacConnell
      3. Main.java
        0.6 kB
        Dennis MacConnell

        Issue Links

          Activity

          Hide
          Cheng Fang added a comment -

          The most likely cause is some classes that are needed on the client side are not availabel at runtime. That could also explain why the same set tests fail in remote client, but pass in server environment.

          I remember some time back javax.mail.jar was split into 3 jars, along with some other refactoring:

          rw-rr-@ 1 staff 26926 Apr 17 13:19 javamail-connector.jar
          rw-rr-@ 1 staff 12859 Apr 17 13:19 javamail-runtime.jar
          rw-rr-@ 1 staff 507980 Apr 17 13:19 javax.mail.jar

          Dennnis, can you try including both javax.mail.jar and javamail-runtime.jar in appclient classpath?

          Show
          Cheng Fang added a comment - The most likely cause is some classes that are needed on the client side are not availabel at runtime. That could also explain why the same set tests fail in remote client, but pass in server environment. I remember some time back javax.mail.jar was split into 3 jars, along with some other refactoring: rw-r r -@ 1 staff 26926 Apr 17 13:19 javamail-connector.jar rw-r r -@ 1 staff 12859 Apr 17 13:19 javamail-runtime.jar rw-r r -@ 1 staff 507980 Apr 17 13:19 javax.mail.jar Dennnis, can you try including both javax.mail.jar and javamail-runtime.jar in appclient classpath?
          Hide
          Dennis MacConnell added a comment -

          Adding javamail-connector.jar & javamail-runtime.jar to the appclient command classpath resolves the problem.

          Show
          Dennis MacConnell added a comment - Adding javamail-connector.jar & javamail-runtime.jar to the appclient command classpath resolves the problem.
          Hide
          Cheng Fang added a comment -

          Assign to appclient team to see if we can fix gf-client.jar.

          gf-client.jar references javax.mail.jar but not javamail-runtime.jar.

          Show
          Cheng Fang added a comment - Assign to appclient team to see if we can fix gf-client.jar. gf-client.jar references javax.mail.jar but not javamail-runtime.jar.
          Hide
          Tim Quinn added a comment -

          Fix checked in.

          Project: glassfish
          Repository: svn
          Revision: 54626
          Author: tjquinn
          Date: 2012-06-18 15:09:33 UTC
          Link:

          Log Message:
          ------------
          Fix for 18610

          App clients that use JavaMail were not working correctly without explicitly adding two JavaMail-related JARs to the class path.

          This change makes those JARs available to clients.

          pom.xml change approved: Romain
          Tests: QL, deployment devtests

          Revisions:
          ----------
          54626

          Modified Paths:
          ---------------
          trunk/main/appserver/appclient/client/acc/pom.xml

          Show
          Tim Quinn added a comment - Fix checked in. Project: glassfish Repository: svn Revision: 54626 Author: tjquinn Date: 2012-06-18 15:09:33 UTC Link: Log Message: ------------ Fix for 18610 App clients that use JavaMail were not working correctly without explicitly adding two JavaMail-related JARs to the class path. This change makes those JARs available to clients. pom.xml change approved: Romain Tests: QL, deployment devtests Revisions: ---------- 54626 Modified Paths: --------------- trunk/main/appserver/appclient/client/acc/pom.xml
          Hide
          Tim Quinn added a comment -

          While resolving 18610 I discovered that even after a mail session was removed on the server, as long as the server was not restarted new runs of the client could continue to open sessions using the resource. Issue 18800 tracks that separate bug.

          Show
          Tim Quinn added a comment - While resolving 18610 I discovered that even after a mail session was removed on the server, as long as the server was not restarted new runs of the client could continue to open sessions using the resource. Issue 18800 tracks that separate bug.

            People

            • Assignee:
              Tim Quinn
              Reporter:
              Dennis MacConnell
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: