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 Kraig Schario <ct...@cinti.net> on 2003/12/29 15:43:49 UTC

Determine Message Size in Mailet

I am having a problem with a mailet when copying the Mail mail object to a
MimeMessage.

    MimeMessage message = mail.getMessage();

It only occurs when the message contains large attachments. Usually larger
than 2 MB.  I receive the following error in the Mailet.log

    java.lang.OutOfMemoryError

And the message is sent to the Error Processor.

Is there a way to test the size of the mail object before copying it to a
MimeMessage to access the getSize() method?

I experience the problem in both James 2.1.3 and James 2.2.0a15.  Runing on
RedHat 9 or on Windows XP and 2000.  The systems have 512 MB and 1.8GHz
processors, so I don't think it is resource related.  I am using Sun Java
version j2re1.4.2_03

Thanks


Kraig Schario


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


Re: Determine Message Size in Mailet

Posted by "Richard O. Hammer" <RO...@EarthLink.net>.
Oh, and let me add that documentation (or perhaps I should say hints) 
about that memory-increasing command line option can be found in 
places like this 
<http://java.sun.com/j2se/1.4.1/docs/tooldocs/windows/java.html>.


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


Re: Determine Message Size in Mailet

Posted by "Richard O. Hammer" <RO...@EarthLink.net>.
Kraig Schario wrote:
> I am having a problem with a mailet when copying the Mail mail object to a
> MimeMessage.
> 
>     MimeMessage message = mail.getMessage();
> 
> It only occurs when the message contains large attachments. Usually larger
> than 2 MB.  I receive the following error in the Mailet.log
> 
>     java.lang.OutOfMemoryError


I think one way to deal with this is to give the JVM more memory to 
work with than it gets by default.  You can do this with a command 
line option to the "java" command, an option like "-Xmx96m".

I had this working once, after experimenting some, and was thereby 
able to process bigger messages through JavaMail.  Unfortunately, now 
I can't find specifically what option I used.  You may succeed with 
trial and error.

As I recall, the JVM gets 64 megs by default in my situation.

Rich Hammer


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


Re: Determine Message Size in Mailet

Posted by Kraig Schario <ct...@cinti.net>.
Thanks Corey,

That worked.  I set the following options -Xms64m and -Xmx128m

Kraig
----- Original Message ----- 
From: "Corey A. Johnson" <cj...@cniweb.net>
To: "James Users List" <se...@james.apache.org>
Sent: Monday, December 29, 2003 11:01 AM
Subject: Re: Determine Message Size in Mailet


> Are you running any special start-up parameters with the JVM?
>
> I have Phoenix (James) running with these parameters:
>
> JVM_OPTS="-server -ms384m -mx384m -Djava.ext.dirs=$PHOENIX_HOME/lib"
>
> The above is used in the phoenix.sh startup script.  The server i am
> running James on has 2GB RAM.. so you may want to lower the 384 to maybe
> 256m or 128m... since your server is running with 512MB RAM.
>
> Not sure if it is related..  but you could try this and see if you still
> get the OutOfMemoryError.
>
> Cj
>
> Kraig Schario wrote:
>
> >The service code is as follows: I have only inclued the part where the
> >problem occurs. From what I can tell in all logging, is that it enters
the
> >mailet, it logs the message: 'Copying to MimeMessage', then I get the
> >java.lang.OutOfMemoryError and it never logs the 'Message getSize' line.
As
> >I said previously, it only does this on messages with large attachments.
> >
> >    public void service(Mail mail) throws MessagingException {
> >            try {
> >                log("Copying to MimeMessage");
> >                MimeMessage message = mail.getMessage();
> >                log("Message getSize()" + message.getSize());
> >
> >                . . .
> >
> >             catch (Exception e) {
> >                    log("Exception: "
> >                    + e.getMessage(), e);
> >                    throw new MessagingException("Exception thrown", e);
> >            }
> >    }
> >
> >Kraig
> >----- Original Message ----- 
> >From: "Corey A. Johnson" <cj...@cniweb.net>
> >To: "James Users List" <se...@james.apache.org>
> >Sent: Monday, December 29, 2003 10:26 AM
> >Subject: Re: Determine Message Size in Mailet
> >
> >
> >
> >
> >>Weird problem.  I am doing the same thing in a mailet.. without any
> >>issues.  But i am running on Solaris 8 for SPARC.
> >>
> >>can you email to list the service method code for your mailet?
> >>
> >>Cj
> >>
> >>Kraig Schario wrote:
> >>
> >>
> >>
> >>>I am having a problem with a mailet when copying the Mail mail object
to
> >>>
> >>>
> >a
> >
> >
> >>>MimeMessage.
> >>>
> >>>   MimeMessage message = mail.getMessage();
> >>>
> >>>It only occurs when the message contains large attachments. Usually
> >>>
> >>>
> >larger
> >
> >
> >>>than 2 MB.  I receive the following error in the Mailet.log
> >>>
> >>>   java.lang.OutOfMemoryError
> >>>
> >>>And the message is sent to the Error Processor.
> >>>
> >>>Is there a way to test the size of the mail object before copying it to
a
> >>>MimeMessage to access the getSize() method?
> >>>
> >>>I experience the problem in both James 2.1.3 and James 2.2.0a15.
Runing
> >>>
> >>>
> >on
> >
> >
> >>>RedHat 9 or on Windows XP and 2000.  The systems have 512 MB and 1.8GHz
> >>>processors, so I don't think it is resource related.  I am using Sun
Java
> >>>version j2re1.4.2_03
> >>>
> >>>Thanks
> >>>
> >>>
> >>>Kraig Schario
> >>>
> >>>
> >>>---------------------------------------------------------------------
> >>>To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
> >>>For additional commands, e-mail: server-user-help@james.apache.org
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>
> >>-- 
> >>Corey A. Johnson
> >>Creative Network Innovations
> >>http://www.cniweb.net/
> >>1-800-CNi-5547 ** 1-321-259-1984
> >>
> >>
> >>---------------------------------------------------------------------
> >>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
> >
> >
> >
> >
>
> -- 
> Corey A. Johnson
> Creative Network Innovations
> http://www.cniweb.net/
> 1-800-CNi-5547 ** 1-321-259-1984
>
>
> ---------------------------------------------------------------------
> 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: Determine Message Size in Mailet

Posted by "Corey A. Johnson" <cj...@cniweb.net>.
Are you running any special start-up parameters with the JVM?

I have Phoenix (James) running with these parameters:

JVM_OPTS="-server -ms384m -mx384m -Djava.ext.dirs=$PHOENIX_HOME/lib"

The above is used in the phoenix.sh startup script.  The server i am 
running James on has 2GB RAM.. so you may want to lower the 384 to maybe 
256m or 128m... since your server is running with 512MB RAM.

Not sure if it is related..  but you could try this and see if you still 
get the OutOfMemoryError.

Cj

Kraig Schario wrote:

>The service code is as follows: I have only inclued the part where the
>problem occurs. From what I can tell in all logging, is that it enters the
>mailet, it logs the message: 'Copying to MimeMessage', then I get the
>java.lang.OutOfMemoryError and it never logs the 'Message getSize' line.  As
>I said previously, it only does this on messages with large attachments.
>
>    public void service(Mail mail) throws MessagingException {
>            try {
>                log("Copying to MimeMessage");
>                MimeMessage message = mail.getMessage();
>                log("Message getSize()" + message.getSize());
>
>                . . .
>
>             catch (Exception e) {
>                    log("Exception: "
>                    + e.getMessage(), e);
>                    throw new MessagingException("Exception thrown", e);
>            }
>    }
>
>Kraig
>----- Original Message ----- 
>From: "Corey A. Johnson" <cj...@cniweb.net>
>To: "James Users List" <se...@james.apache.org>
>Sent: Monday, December 29, 2003 10:26 AM
>Subject: Re: Determine Message Size in Mailet
>
>
>  
>
>>Weird problem.  I am doing the same thing in a mailet.. without any
>>issues.  But i am running on Solaris 8 for SPARC.
>>
>>can you email to list the service method code for your mailet?
>>
>>Cj
>>
>>Kraig Schario wrote:
>>
>>    
>>
>>>I am having a problem with a mailet when copying the Mail mail object to
>>>      
>>>
>a
>  
>
>>>MimeMessage.
>>>
>>>   MimeMessage message = mail.getMessage();
>>>
>>>It only occurs when the message contains large attachments. Usually
>>>      
>>>
>larger
>  
>
>>>than 2 MB.  I receive the following error in the Mailet.log
>>>
>>>   java.lang.OutOfMemoryError
>>>
>>>And the message is sent to the Error Processor.
>>>
>>>Is there a way to test the size of the mail object before copying it to a
>>>MimeMessage to access the getSize() method?
>>>
>>>I experience the problem in both James 2.1.3 and James 2.2.0a15.  Runing
>>>      
>>>
>on
>  
>
>>>RedHat 9 or on Windows XP and 2000.  The systems have 512 MB and 1.8GHz
>>>processors, so I don't think it is resource related.  I am using Sun Java
>>>version j2re1.4.2_03
>>>
>>>Thanks
>>>
>>>
>>>Kraig Schario
>>>
>>>
>>>---------------------------------------------------------------------
>>>To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
>>>For additional commands, e-mail: server-user-help@james.apache.org
>>>
>>>
>>>
>>>
>>>      
>>>
>>-- 
>>Corey A. Johnson
>>Creative Network Innovations
>>http://www.cniweb.net/
>>1-800-CNi-5547 ** 1-321-259-1984
>>
>>
>>---------------------------------------------------------------------
>>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
>
>
>  
>

-- 
Corey A. Johnson
Creative Network Innovations
http://www.cniweb.net/
1-800-CNi-5547 ** 1-321-259-1984


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


Re: Determine Message Size in Mailet

Posted by Kraig Schario <ct...@cinti.net>.
The service code is as follows: I have only inclued the part where the
problem occurs. From what I can tell in all logging, is that it enters the
mailet, it logs the message: 'Copying to MimeMessage', then I get the
java.lang.OutOfMemoryError and it never logs the 'Message getSize' line.  As
I said previously, it only does this on messages with large attachments.

    public void service(Mail mail) throws MessagingException {
            try {
                log("Copying to MimeMessage");
                MimeMessage message = mail.getMessage();
                log("Message getSize()" + message.getSize());

                . . .

             catch (Exception e) {
                    log("Exception: "
                    + e.getMessage(), e);
                    throw new MessagingException("Exception thrown", e);
            }
    }

Kraig
----- Original Message ----- 
From: "Corey A. Johnson" <cj...@cniweb.net>
To: "James Users List" <se...@james.apache.org>
Sent: Monday, December 29, 2003 10:26 AM
Subject: Re: Determine Message Size in Mailet


> Weird problem.  I am doing the same thing in a mailet.. without any
> issues.  But i am running on Solaris 8 for SPARC.
>
> can you email to list the service method code for your mailet?
>
> Cj
>
> Kraig Schario wrote:
>
> >I am having a problem with a mailet when copying the Mail mail object to
a
> >MimeMessage.
> >
> >    MimeMessage message = mail.getMessage();
> >
> >It only occurs when the message contains large attachments. Usually
larger
> >than 2 MB.  I receive the following error in the Mailet.log
> >
> >    java.lang.OutOfMemoryError
> >
> >And the message is sent to the Error Processor.
> >
> >Is there a way to test the size of the mail object before copying it to a
> >MimeMessage to access the getSize() method?
> >
> >I experience the problem in both James 2.1.3 and James 2.2.0a15.  Runing
on
> >RedHat 9 or on Windows XP and 2000.  The systems have 512 MB and 1.8GHz
> >processors, so I don't think it is resource related.  I am using Sun Java
> >version j2re1.4.2_03
> >
> >Thanks
> >
> >
> >Kraig Schario
> >
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
> >For additional commands, e-mail: server-user-help@james.apache.org
> >
> >
> >
> >
>
> -- 
> Corey A. Johnson
> Creative Network Innovations
> http://www.cniweb.net/
> 1-800-CNi-5547 ** 1-321-259-1984
>
>
> ---------------------------------------------------------------------
> 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: Determine Message Size in Mailet

Posted by "Corey A. Johnson" <cj...@cniweb.net>.
Weird problem.  I am doing the same thing in a mailet.. without any 
issues.  But i am running on Solaris 8 for SPARC.

can you email to list the service method code for your mailet?

Cj

Kraig Schario wrote:

>I am having a problem with a mailet when copying the Mail mail object to a
>MimeMessage.
>
>    MimeMessage message = mail.getMessage();
>
>It only occurs when the message contains large attachments. Usually larger
>than 2 MB.  I receive the following error in the Mailet.log
>
>    java.lang.OutOfMemoryError
>
>And the message is sent to the Error Processor.
>
>Is there a way to test the size of the mail object before copying it to a
>MimeMessage to access the getSize() method?
>
>I experience the problem in both James 2.1.3 and James 2.2.0a15.  Runing on
>RedHat 9 or on Windows XP and 2000.  The systems have 512 MB and 1.8GHz
>processors, so I don't think it is resource related.  I am using Sun Java
>version j2re1.4.2_03
>
>Thanks
>
>
>Kraig Schario
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
>For additional commands, e-mail: server-user-help@james.apache.org
>
>
>  
>

-- 
Corey A. Johnson
Creative Network Innovations
http://www.cniweb.net/
1-800-CNi-5547 ** 1-321-259-1984


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


RE: Determine Message Size in Mailet

Posted by "Noel J. Bergman" <no...@devtech.com>.
Increase the available heap size for James using JVM_OPTS.  The default is
too small for your needs.

	--- Noel


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