geronimo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Hearty <heartyraph...@gmail.com>
Subject Re: I am getting javax.mail.AuthenticationFailedException
Date Mon, 20 Apr 2009 07:04:52 GMT

Hi Rick,

     My application using POP3 in a different way. Basically I am looking
for to use the application specific "mail.jar" instead of geronimo-mail
since I need to support both tomcat5.5 and geronimo using the same code
base. I have included mail.jar as a dependency jar. But even after tried to
hide the geronimo mail class using
<sys:filter>org.apache.geronimo.mail</sys:filter>, I am getting the same
error.

The following is the code snippet I am using related to POP3. 

import javax.mail.Address;
import javax.mail.BodyPart;
import javax.mail.Flags;
import javax.mail.Folder;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Part;
import javax.mail.Session;
import javax.mail.Store;
import javax.mail.URLName;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeBodyPart;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMultipart;
import javax.mail.internet.MimePart;

 public String getValue() {
        if ((strings == null) || (strings.length < 4)) {
            throw new
FormulaRuntimeException(getMessage("formula.common.invalidInput.header",
info));
        }

        Element element = getElement();
        if (element == null) {
            throw new
FormulaRuntimeException(getMessage("formula.MailImport.failed.mailStoreFolder"));
        }

        User user = getUser();
        if (user == null) {
            throw new
FormulaRuntimeException(getMessage("formula.MailImport.failed.currentElementOwner"));
            // some top folders are created with no owner

        }

        boolean expunge = false;
        if (strings[1].trim().equalsIgnoreCase("true") || strings[1].trim()
            .equalsIgnoreCase("yes"))
        {
            expunge = true;
        }

        String attachmentAttributeName = null;
        if (strings.length >= 5) {
            attachmentAttributeName = strings[4];
        }

        String result = "";
        try {
            Properties mailProperties = new Properties();
            Session session = Session.getInstance(mailProperties);
            URLName url = new URLName(strings[0]);
            Store store = session.getStore(url);
            store.connect();
            Folder folder = store.getFolder(url);
            folder.open(Folder.READ_WRITE);
            Message[] messages = folder.getMessages();
            result =
getMessage("formula.MailImport.lastupdate.message.many", messages.length) ;
            for (int i = 0; i < messages.length; i++) {
                if (messages[i] instanceof MimeMessage) {
                    MimeMessage message = (MimeMessage) messages[i];
                    Element subFolder = getMonthFolder(element, message
                        .getSentDate());
                    if (subFolder == null) {
                        result += 
getMessage("formula.MailImport.failed.folderCreate") ;
                        subFolder = element;
                    }
                    createElement(subFolder, user, message, strings[2],
                        strings[3], attachmentAttributeName);
                    message.setFlag(Flags.Flag.DELETED, expunge);
                }
            }
            folder.close(expunge);
            store.close();
        } catch (ClassCastException e) {
            log.error("", e);
            throw new
FormulaRuntimeException(getMessage("formula.MailImport.failed.attribute.wrongType"));
        } catch (Exception e) { // XXX PN nice error messages here
            log.error("", e);
            throw new
FormulaRuntimeException(getMessage("formula.MailImport.failed.genric.message",
e));
        }
        return result;
    }

Here strings array contains the values as 
"pop3://pop3user:pop3user@192.168.100.271/Inbox","false","Mails","MID","Attachment","update_interval=1m"

When  store.connect(); is called I am getting the
javax.mail.AuthenticationFailedException.
Here pop3 url configuration is not part of any config files. It is as simple
as the user can configure it in a text field on clicking submit, the mail
application will try to fetch the mails if any. 

The kind of solution I am looking for is, to use my application specific
mail.jar and avoid the loading of the classes related geronimo-mail.jar. 




Rick McGuire wrote:
> 
> I'm not completely sure what you're trying to do here.  Configuring 
> SMTPHost and SMTPPort has no connection to the POP3 protocol.  That only 
> controls SMTP protocol.  If you need to have POP3 configured, you can 
> add a POP3Transport gbean to the javamail configuration.  However, that 
> only controls what gets used if you use the MailResource JNDI entry to 
> obtain the session. 
> 
> How are you accessing the Session used to obtain the POP3 store 
> instance?  The answer to that question will determine what additional 
> steps you need to take to get this working.
> 
> Rick
> 
> Hearty wrote:
>> I am using Apache Geronimo Server 2.1.3 and I am using POP3 protocol for
>> my
>> application mail settings.
>>
>> I've configured SMTPHost and SMTPPort correctly with
>> config-subsitution.properties and in the config.xml  gbean for javamail
>> is
>> loaded.
>> <module name="org.apache.geronimo.configs/javamail/2.1.3/car">
>>         <gbean name="SMTPTransport">
>>             <attribute name="host">${SMTPHost}</attribute>
>>             <attribute name="port">${SMTPPort}</attribute>
>>         </gbean>
>>     </module>
>>
>> But I am getting the javax.mail.AuthenticationFailedException. But when I
>> tried with tomcat 5.5, it is working fine. In tomcat I am using a jar
>> called
>> mail.jar. 
>>
>> The second approach I've done as follows [But still I am getting the
>> javax.mail.AuthenticationFailedException error]
>> 1. I have made <module
>> name="org.apache.geronimo.configs/javamail/2.1.3/car"
>> load="false">
>> 2. In geronimo-web.xml, I have added one entry against hidden-classes
>> <sys:hidden-classes>
>>    <sys:filter>org.apache.geronimo.mail</sys:filter>
>> </sys:hidden-classes>
>> 3. I have included mail.jar as the dependency jar in geronimo-web.xml as
>> follows
>>  <sys:dependency>
>> 				<sys:groupId>com.telelogic.focalpoint.lib</sys:groupId>
>> 				<sys:artifactId>mail</sys:artifactId>
>> 				<sys:version>1.3</sys:version>
>> 				<sys:type>jar</sys:type>
>> 			</sys:dependency>
>>
>> In the both the approaches I am getting the same error. Since it was
>> working
>> fine with mail.jar in tomcat5.5, I preferred to go with the second
>> approach.
>>
>> Please help me what additional settings I need to do make the POP3 mail
>> application to work fine?
>> If I made any mistakes in configuration please let me know.
>>
>>
>>
>> javax.mail.AuthenticationFailedException
>> 	at javax.mail.Service.connect(Service.java:277)
>> 	at javax.mail.Service.connect(Service.java:91)
>> 	at javax.mail.Service.connect(Service.java:76)
>> 	at MailImport.getValue(MailImport.java:116)
>> 	at
>> com.telelogic.focalpoint.bus.formula.ownformula.ExpressionInfo.getValue(ExpressionInfo.java:115)
>> 	at
>> com.telelogic.focalpoint.bus.formula.FormulaManagerImpl.getExpressionValue(FormulaManagerImpl.java:2946)
>> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>> 	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
>> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
>> 	at java.lang.reflect.Method.invoke(Unknown Source)
>> 	at
>> org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:281)
>> 	at
>> org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:187)
>> 	at
>> org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:154)
>> 	at
>> org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:107)
>> 	at
>> org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:176)
>> 	at
>> org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:107)
>> 	at
>> org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:176)
>> 	at
>> org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:210)
>> 	at $Proxy83.getExpressionValue(Unknown Source)
>> 	at
>> com.telelogic.focalpoint.bus.formula.parser.OwnFormulaToken.translateToUserDefined(OwnFormulaToken.java:755)
>> 	at
>> com.telelogic.focalpoint.bus.formula.parser.OwnFormulaToken.getCalculatedValue(OwnFormulaToken.java:417)
>> 	at
>> com.telelogic.focalpoint.bus.formula.parser.Token.getValue(Token.java:98)
>> 	at
>> com.telelogic.focalpoint.bus.formula.parser.Tokens.getValue(Tokens.java:92)
>> 	at
>> com.telelogic.focalpoint.bus.formula.TextFormula.calculateHelper(TextFormula.java:45)
>> 	at
>> com.telelogic.focalpoint.bus.formula.Formula.calculate(Formula.java:145)
>> 	at
>> com.telelogic.focalpoint.pres.controller.FormulaController.evaluate(FormulaController.java:168)
>> 	at
>> com.telelogic.focalpoint.pres.controller.FormulaController.handlePost(FormulaController.java:85)
>> 	at
>> com.telelogic.focalpoint.pres.controller.BaseController.myService(BaseController.java:453)
>> 	at
>> com.telelogic.focalpoint.pres.controller.BaseController.service(BaseController.java:205)
>> 	at javax.servlet.http.HttpServlet.service(HttpServlet.java:806)
>> 	at
>> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
>> 	at
>> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
>> 	at
>> com.telelogic.focalpoint.pres.servletfilter.VersionCheckFilter.doFilter(VersionCheckFilter.java:35)
>> 	at
>> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
>> 	at
>> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
>> 	at
>> com.telelogic.focalpoint.pres.servletfilter.WebSSOFilter.myDoFilter(WebSSOFilter.java:56)
>> 	at
>> com.telelogic.focalpoint.pres.servletfilter.UriExcludingFilter.doFilter(UriExcludingFilter.java:51)
>> 	at
>> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
>> 	at
>> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
>> 	at
>> com.telelogic.focalpoint.pres.servletfilter.CurrentUserHandlerFilter.myDoFilter(CurrentUserHandlerFilter.java:52)
>> 	at
>> com.telelogic.focalpoint.pres.servletfilter.UriExcludingFilter.doFilter(UriExcludingFilter.java:51)
>> 	at
>> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
>> 	at
>> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
>> 	at
>> com.telelogic.focalpoint.pres.servletfilter.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:39)
>> 	at
>> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
>> 	at
>> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
>> 	at
>> com.telelogic.focalpoint.pres.servletfilter.RequestPrinterFilter.myDoFilter(RequestPrinterFilter.java:56)
>> 	at
>> com.telelogic.focalpoint.pres.servletfilter.UriExcludingFilter.doFilter(UriExcludingFilter.java:51)
>> 	at
>> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
>> 	at
>> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
>> 	at
>> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
>> 	at
>> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
>> 	at
>> org.apache.geronimo.tomcat.valve.DefaultSubjectValve.invoke(DefaultSubjectValve.java:56)
>> 	at
>> org.apache.geronimo.tomcat.GeronimoStandardContext$SystemMethodValve.invoke(GeronimoStandardContext.java:406)
>> 	at
>> org.apache.geronimo.tomcat.valve.GeronimoBeforeAfterValve.invoke(GeronimoBeforeAfterValve.java:47)
>> 	at
>> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
>> 	at
>> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
>> 	at
>> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
>> 	at
>> org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:568)
>> 	at
>> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
>> 	at
>> org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
>> 	at
>> org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
>> 	at
>> org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
>> 	at java.lang.Thread.run(Unknown Source)
>>   
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/I-am-getting-javax.mail.AuthenticationFailedException-tp23099624s134p23131387.html
Sent from the Apache Geronimo - Users mailing list archive at Nabble.com.


Mime
View raw message