在窗口电话上推送通知

时间:2013-06-21 08:25:25

标签: java windows-phone-7

我正在移动操作系统上构建一个多平台推送通知系统。我的服务器是用JSP servlet编写的。在窗口电话平台上构建时遇到的问题。我尝试使用ASP服务器在这个操作系统上进行测试,它们运行良好。但是因为我的服务器是JSP所以我想从ASP转向JSP以保持一致性。我在这里使用了库mpns https://github.com/notnoop/java-mpns 来执行此操作。但是在运行过程中,我的服务器出现故障,并且无法将消息发送给客户端。可以帮助我!

当我在调试中运行它到 MpnsService服务= MPNS.newService()。build(); 时,服务器停止而不再运行。和WebBrowser错误消息 HTTP状态500 - Servlet执行引发异常

代码服务器

public class SendAllMessagesServlet extends BaseServlet {

@Override
 protected void doPost(HttpServletRequest req, HttpServletResponse resp)
  throws IOException, ServletException {
  String uri=req.getParameter("uri");
  String title=req.getParameter("title");
  String content=req.getParameter("content");
  String page=req.getParameter("page");
  MpnsService service =
          MPNS.newService()
                  .build();
  TileNotification tile = MPNS.newNotification().tile()
          .count(1).title(title).backBackgroundImage("http://sample.com/image.png")
          .backTitle(content)
          .build();
  String subscriptionUri = uri;
  service.push(subscriptionUri, tile);

//PushNotificationWP push=new PushNotificationWP();
//push.PushNotif(title,content,page,uri);
getServletContext().getRequestDispatcher("/home").forward(req, resp);
 }

 }

网络浏览器出错

HTTP Status 500 - Servlet execution threw an exception

type Exception report message Servlet execution threw an exception description The server encountered an internal error that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: Servlet execution threw an exception root cause

java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
org.apache.http.impl.client.AbstractHttpClient.<init>(AbstractHttpClient.java:187)
org.apache.http.impl.client.DefaultHttpClient.<init>(DefaultHttpClient.java:146)
mpns.MpnsServiceBuilder.build(MpnsServiceBuilder.java:185)
SendAllMessagesServlet.doPost(SendAllMessagesServlet.java:32)
javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
 note The full stack trace of the root cause is available in the Apache Tomcat/7.0.37 logs.

1 个答案:

答案 0 :(得分:0)

您应该在您的应用程序中包含commons-loggin jar。你可以在commons.apache.org

找到它

下载文件后,打开文件并将名为commons-logging-1.1.3.jar的文件(假设您已下载最后一个二进制文件)复制到Web应用程序中。

祝你好运