Strange compile problem with javax.mail

From: Andreas Wollschlaeger (postmaster_at_1.0.0.127.in-addr.arpa)
Date: 01/29/04


Date: Thu, 29 Jan 2004 12:27:26 +0100

Hi folks,

i have a strange problem this morning which is just driving me nuts :-/

I am working on an app, one part is the sending of some email via
javax.mail! Here is a snippet of code:

-- snip --

         java.util.Properties p = System.getProperties();
         javax.mail.Session s = javax.mail.Session.getDefaultInstance(p);
         Message m = new MimeMessage(s);
        ...
         Transport t = s.getTransport("smtp");
         t.connect(smtphost, username, password);
         t.sendMessage(m, m.getAllRecipients());
         t.close();

-- snip --

Nothing special here! Now the problem: From within Netbeans, this
compiles and runs perfectly. But, when i launch ant to build the same
stuff, javac woes:

Compiling 34 source files to C:\work\ELP_BOT\ELP_BOT\__ELP_BOT\build
__ELP_BOT\src\com\elpmedien\backorder_tool\MailHelper.java [40]

getDefaultInstance(java.util.Properties,javax.mail.Authenticator) in
javax.mail.Session cannot be applied to (java.util.Properties)
         javax.mail.Session s = javax.mail.Session.getDefaultInstance(p);
                                                  ^
1 error

The strange thing is, i use the same set of jars both for Netbeans and
Ant! I also tried updating mail.jar and activation.jar with the current
version from java.sun.com, same result.

If i change the invocation of getDefaultInstance() to

   javax.mail.Session s = javax.mail.Session.getDefaultInstance(p,null);

the code builds, but throws an exception:

java.lang.NoClassDefFoundError: com/sun/mail/util/MailDateFormat
         at com.elpmedien.backorder_tool.MailHelper.sendMail(Unknown Source)

Any ideas?

Cheers
Andreas



Relevant Pages

  • Disappearing Sessions
    ... I'm presently converting a v1.1 ASP.NET app to v2, and am encountering a ... strange problem. ... When running in Debug mode (i.e. hitting F5), ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: glCallList infinite loop
    ... I have a strange problem with OpenGL in Windows XP. ... My app has 3 gl canvas (managed by wxWidgets). ... Memory bug, Use a memory tool like Purify. ...
    (comp.graphics.api.opengl)
  • glCallList infinite loop
    ... I have a strange problem with OpenGL in Windows XP. ... My app has 3 gl canvas (managed by wxWidgets). ...
    (comp.graphics.api.opengl)
  • Memory leak (yep, another one) with forms possibly
    ... I have a strange problem. ... I have what I consider a huge app for a ce/ppc ... all references to the outside thinking maybe there was something referencing ...
    (microsoft.public.dotnet.framework.compactframework)
  • Application.ThreadException doesnt catch in IDE
    ... Very strange problem that is only ocurring in one application (that is, ... can create a brand new app and not experience this problem). ... I have created a handler for Application.ThreadException, ... that simply displays the unhandled exception. ...
    (microsoft.public.vsnet.debugging)