Why activitystream can not get any event

I try following code but get empty xml document.
Exactly I found the events list is empty. So I wonder what is wrong with these codes. do I miss anything?

{{velocity}}
#set ($events = $xwiki.activitystream.getEventsForSpace('XWiki', true, 20, 0, $xcontext))
#set ($feed = $xwiki.activitystream.getFeed($events, $xcontext))
$xwiki.feed.getFeedOutput($feed, $xwiki.getXWikiPreference('feed_type', 'atom_1.0'))
{{/velocity}}

If I execute query and get same list as activitystream macro, I stuck at the point of getFeed method by ClassCastException when casting object from ActivityEventImpl to ActivityEvent.

#set ($query = 'select act from ActivityEventImpl as act, ActivityEventImpl as act2')
#set ($query = "$query where act.eventId=act2.eventId and")
#set ($query = "$query (act.hidden <> true or act.hidden is null) and")
#set ($query = "$query (act.space=:space OR act.space LIKE :space_nested)")
#set ($query = "$query group by act.requestId having (act.priority)=max(act2.priority) order by act.url")
#set ($queryObject = $services.query.xwql($query).setLimit(20).setOffset(0))
#set ($queryObject = $queryObject.bindValue('space', 'XWiki'))
#set ($queryObject = $queryObject.bindValue('space_nested', 'XWiki.%'))
#set ($events = $queryObject.execute())
#set ($feed = $xwiki.activitystream.getFeed($events, $xcontext))
$xwiki.feed.getFeedOutput($feed, $xwiki.getXWikiPreference('feed_type', 'atom_1.0'))