0

我正在移动操作系统上构建一个多平台推送通知系统。我的服务器是用 JSP servlet 编写的。我在window phone平台上构建时遇到的问题。我在这个操作系统上用ASP服务器试了一下push,运行良好。但是因为我的服务器是 JSP,所以我想从 ASP 迁移到 JSP 以保持一致性。我在这里使用了库 mpns https://github.com/notnoop/java-mpns来做到这一点。但是在运行的过程中,我的服务器出现故障,消息无法发送到客户端。你能帮帮我吗!

当我在调试中运行它时MpnsService service = MPNS.newService().build(); , 服务器停止并且不再运行。和 WebBrowser 错误消息HTTP Status 500 - Servlet execution throw an exception

代码服务器

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.
4

1 回答 1

0

您应该将 commons-loggin jar 包含到您的应用程序中。你可以在这里找到它commons.apache.org

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

祝你好运

于 2013-07-03T21:51:45.780 回答