1

I am sending the email using Apache Camel. When I call the send method from my main class I am not getting any exception but when I am trying to invoke it from rest services then I am getting this exception, the full trace is here:

http://camel.465427.n5.nabble.com/i-am-getting-exception-org-apache-cxf-interceptor-Fault-org-apache-camel-CamelContext-td5742012.html#a5742016

This is my method of rest services.

    @POST
@Path("/sendemail")
public Response sendEmail(final String userdata)
{
    System.out.println("the starting of the send email process");
    ResponseBuilder builder=Response.ok();
    JSONObject data=(JSONObject) JSONSerializer.toJSON(userdata);

    EmailInterface ei=new EmailInterface();
    boolean status=ei.sendEmail(data);
    if(status)
        builder.status(200).entity("SUCCESS");
    else
        builder.status(400).entity("UN SUCCESS");
    return builder.build();
}

This method invokes the method of the EmailInterface class.

 public class EmailInterface {
   private CamelContext camel;
   private ProducerTemplate template;

public boolean sendEmail(JSONObject data)
{
    boolean status=false;
    camel = new DefaultCamelContext();
    template = camel.createProducerTemplate();

    Map<String, Object> map = new HashMap<String, Object>();
    map.put("To",data.getString("toaddress"));
    String body = data.getString("body");
    map.put("Subject", data.getString("subject"));
    map.put("From", "[email protected]");

    template.sendBodyAndHeaders("smtps://smtp.gmail.com?                 [email protected]&password=ixxxxx", body, map);
    status=true;
    return status;

}
  public static void main(String args[])
{

    JSONObject data=new JSONObject();
    data.put("toaddress", "[email protected]");
    data.put("subject", "Service Status");
    data.put("body", "hi testing message");
    EmailInterface emailInterface=new EmailInterface();
    System.out.println(emailInterface.sendEmail(data));
}

When I call from the main method of EmailInterface, then its working fine and sends the email, but when I try to call from rest then I am only getting this execption.

3
  • It seems that you have a problem with your libs (java.lang.NoClassDefFoundError: org/apache/camel/CamelContext). Are you sure that camel libs are included in your war when you deploy your web service ? Commented Oct 22, 2013 at 8:37
  • i included two lib file into class path.so its working from main class but not working from rest uri. Commented Oct 22, 2013 at 8:41
  • hey.i included in class path then its not working but when i pute in apache lib folder then its working fine...thanks you for help. Commented Oct 22, 2013 at 8:44

1 Answer 1

4

It seems that you have a problem with your libs java.lang.NoClassDefFoundError: org/apache/camel/CamelContext.

Include them in the server's lib folder.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.