Google App Engine频道呈现处理程序抛出异常

时间:2013-03-15 00:21:00

标签: google-app-engine channel-api

我在Mac上本地运行SDK时遇到了这种情况。我正在尝试建立在场处理。我创建了一个简单的servlet,除了日志记录之外什么也不做。但是,我在任何连接和断开连接事件上都遇到以下异常(虽然Channels似乎正在工作)...

Mar 14, 2013 8:04:25 PM com.google.apphosting.utils.jetty.JettyLogger warn
WARNING: /_ah/channel/disconnected/: javax.servlet.UnavailableException: java.lang.InstantiationException
Mar 14, 2013 8:04:38 PM com.google.apphosting.utils.jetty.JettyLogger warn
WARNING: /_ah/channel/connected/: javax.servlet.UnavailableException: java.lang.InstantiationException

我已经在web.xml中注册了用于连接和断开通道的servlet ...

  <servlet>
    <servlet-name>ChannelPresence</servlet-name>
    <servlet-class>com.readyposition.gaetestbed.ChannelPresenceServlet          
    </servlet-class>
  </servlet>

  <servlet-mapping>
    <servlet-name>ChannelPresence</servlet-name>
    <url-pattern>/_ah/channel/connected/</url-pattern>
  </servlet-mapping>

  <servlet-mapping>
    <servlet-name>ChannelPresence</servlet-name>
    <url-pattern>/_ah/channel/disconnected/</url-pattern>
  </servlet-mapping>                                                            

处理程序(servlet)本身非常基础......

package com.readyposition.gaetestbed;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.google.appengine.api.channel.ChannelPresence;
import com.google.appengine.api.channel.ChannelService;
import com.google.appengine.api.channel.ChannelServiceFactory;

@SuppressWarnings("serial")
public abstract class ChannelPresenceServlet extends HttpServlet {
    final static Logger logger =
            LoggerFactory.getLogger(ChannelPresenceServlet.class);

    @Override
    public void doGet(final HttpServletRequest req,
            final HttpServletResponse resp)
                    throws IOException, ServletException
    {
        processCommand(req, resp);
    }

    @Override
    public void doPost(final HttpServletRequest req,
            final HttpServletResponse resp)
                    throws IOException, ServletException
    {
        processCommand(req, resp);
    }

    public void processCommand(final HttpServletRequest req,
            final HttpServletResponse resp)
                    throws IOException, ServletException
    {
        final ChannelService channelService =
                ChannelServiceFactory.getChannelService();
        final ChannelPresence presence = channelService.parsePresence(req);

        logger.info("Channel Presence - clientId={}, isConnected={}",
                presence.clientId(), presence.isConnected());
    }
}

任何帮助都将不胜感激。

1 个答案:

答案 0 :(得分:1)

多么尴尬。剪切和粘贴错误。我的servlet类错误地抽象了。叹。固定的。

我看到其他几个人在不同的情况下抱怨同样的例外,至少有一个与频道存在有关。如果另一个人意识到他们错误地将servlet类留作抽象,那么我认为这将是有益的。

感谢任何试图跟踪我的老鼠洞的人。