Results 1 to 4 of 4

Thread: Spring Mail support getting test failure while running out side eclipse.

  1. #1
    Join Date
    Mar 2008
    Location
    India
    Posts
    12

    Red face Spring Mail support getting test failure while running out side eclipse.

    Hi spring guys,

    I am using spring mail support.

    I am getting an strange problem, while i am running my test case for my mail service inside eclipse its running fine while running it from maven through console its showing build failure and giving error.

    I am using spring 2.5.5. and java (1.5.0_15) dependency for maven pom is

    <plugins>
    <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>2.0.2</version>
    <configuration>
    <source>1.5</source>
    <target>1.5</target>
    </configuration>
    </plugin>
    </plugins>


    and java mail 1.3.3 with activation 1.0.2

    I think this is a jar issue. Can any body help me which jars are supportable for this.

    Let me know if any solution or i should arise this issue on jira.



    I have attached my stack trace file.



    Thanks,
    Shakil Akhtar
    Attached Files Attached Files

  2. #2
    Join Date
    Apr 2005
    Location
    Finland
    Posts
    314

    Default

    I think the error message is quite obvious.

    java.lang.NoClassDefFoundError: com/sun/activation/registries/LogSupport

    You're missing activation.jar or you're using old/wrong version which does not contain LogSupport class.

    You mentioned that this is a test class. Do mean by "test class" a unit test class or just a "test" class? In unit tests it's not recommended that the unit tests have dependencies to external resources like smtp server etc.... this is just a side note
    if a trainstation is where the train stops, what's a workstation...

  3. #3
    Join Date
    Mar 2008
    Location
    India
    Posts
    12

    Default

    Hi Noon,

    Thanks for replying,

    Unit test i.e Junit i have written for my MailManager class that is using spring and velocity in that its running fine in eclipse on run as junit and even sending emails.
    but when i do maven build it shows this error.

    if you have used spring 2.5.5 can you tell me which activation and java mail version with jdk 1.5.0_15 i should use to make maven build fine so that my junit test case will run fine.

    i got this problem before this module in my project so for my first release i have to go with pure java mail.

    Because spring is providing excellent mail support so i want to go with that.

    Here is my mail manager.

    public class MailManager
    {

    private static final Log LOG = LogFactory
    .getLog(MailManager.class);

    private JavaMailSender mailSender;

    private String subject;

    private String from;

    private VelocityEngine velocityEngine;

    private String templateFile;

    public void sendMail(final AlertNotification alertNotification,
    final String[] toAddresses)throws MessagingException
    {
    MimeMessagePreparator preparator = new MimeMessagePreparator() {
    public void prepare(MimeMessage mimeMessage) throws MessagingException
    {
    MimeMessageHelper message = new MimeMessageHelper(mimeMessage);
    message.setTo(toAddresses);
    message.setSubject(subject);
    message.setFrom(from);
    Map model = new HashMap();
    model.put("alertNotification", alertNotification);
    String text = VelocityEngineUtils.mergeTemplateIntoString(
    velocityEngine, templateFile, model);
    message.setText(text, true);
    }
    };
    this.mailSender.send(preparator);
    }


    public void setVelocityEngine(VelocityEngine velocityEngn)
    {
    this.velocityEngine = velocityEngn;
    }

    public void setTemplateFile(String file)
    {
    this.templateFile = file;
    }

    public void setMailSender(JavaMailSender sender)
    {
    this.mailSender = sender;
    }

    public void setSubject(String sbjct)
    {
    this.subject = sbjct;
    }

    public void setFrom(String frm)
    {
    this.from = frm;
    }
    }

    please help me its urgent for release to take decision for java mail or spring mail.

    thanks in advance.
    Last edited by Akhtar; Nov 2nd, 2008 at 10:01 PM.

  4. #4
    Join Date
    Apr 2005
    Location
    Finland
    Posts
    314

    Default

    I think you should use activation 1.1. version instead of the 1.0.2. since the com/sun/activation/registries/LogSupport class exists only in 1.1. version (not in 1.0.2).

    This doesn't explain why it's working in Eclipse. I think Eclipse finds it from other JAR in your classpath??
    if a trainstation is where the train stops, what's a workstation...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •