title: Getting exception org.apache.cxf.interceptor.Fault: org/apache/camel/CamelContext
body: <p>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:</p>
  
  <p><a href="http://camel.465427.n5.nabble.com/i-am-getting-exception-org-apache-cxf-interceptor-Fault-org-apache-camel-CamelContext-td5742012.html#a5742016" rel="nofollow">http://camel.465427.n5.nabble.com/i-am-getting-exception-org-apache-cxf-interceptor-Fault-org-apache-camel-CamelContext-td5742012.html#a5742016</a></p>
  
  <p>This is my method of rest services.</p>
  
  <pre><code>    @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();
  }
  </code></pre>
  
  <p>This method invokes the method of the EmailInterface class. </p>
  
  <pre><code> public class EmailInterface {
     private CamelContext camel;
     private ProducerTemplate template;
  
  public boolean sendEmail(JSONObject data)
  {
      boolean status=false;
      camel = new DefaultCamelContext();
      template = camel.createProducerTemplate();
  
      Map&lt;String, Object&gt; map = new HashMap&lt;String, Object&gt;();
      map.put("To",data.getString("toaddress"));
      String body = data.getString("body");
      map.put("Subject", data.getString("subject"));
      map.put("From", "xxxx@yahoo.com");
  
      template.sendBodyAndHeaders("smtps://smtp.gmail.com?                 username=xxxxx@gmail.com&amp;password=ixxxxx", body, map);
      status=true;
      return status;
  
  }
    public static void main(String args[])
  {
  
      JSONObject data=new JSONObject();
      data.put("toaddress", "xxxxxxx@gmail.com");
      data.put("subject", "Service Status");
      data.put("body", "hi testing message");
      EmailInterface emailInterface=new EmailInterface();
      System.out.println(emailInterface.sendEmail(data));
  }
  </code></pre>
  
  <p>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.</p>