繁体   English   中英

获取异常org.apache.cxf.interceptor.Fault:org / apache / camel / CamelContext

[英]Getting exception org.apache.cxf.interceptor.Fault: org/apache/camel/CamelContext

我正在使用Apache Camel发送电子邮件。 当我从我的主类调用send方法时,我没有得到任何异常但是当我尝试从rest服务调用它时,我得到了这个异常,完整的跟踪在这里:

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

这是我的休息服务方法。

    @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();
}

此方法调用EmailInterface类的方法。

 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", "xxxx@yahoo.com");

    template.sendBodyAndHeaders("smtps://smtp.gmail.com?                 username=xxxxx@gmail.com&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));
}

当我从EmailInterface的主要方法调用时,它的工作正常并发送电子邮件,但是当我尝试从休息时调用然后我只得到这个执行。

你的libs java.lang.NoClassDefFoundError: org/apache/camel/CamelContext似乎有问题。

将它们包含在服务器的lib文件夹中。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM