5 Replies Latest reply on Dec 29, 2003 4:15 AM by 843830

    I was the first guy in the world...

    843830
      ...to connect Sun ONE Application Server to PostgreSQL, so I'm expecting to be the first guy in the world who has tried to send email from an EJB deployed on Sun ONE Application Server.

      I've gone through all the docs and tried dozens of different variations...I can look up the Session properly, but the problem is when I call Transport.send(). It happens on my application, and ALSO on the sample JavaMail application that ships with S1AS. I've set up the sessions properly via the admin interface.

      All I have to go on is the following (completely useless) stack trace. Any ideas?

      java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
      java.rmi.RemoteException
      at com.sun.corba.ee.internal.javax.rmi.CORBA.Util.wrapException(Util.java:364)
      at javax.rmi.CORBA.Util.wrapException(Util.java:277)
      at com.ai.coaching.ejb.directorymanager._DirectoryManager_Stub.sendEmailToAccount(Unknown Source)
      at com.ai.coaching.web.SendEmailAction.perform(SendEmailAction.java:142)
      at org.apache.struts.action.Action.execute(Action.java:415)
      at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:465)
      at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
      at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1422)
      at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:523)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
      at org.apache.catalina.core.StandardWrapperValve.invokeServletService(StandardWrapperValve.java:720)
      at org.apache.catalina.core.StandardWrapperValve.access$000(StandardWrapperValve.java:118)
      at org.apache.catalina.core.StandardWrapperValve$1.run(StandardWrapperValve.java:278)
      at java.security.AccessController.doPrivileged(Native Method)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:274)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:505)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:212)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:505)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:203)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:505)
      at com.iplanet.ias.web.connector.nsapi.NSAPIProcessor.process(NSAPIProcessor.java:157)
      at com.iplanet.ias.web.WebContainer.service(WebContainer.java:598)
      Caused by: java.rmi.RemoteException
      at com.sun.enterprise.iiop.POAProtocolMgr.mapException(POAProtocolMgr.java:451)
      at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:545)
      at com.ai.coaching.ejb.directorymanager.DirectoryManagerBean_EJBObjectImpl.sendEmailToAccount(DirectoryManagerBean_EJB

      at com.ai.coaching.ejb.directorymanager._DirectoryManager_Stub.sendEmailToAccount(Unknown Source)
      ... 20 more
        • 1. Re: I was the first guy in the world...
          843830
          I Have the same problen. Have you resolved it yet ?
          • 2. Re: I was the first guy in the world...
            843830
            Has this been resolved yet..? I am facing the same problem and am curious to know how it has been resolved.
            • 3. Re: I was the first guy in the world...
              843830
              what kind of system do you use?

              I successfully developed a EJB on W2k. Deployed it to a Solaris appserver => worked.

              Switching to Linux and I can see the EJB crashing at the position
              Transport.send(msg);
              without Exception!????

              Very strange.

              -chris
              • 4. Re: I was the first guy in the world...
                843830
                I too am having a similar problem.

                I'm attempting to send an email from within a Struts Action class, deployed on the Sun App Server 7. I have followed several documented ways of sending a JavaMail email without success. When I call Transport.send... I receive the following error msg:

                [28/Dec/2003:16:20:48] SEVERE ( 2812): StandardWrapperValve[StrutsController]: Servlet.service() for servlet StrutsController threw exception
                javax.servlet.ServletException: Servlet execution threw an exception
                     at org.apache.catalina.core.StandardWrapperValve.invokeServletService(StandardWrapperValve.java:742)
                     at org.apache.catalina.core.StandardWrapperValve.access$000(StandardWrapperValve.java:118)
                     at org.apache.catalina.core.StandardWrapperValve$1.run(StandardWrapperValve.java:278)
                     at java.security.AccessController.doPrivileged(Native Method)
                     at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:274)
                     at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:505)
                     at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:212)
                     at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:505)
                     at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:203)
                     at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:505)
                     at com.iplanet.ias.web.connector.nsapi.NSAPIProcessor.process(NSAPIProcessor.java:157)
                     at com.iplanet.ias.web.WebContainer.service(WebContainer.java:598)
                ----- Root Cause -----
                java.lang.ExceptionInInitializerError
                     at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
                     at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
                     at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
                     at java.lang.reflect.Constructor.newInstance(Constructor.java:274)
                     at javax.mail.Session.getService(Session.java:607)
                     at javax.mail.Session.getTransport(Session.java:541)
                     at javax.mail.Session.getTransport(Session.java:484)
                     at javax.mail.Session.getTransport(Session.java:464)
                     at com.americandatacorp.struts.action.MailAction.execute(MailAction.java:60)
                     at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
                     at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
                     at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
                     at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
                     at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
                     at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
                     at org.apache.catalina.core.StandardWrapperValve.invokeServletService(StandardWrapperValve.java:720)
                     at org.apache.catalina.core.StandardWrapperValve.access$000(StandardWrapperValve.java:118)
                     at org.apache.catalina.core.StandardWrapperValve$1.run(StandardWrapperValve.java:278)
                     at java.security.AccessController.doPrivileged(Native Method)
                     at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:274)
                     at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:505)
                     at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:212)
                     at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:505)
                     at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:203)
                     at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:505)
                     at com.iplanet.ias.web.connector.nsapi.NSAPIProcessor.process(NSAPIProcessor.java:157)
                     at com.iplanet.ias.web.WebContainer.service(WebContainer.java:598)
                Caused by: org.apache.commons.logging.LogConfigurationException: java.lang.ClassCastException: org.apache.commons.logging.impl.LogFactoryImpl
                     at org.apache.commons.logging.LogFactory.newFactory(LogFactory.java:549)
                     at org.apache.commons.logging.LogFactory.getFactory(LogFactory.java:337)
                     at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:394)
                     at com.sun.mail.smtp.SMTPTransport.<clinit>(SMTPTransport.java:44)
                     ... 27 more
                Caused by: java.lang.ClassCastException: org.apache.commons.logging.impl.LogFactoryImpl
                     at org.apache.commons.logging.LogFactory.newFactory(LogFactory.java:542)
                     ... 30 more

                When I take the same approach and run the process from a main method in a standalone program it sends a mail successfully. Any idea why this is breaking with in the App Server or what this error message means?

                The following is a summary of my code to send the email...

                Properties props = new Properties();
                props.put( "mail.smtp.host", host );
                props.put("mail.smtp.auth", "true");
                Authenticator auth = new ADCAuthenticator(); //implemented within this source file...
                Session session = Session.getInstance( props, auth );
                try {
                MimeMessage msg = new MimeMessage( session );
                msg.setFrom( new InternetAddress ( fromEmailAddress );
                InternetAddress[] address = { new InternetAddress(  toEmailAddress ) };
                msg.setRecipients( Message.RecipientType.TO, address );
                msg.setSubject( "JavaMail APIs Multipart Test" );
                msg.setSentDate( new Date() );

                MimeBodyPart mbp1 = new MimeBodyPart();
                mbp1.setText( msgText1 );

                MimeBodyPart mbp2 = new MimeBodyPart();
                mbp2.setText( msgText2, "us-ascii" );

                Multipart mp = new MimeMultipart();
                mp.addBodyPart( mbp1 );
                mp.addBodyPart( mbp2 );

                msg.setContent( mp );

                Transport.send( msg ); //the exception is thrown here.

                } catch ( MessagingException mex ) {
                mex.printStackTrace();
                Exception ex = null;
                if ( ( ex = mex.getNextException() ) != null ) {
                ex.printStackTrace();
                }
                }
                Is this a problem within my code or a bug in the application server? The root cause:
                Caused by: java.lang.ClassCastException: org.apache.commons.logging.impl.LogFactoryImpl
                concerns me since I'm not making any calls to the application server logging system.

                Thanks for your assistance to anyone who can shed any light on this issue.

                Regards,

                Josh Holtzman
                • 5. Re: I was the first guy in the world...
                  843830
                  I have found a temporary solution to this problem as was noted in another post.

                  http://swforum.sun.com/jive/thread.jsp?nav=false&forum=56&thread=19700

                  I've resolved this problem by updating the mail.jar and activation.jar files with the most recent versions of the libraries from sun.com. These files need to be updated in both the imq/lib and share/lib directories.

                  While this resolves this problem I'm not sure if it opens up other problems within the AS7 environment. As far as I am concerned this is a "Mickey Mouse" way around the problem, and SUN should publish an update, or official resolution on this issue.

                  It seems that this problem is likely related to a bug within, or the packaging of, these jar files as they are provided withing the SUN AS7 deployment. As others have mentioned it might simply have to do with the placement of a .mailcap configuration file within the directory structure where the MailcapCommandMap searches to load the .mailcap file.

                  Nevertheless, I hope this finds others in search of assistance on this topic with some guidance.