You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-user@james.apache.org by Benoit Tellier <bt...@linagora.com> on 2015/01/09 15:10:13 UTC

Deploy a custom mailet in James 3.0.0-beta5

Hi,

I am trying to deploy a custom mailet and a custom matcher on my running
James server.

When adding my mailet or my matcher in the mailetcontainer.xml file, I
have a strange error ( repeted thousand of times ). I added the
stacktrace as an attachement for readability.

Here is how my code looks like :

    package com.linagora.openpaas.mailet;

    public class PostMailOnESN extends GenericMailet {

        public void init() throws MessagingException {
            // ...
        }

        public void service(Mail mail) throws MessagingException {
            // ...
        }

        public void destroy() {
            // ...
        }
    }

I added the generated jar in conf/lib directory.

Here is the section of mailetcontainer.xml file involving this mailet :

    <mailet
match="com.linagora.openpaas.matcher.ESNPostmasterMailMatcher=http://127.0.0.1:8080/api/messages/email/check%esn.james.minet.net"
class="com.linagora.openpaas.mailet.PostMailOnESN">
    	<esnip>127.0.0.1</esnip>
        <port>8080</port>
        <api>api/james/mail</api>
    </mailet>

Note that it works fine if I replace this mailet by :

	<mailet match="All" class="Null"/>

And That I get the same kind of stacktraces using the following non
existing mailet and matcher :

	<mailet match="Al" class="Null"/>

Or :

	<mailet match="All" class="Nul"/>

Oh and I am running james 3.0.0-beta5, on openjdk-7-jre ( I have the
same problem using openjdk-6-jre )

My question is :
  - have I made something wrong ? ( I have the impression
  - have someone deployed a custom mailet successfully on James
3.0.0-beta5 ? Does you have any tips ?

Thank you by advance,

Benoit



Re: Deploy a custom mailet in James 3.0.0-beta5

Posted by Benoit Tellier <bt...@linagora.com>.
Hi,

The problem was with some depandancies for this mailet : as I had no
meaningful logs, I was unable to locate the failing dependencies.

As a temporary warkaround, I compiled my mailet with jar-with-dependency
using maven.

And I had to add it by hand to the classpath the way you describe it. (
I tried it before but having a non satisfied dependency, I couldn't see
any improvements ).

It now works, thank you very much everybody.

Regards,

Benoit

On 01/13/15 07:54, Kurt Harders wrote:
> Hi Benoit,
>
> did you add your jar to the classpath in wrapper.conf like
> wrapper.java.classpath.128=/opt/james/conf/lib/localbounce.jar
>
> Regards, Kurt
>


---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org


Re: Deploy a custom mailet in James 3.0.0-beta5

Posted by Kurt Harders <ha...@khtronik.de>.
Hi Benoit,

did you add your jar to the classpath in wrapper.conf like
wrapper.java.classpath.128=/opt/james/conf/lib/localbounce.jar

Regards, Kurt

-- 
KHTronik - Kurt Harders 
Elektronik, Softwareentwicklung, Opensource-Beratung 
Leimbacher Str. 36 
42281 Wuppertal 

T +49 202  2 50 11 64 
F +49 202  2 50 11 65 
M +49 171  8 36 82 33 





---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org


Re: Deploy a custom mailet in James 3.0.0-beta5

Posted by Robert Munn <ro...@gmail.com>.
Benoit,

Below is the method that generated the error. This code is in:

org.apache.james.queue.jms.JMSMailQueue.deQueue(JMSMailQueue.java:171)

Looking at this code, it seems that if message is null, it will always generate an error because the while(true){} loop will never exit otherwise. For your debugging purposes, the message consumer is expecting a message and does not receive it within the timeout value, so it generates an error. I do not know why the message never comes through, but that’s where you should look for the problem. 

HTH

Robert

   public MailQueueItem deQueue() throws MailQueueException {
        Connection connection = null;
        Session session = null;
        Message message;
        MessageConsumer consumer = null;

        while (true) {
            try {
                connection = connectionFactory.createConnection();
                connection.start();

                session = connection.createSession(true, Session.SESSION_TRANSACTED);
                Queue queue = session.createQueue(queueName);
                consumer = session.createConsumer(queue, getMessageSelector());

                message = consumer.receive(10000);

                if (message != null) {
                    return createMailQueueItem(connection, session, consumer, message);
                } else {
                    session.commit();

                    if (consumer != null) {

                        try {
                            consumer.close();
                        } catch (JMSException e1) {
                            // ignore on rollback
                        }
                    }
                    try {
                        if (session != null)
                            session.close();
                    } catch (JMSException e1) {
                        // ignore here
                    }

                    try {
                        if (connection != null)
                            connection.close();
                    } catch (JMSException e1) {
                        // ignore here
                    }
                }

            } catch (Exception e) {
                if (session != null) {
                    try {
                        session.rollback();
                    } catch (JMSException e1) {
                        // ignore on rollback
                    }
                }

                if (consumer != null) {

                    try {
                        consumer.close();
                    } catch (JMSException e1) {
                        // ignore on rollback
                    }
                }
                try {
                    if (session != null)
                        session.close();
                } catch (JMSException e1) {
                    // ignore here
                }

                try {
                    if (connection != null)
                        connection.close();
                } catch (JMSException e1) {
                    // ignore here
                }
                throw new MailQueueException("Unable to dequeue next message", e);
            }
        }

    }






On Jan 12, 2015, at 9:37 AM, Benoit Tellier <bt...@linagora.com> wrote:

> Yes, I have well placed my jar in the conf/lib directory of my working
> james directory.
> 
> I tested it again today and I still get the exact same behaviour...
> 
> Thanks for the reply,
> 
> Benoit
> 
> On 01/12/15 14:04, Markus Moldaschl wrote:
>> Did you put the jar with your custom matcher in the proper directory?? e.g. with 3.0.0-beta3 you have to put it in [JAMES_HOME]/conf/lib
>> 
>> kr
>> Markus
>> 
>> 
>> 
>>> Am 09.01.2015 um 15:10 schrieb Benoit Tellier <bt...@linagora.com>:
>>> 
>>> Hi,
>>> 
>>> I am trying to deploy a custom mailet and a custom matcher on my running
>>> James server.
>>> 
>>> When adding my mailet or my matcher in the mailetcontainer.xml file, I
>>> have a strange error ( repeted thousand of times ). I added the
>>> stacktrace as an attachement for readability.
>>> 
>>> Here is how my code looks like :
>>> 
>>>   package com.linagora.openpaas.mailet;
>>> 
>>>   public class PostMailOnESN extends GenericMailet {
>>> 
>>>       public void init() throws MessagingException {
>>>           // ...
>>>       }
>>> 
>>>       public void service(Mail mail) throws MessagingException {
>>>           // ...
>>>       }
>>> 
>>>       public void destroy() {
>>>           // ...
>>>       }
>>>   }
>>> 
>>> I added the generated jar in conf/lib directory.
>>> 
>>> Here is the section of mailetcontainer.xml file involving this mailet :
>>> 
>>>   <mailet
>>> match="com.linagora.openpaas.matcher.ESNPostmasterMailMatcher=http://127.0.0.1:8080/api/messages/email/check%esn.james.minet.net"
>>> class="com.linagora.openpaas.mailet.PostMailOnESN">
>>>   	<esnip>127.0.0.1</esnip>
>>>       <port>8080</port>
>>>       <api>api/james/mail</api>
>>>   </mailet>
>>> 
>>> Note that it works fine if I replace this mailet by :
>>> 
>>> 	<mailet match="All" class="Null"/>
>>> 
>>> And That I get the same kind of stacktraces using the following non
>>> existing mailet and matcher :
>>> 
>>> 	<mailet match="Al" class="Null"/>
>>> 
>>> Or :
>>> 
>>> 	<mailet match="All" class="Nul"/>
>>> 
>>> Oh and I am running james 3.0.0-beta5, on openjdk-7-jre ( I have the
>>> same problem using openjdk-6-jre )
>>> 
>>> My question is :
>>> - have I made something wrong ? ( I have the impression
>>> - have someone deployed a custom mailet successfully on James
>>> 3.0.0-beta5 ? Does you have any tips ?
>>> 
>>> Thank you by advance,
>>> 
>>> Benoit
>>> 
>>> 
>>> <stacktrace.txt>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
>>> For additional commands, e-mail: server-user-help@james.apache.org
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
>> For additional commands, e-mail: server-user-help@james.apache.org
>> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
> For additional commands, e-mail: server-user-help@james.apache.org
> 


Re: Deploy a custom mailet in James 3.0.0-beta5

Posted by Benoit Tellier <bt...@linagora.com>.
Yes, I have well placed my jar in the conf/lib directory of my working
james directory.

I tested it again today and I still get the exact same behaviour...

Thanks for the reply,

Benoit

On 01/12/15 14:04, Markus Moldaschl wrote:
> Did you put the jar with your custom matcher in the proper directory?? e.g. with 3.0.0-beta3 you have to put it in [JAMES_HOME]/conf/lib
>
> kr
> Markus
>
>
>
>> Am 09.01.2015 um 15:10 schrieb Benoit Tellier <bt...@linagora.com>:
>>
>> Hi,
>>
>> I am trying to deploy a custom mailet and a custom matcher on my running
>> James server.
>>
>> When adding my mailet or my matcher in the mailetcontainer.xml file, I
>> have a strange error ( repeted thousand of times ). I added the
>> stacktrace as an attachement for readability.
>>
>> Here is how my code looks like :
>>
>>    package com.linagora.openpaas.mailet;
>>
>>    public class PostMailOnESN extends GenericMailet {
>>
>>        public void init() throws MessagingException {
>>            // ...
>>        }
>>
>>        public void service(Mail mail) throws MessagingException {
>>            // ...
>>        }
>>
>>        public void destroy() {
>>            // ...
>>        }
>>    }
>>
>> I added the generated jar in conf/lib directory.
>>
>> Here is the section of mailetcontainer.xml file involving this mailet :
>>
>>    <mailet
>> match="com.linagora.openpaas.matcher.ESNPostmasterMailMatcher=http://127.0.0.1:8080/api/messages/email/check%esn.james.minet.net"
>> class="com.linagora.openpaas.mailet.PostMailOnESN">
>>    	<esnip>127.0.0.1</esnip>
>>        <port>8080</port>
>>        <api>api/james/mail</api>
>>    </mailet>
>>
>> Note that it works fine if I replace this mailet by :
>>
>> 	<mailet match="All" class="Null"/>
>>
>> And That I get the same kind of stacktraces using the following non
>> existing mailet and matcher :
>>
>> 	<mailet match="Al" class="Null"/>
>>
>> Or :
>>
>> 	<mailet match="All" class="Nul"/>
>>
>> Oh and I am running james 3.0.0-beta5, on openjdk-7-jre ( I have the
>> same problem using openjdk-6-jre )
>>
>> My question is :
>>  - have I made something wrong ? ( I have the impression
>>  - have someone deployed a custom mailet successfully on James
>> 3.0.0-beta5 ? Does you have any tips ?
>>
>> Thank you by advance,
>>
>> Benoit
>>
>>
>> <stacktrace.txt>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
>> For additional commands, e-mail: server-user-help@james.apache.org
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
> For additional commands, e-mail: server-user-help@james.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org


Re: Deploy a custom mailet in James 3.0.0-beta5

Posted by Markus Moldaschl <Ma...@willhaben.at>.
Did you put the jar with your custom matcher in the proper directory?? e.g. with 3.0.0-beta3 you have to put it in [JAMES_HOME]/conf/lib

kr
Markus



> Am 09.01.2015 um 15:10 schrieb Benoit Tellier <bt...@linagora.com>:
> 
> Hi,
> 
> I am trying to deploy a custom mailet and a custom matcher on my running
> James server.
> 
> When adding my mailet or my matcher in the mailetcontainer.xml file, I
> have a strange error ( repeted thousand of times ). I added the
> stacktrace as an attachement for readability.
> 
> Here is how my code looks like :
> 
>    package com.linagora.openpaas.mailet;
> 
>    public class PostMailOnESN extends GenericMailet {
> 
>        public void init() throws MessagingException {
>            // ...
>        }
> 
>        public void service(Mail mail) throws MessagingException {
>            // ...
>        }
> 
>        public void destroy() {
>            // ...
>        }
>    }
> 
> I added the generated jar in conf/lib directory.
> 
> Here is the section of mailetcontainer.xml file involving this mailet :
> 
>    <mailet
> match="com.linagora.openpaas.matcher.ESNPostmasterMailMatcher=http://127.0.0.1:8080/api/messages/email/check%esn.james.minet.net"
> class="com.linagora.openpaas.mailet.PostMailOnESN">
>    	<esnip>127.0.0.1</esnip>
>        <port>8080</port>
>        <api>api/james/mail</api>
>    </mailet>
> 
> Note that it works fine if I replace this mailet by :
> 
> 	<mailet match="All" class="Null"/>
> 
> And That I get the same kind of stacktraces using the following non
> existing mailet and matcher :
> 
> 	<mailet match="Al" class="Null"/>
> 
> Or :
> 
> 	<mailet match="All" class="Nul"/>
> 
> Oh and I am running james 3.0.0-beta5, on openjdk-7-jre ( I have the
> same problem using openjdk-6-jre )
> 
> My question is :
>  - have I made something wrong ? ( I have the impression
>  - have someone deployed a custom mailet successfully on James
> 3.0.0-beta5 ? Does you have any tips ?
> 
> Thank you by advance,
> 
> Benoit
> 
> 
> <stacktrace.txt>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
> For additional commands, e-mail: server-user-help@james.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org