James Server
  1. James Server
  2. JAMES-882

VirtualUserTable-Store is not working anymore

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 3.0.0, Trunk
    • Fix Version/s: 3.0-M1, 3.0.0
    • Component/s: None
    • Labels:
      None

      Description

      In current trunk the VirtualUserTable-Store implementation get never called from a mailet to rewrite recipients.

      1. vut-support.diff
        18 kB
        Norman Maurer
      2. vut-smoke.patch
        6 kB
        Robert Burrell Donkin
      3. diff.txt
        9 kB
        Robert Burrell Donkin

        Activity

        Hide
        Norman Maurer added a comment -

        Please review

        Show
        Norman Maurer added a comment - Please review
        Hide
        Robert Burrell Donkin added a comment -

        isLocalEmail does not correctly take VUT into account so I think VUT support should be removed from LocalDelivery.

        Show
        Robert Burrell Donkin added a comment - isLocalEmail does not correctly take VUT into account so I think VUT support should be removed from LocalDelivery.
        Hide
        Robert Burrell Donkin added a comment -

        JDBCVirtualUserTable and XMLVirtualUserTable mailets don't use the VUT API. Should the be deleted?

        Show
        Robert Burrell Donkin added a comment - JDBCVirtualUserTable and XMLVirtualUserTable mailets don't use the VUT API. Should the be deleted?
        Hide
        Norman Maurer added a comment -

        @Robert: what VUT support you are talking about ( LocalDelivery) ?

        Show
        Norman Maurer added a comment - @Robert: what VUT support you are talking about ( LocalDelivery) ?
        Hide
        Robert Burrell Donkin added a comment -

        I'm happy to see this committed if it works for you. I don't really want to get into a massive design debate ATM.

        Show
        Robert Burrell Donkin added a comment - I'm happy to see this committed if it works for you. I don't really want to get into a massive design debate ATM.
        Hide
        Robert Burrell Donkin added a comment -

        I've attached the VUT smoke test

        Show
        Robert Burrell Donkin added a comment - I've attached the VUT smoke test
        Hide
        Norman Maurer added a comment -

        Hi all,

        today I tried to complete the fix for it, but it seems I can't get the dependency injection stuff to get work. Maybe some can check the James.xinfo and assembly.xml to see if he can spot an error ?

        Thx

        Show
        Norman Maurer added a comment - Hi all, today I tried to complete the fix for it, but it seems I can't get the dependency injection stuff to get work. Maybe some can check the James.xinfo and assembly.xml to see if he can spot an error ? Thx
        Hide
        Robert Burrell Donkin added a comment -

        One of the reasons why I added the JSR250 injection was that I really struggled to persuade Phoenix to work. If this still isn't working and it's ok with people, I can try the JSR250 stuff.

        Show
        Robert Burrell Donkin added a comment - One of the reasons why I added the JSR250 injection was that I really struggled to persuade Phoenix to work. If this still isn't working and it's ok with people, I can try the JSR250 stuff.
        Hide
        Robert Burrell Donkin added a comment -

        James was failing the smoke tests (basically not booting) since the Phoenix stuff wasn't working. I've patched the mailet to use JSR250 since my Phoenix foo is weak. If anyone finds the time and inclination to reverse this change and get the Phoenix stuff working, fine by me.

        BTW sorry for missing the JIRA number on the commit :-/

        Show
        Robert Burrell Donkin added a comment - James was failing the smoke tests (basically not booting) since the Phoenix stuff wasn't working. I've patched the mailet to use JSR250 since my Phoenix foo is weak. If anyone finds the time and inclination to reverse this change and get the Phoenix stuff working, fine by me. BTW sorry for missing the JIRA number on the commit :-/
        Hide
        Norman Maurer added a comment -

        Hi Robert,

        thx for diggin.. Unfortunally I still can't get james to start with VirtualUserTable Mailet configured. I get:

        ava.lang.RuntimeException: Initialisation failed
        at org.apache.james.phoenix.PhoenixLoader.applicationStarted(PhoenixLoader.java:102)
        at org.apache.avalon.phoenix.components.application.ListenerSupport.applicationStarted(ListenerSupport.java:238)
        at org.apache.avalon.phoenix.components.application.DefaultApplication.doRunPhase(DefaultApplication.java:506)
        at org.apache.avalon.phoenix.components.application.DefaultApplication.runPhase(DefaultApplication.java:409)
        at org.apache.avalon.phoenix.components.application.DefaultApplication.start(DefaultApplication.java:180)
        at org.apache.avalon.framework.container.ContainerUtil.start(ContainerUtil.java:260)
        at org.apache.avalon.phoenix.components.kernel.DefaultKernel.startup(DefaultKernel.java:295)
        at org.apache.avalon.phoenix.components.kernel.DefaultKernel.addApplication(DefaultKernel.java:376)
        at org.apache.avalon.phoenix.components.deployer.DefaultDeployer.deploy(DefaultDeployer.java:357)
        at org.apache.avalon.phoenix.components.embeddor.DefaultEmbeddor.deployFile(DefaultEmbeddor.java:542)
        at org.apache.avalon.phoenix.components.embeddor.DefaultEmbeddor.deployFile(DefaultEmbeddor.java:535)
        at org.apache.avalon.phoenix.components.embeddor.DefaultEmbeddor.deployFiles(DefaultEmbeddor.java:520)
        at org.apache.avalon.phoenix.components.embeddor.DefaultEmbeddor.deployDefaultApplications(DefaultEmbeddor.java:509)
        at org.apache.avalon.phoenix.components.embeddor.DefaultEmbeddor.execute(DefaultEmbeddor.java:268)
        at org.apache.avalon.phoenix.frontends.CLIMain.run(CLIMain.java:198)
        at org.apache.avalon.phoenix.frontends.CLIMain.execute(CLIMain.java:184)
        at org.apache.avalon.phoenix.frontends.CLIMain.main(CLIMain.java:145)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.avalon.phoenix.launcher.Main.startup(Main.java:135)
        at org.apache.avalon.phoenix.launcher.Main.main(Main.java:84)
        Caused by: java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.james.phoenix.PhoenixLoader.applicationStarted(PhoenixLoader.java:97)
        ... 22 more
        Caused by: org.apache.avalon.framework.configuration.ConfigurationException: Unable to init mailet @file:/x1/home/norman/james-server-3.0-SNAPSHOT/apps/james/SAR-INF/config.xml:553:48
        at org.apache.james.transport.LinearProcessor.configure(LinearProcessor.java:653)
        at org.apache.avalon.framework.container.ContainerUtil.configure(ContainerUtil.java:201)
        at org.apache.james.transport.StateAwareProcessorList.initialize(StateAwareProcessorList.java:101)
        at org.apache.avalon.framework.container.ContainerUtil.initialize(ContainerUtil.java:244)
        at org.apache.james.transport.JamesSpoolManager.initialize(JamesSpoolManager.java:159)
        ... 27 more
        Caused by: org.apache.mailet.MailetException: Not initialised. Please ensure that the mailet container supports either setter or constructor injection.
        at org.apache.james.transport.mailets.VirtualUserTable.init(VirtualUserTable.java:91)
        at org.apache.mailet.base.GenericMailet.init(GenericMailet.java:162)
        at org.apache.james.transport.JamesMailetLoader.getMailet(JamesMailetLoader.java:82)
        at org.apache.james.transport.LinearProcessor.configure(LinearProcessor.java:628)
        ... 31 more

        Show
        Norman Maurer added a comment - Hi Robert, thx for diggin.. Unfortunally I still can't get james to start with VirtualUserTable Mailet configured. I get: ava.lang.RuntimeException: Initialisation failed at org.apache.james.phoenix.PhoenixLoader.applicationStarted(PhoenixLoader.java:102) at org.apache.avalon.phoenix.components.application.ListenerSupport.applicationStarted(ListenerSupport.java:238) at org.apache.avalon.phoenix.components.application.DefaultApplication.doRunPhase(DefaultApplication.java:506) at org.apache.avalon.phoenix.components.application.DefaultApplication.runPhase(DefaultApplication.java:409) at org.apache.avalon.phoenix.components.application.DefaultApplication.start(DefaultApplication.java:180) at org.apache.avalon.framework.container.ContainerUtil.start(ContainerUtil.java:260) at org.apache.avalon.phoenix.components.kernel.DefaultKernel.startup(DefaultKernel.java:295) at org.apache.avalon.phoenix.components.kernel.DefaultKernel.addApplication(DefaultKernel.java:376) at org.apache.avalon.phoenix.components.deployer.DefaultDeployer.deploy(DefaultDeployer.java:357) at org.apache.avalon.phoenix.components.embeddor.DefaultEmbeddor.deployFile(DefaultEmbeddor.java:542) at org.apache.avalon.phoenix.components.embeddor.DefaultEmbeddor.deployFile(DefaultEmbeddor.java:535) at org.apache.avalon.phoenix.components.embeddor.DefaultEmbeddor.deployFiles(DefaultEmbeddor.java:520) at org.apache.avalon.phoenix.components.embeddor.DefaultEmbeddor.deployDefaultApplications(DefaultEmbeddor.java:509) at org.apache.avalon.phoenix.components.embeddor.DefaultEmbeddor.execute(DefaultEmbeddor.java:268) at org.apache.avalon.phoenix.frontends.CLIMain.run(CLIMain.java:198) at org.apache.avalon.phoenix.frontends.CLIMain.execute(CLIMain.java:184) at org.apache.avalon.phoenix.frontends.CLIMain.main(CLIMain.java:145) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.avalon.phoenix.launcher.Main.startup(Main.java:135) at org.apache.avalon.phoenix.launcher.Main.main(Main.java:84) Caused by: java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.james.phoenix.PhoenixLoader.applicationStarted(PhoenixLoader.java:97) ... 22 more Caused by: org.apache.avalon.framework.configuration.ConfigurationException: Unable to init mailet @ file:/x1/home/norman/james-server-3.0-SNAPSHOT/apps/james/SAR-INF/config.xml:553:48 at org.apache.james.transport.LinearProcessor.configure(LinearProcessor.java:653) at org.apache.avalon.framework.container.ContainerUtil.configure(ContainerUtil.java:201) at org.apache.james.transport.StateAwareProcessorList.initialize(StateAwareProcessorList.java:101) at org.apache.avalon.framework.container.ContainerUtil.initialize(ContainerUtil.java:244) at org.apache.james.transport.JamesSpoolManager.initialize(JamesSpoolManager.java:159) ... 27 more Caused by: org.apache.mailet.MailetException: Not initialised. Please ensure that the mailet container supports either setter or constructor injection. at org.apache.james.transport.mailets.VirtualUserTable.init(VirtualUserTable.java:91) at org.apache.mailet.base.GenericMailet.init(GenericMailet.java:162) at org.apache.james.transport.JamesMailetLoader.getMailet(JamesMailetLoader.java:82) at org.apache.james.transport.LinearProcessor.configure(LinearProcessor.java:628) ... 31 more
        Hide
        Robert Burrell Donkin added a comment -

        That should be fixed now.

        Show
        Robert Burrell Donkin added a comment - That should be fixed now.
        Show
        Robert Burrell Donkin added a comment - svn diff http://svn.apache.org/repos/asf/james/server/branches/next-minor/src/java/org/apache/james/transport/mailets/AbstractVirtualUserTable.java http://svn.apache.org/repos/asf/james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/AbstractVirtualUserTable.java The current doesn't work and seems to be missed code that actually does stuff (like the forwarding).
        Hide
        Robert Burrell Donkin added a comment -

        Bit confused in the last comment. I can't see how the local delivery is supposed to work either in the old or new mailets.

        I would expect the mail mapped to local users to be posted back into the system with new recipiants but AFACT it's not.

        Show
        Robert Burrell Donkin added a comment - Bit confused in the last comment. I can't see how the local delivery is supposed to work either in the old or new mailets. I would expect the mail mapped to local users to be posted back into the system with new recipiants but AFACT it's not.
        Hide
        Robert Burrell Donkin added a comment -

        I'm a little confused. Can anyone explain how the follow code set new local recipients?

        public abstract class AbstractVirtualUserTableMailet extends GenericMailet {

        /*

        • (non-Javadoc)
        • @see org.apache.mailet.base.GenericMailet#service(org.apache.mailet.Mail)
          */
          public void service(Mail mail) throws MessagingException {
          Collection recipients = mail.getRecipients();
          Collection errors = new Vector();

        MimeMessage message = mail.getMessage();

        // Set Return-Path and remove all other Return-Path headers from the
        // message
        // This only works because there is a placeholder inserted by
        // MimeMessageWrapper
        message
        .setHeader(RFC2822Headers.RETURN_PATH,
        (mail.getSender() == null ? "<>" : "<"
        + mail.getSender() + ">"));

        Collection newRecipients = new LinkedList();
        for (Iterator i = recipients.iterator(); i.hasNext() {
        MailAddress recipient = (MailAddress) i.next();
        try {
        Collection usernames = processMail(mail.getSender(), recipient,
        message);

        // if the username is null or changed we remove it from the
        // remaining recipients
        if (usernames == null)

        { i.remove(); }

        else

        { i.remove(); // if the username has been changed we add a new recipient // with the new name. newRecipients.addAll(usernames); }

        } catch (Exception ex)

        { getMailetContext().log("Error while storing mail.", ex); errors.add(recipient); }

        }

        if (newRecipients.size() > 0)

        { recipients.addAll(newRecipients); }

        if (!errors.isEmpty())

        { // If there were errors, we redirect the email to the ERROR // processor. // In order for this server to meet the requirements of the SMTP // specification, mails on the ERROR processor must be returned to // the sender. Note that this email doesn't include any details // regarding the details of the failure(s). // In the future we may wish to address this. getMailetContext().sendMail(mail.getSender(), errors, message, Mail.ERROR); }

        if (recipients.size() == 0)

        { // We always consume this message mail.setState(Mail.GHOST); }
        Show
        Robert Burrell Donkin added a comment - I'm a little confused. Can anyone explain how the follow code set new local recipients? public abstract class AbstractVirtualUserTableMailet extends GenericMailet { /* (non-Javadoc) @see org.apache.mailet.base.GenericMailet#service(org.apache.mailet.Mail) */ public void service(Mail mail) throws MessagingException { Collection recipients = mail.getRecipients(); Collection errors = new Vector(); MimeMessage message = mail.getMessage(); // Set Return-Path and remove all other Return-Path headers from the // message // This only works because there is a placeholder inserted by // MimeMessageWrapper message .setHeader(RFC2822Headers.RETURN_PATH, (mail.getSender() == null ? "<>" : "<" + mail.getSender() + ">")); Collection newRecipients = new LinkedList(); for (Iterator i = recipients.iterator(); i.hasNext() { MailAddress recipient = (MailAddress) i.next(); try { Collection usernames = processMail(mail.getSender(), recipient, message); // if the username is null or changed we remove it from the // remaining recipients if (usernames == null) { i.remove(); } else { i.remove(); // if the username has been changed we add a new recipient // with the new name. newRecipients.addAll(usernames); } } catch (Exception ex) { getMailetContext().log("Error while storing mail.", ex); errors.add(recipient); } } if (newRecipients.size() > 0) { recipients.addAll(newRecipients); } if (!errors.isEmpty()) { // If there were errors, we redirect the email to the ERROR // processor. // In order for this server to meet the requirements of the SMTP // specification, mails on the ERROR processor must be returned to // the sender. Note that this email doesn't include any details // regarding the details of the failure(s). // In the future we may wish to address this. getMailetContext().sendMail(mail.getSender(), errors, message, Mail.ERROR); } if (recipients.size() == 0) { // We always consume this message mail.setState(Mail.GHOST); }
        Hide
        Stefano Bagnara added a comment -

        Collection recipients = mail.getRecipients();

        you get the internal recipients collection and not a copy (MAILET-5)

        and then:

        if (newRecipients.size() > 0)

        { recipients.addAll(newRecipients); }

        Add the new recipients to the collection.

        Show
        Stefano Bagnara added a comment - Collection recipients = mail.getRecipients(); you get the internal recipients collection and not a copy ( MAILET-5 ) and then: if (newRecipients.size() > 0) { recipients.addAll(newRecipients); } Add the new recipients to the collection.
        Hide
        Robert Burrell Donkin added a comment -

        ok - so:

        1. mail.getRecipients returns an live collection (which when mutated alters recipients for future processing). the Mail javadocs are not clear so i'll patch them
        2. the local variable is logically final

        if i undestand correctly, LocalMatcher should check this collection and then pass on to LocalDelivery.

        Show
        Robert Burrell Donkin added a comment - ok - so: 1. mail.getRecipients returns an live collection (which when mutated alters recipients for future processing). the Mail javadocs are not clear so i'll patch them 2. the local variable is logically final if i undestand correctly, LocalMatcher should check this collection and then pass on to LocalDelivery.
        Hide
        Robert Burrell Donkin added a comment -

        I have this working in a smoke test for the phoenix deployment (but not spring). Note that virtual hosting needs to be switched off, or users need to be fully qualified.

        Show
        Robert Burrell Donkin added a comment - I have this working in a smoke test for the phoenix deployment (but not spring). Note that virtual hosting needs to be switched off, or users need to be fully qualified.
        Hide
        Norman Maurer added a comment -

        Its workin again..

        Show
        Norman Maurer added a comment - Its workin again..

          People

          • Assignee:
            Norman Maurer
            Reporter:
            Norman Maurer
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development