gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-29 03:28:51 25 4
gpt4 key购买 nike

我正在使用 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 的主要方法调用时,它工作正常并发送电子邮件,但是当我尝试从 rest 调用时,我只得到这个执行。

最佳答案

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

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

关于java - 获取异常 org.apache.cxf.interceptor.Fault : org/apache/camel/CamelContext,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19512448/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com