0
我試圖從GraniteDS實現Gravity。我在GraniteDS網站的例子中做了所有的事情,但是當我試圖從servlet上下文中獲取重力時,GravityManager.getGravity返回null。這裏是代碼:GravityManager.getGravity()返回null
Gravity gravity = GravityManager.getGravity(contextManager.getServletContext());
什麼可以是這個錯誤的原因?
UPD:
從web.xml中:
<servlet>
<servlet-name>GravityServlet</servlet-name>
<servlet-class>org.granite.gravity.tomcat.GravityTomcatServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>GravityServlet</servlet-name>
<url-pattern>/gravityamf/*</url-pattern>
</servlet-mapping>
從服務-config.xml文件:
<service id="messaging-service" class="flex.messaging.services.MessagingService"
messageTypes="flex.messaging.messages.AsyncMessage">
<adapters>
<adapter-definition id="default"
class="org.granite.gravity.adapters.SimpleServiceAdapter" default="true" />
</adapters>
<destination id="Gravity">
<channels>
<channel ref="my-gravityamf" />
</channels>
</destination>
</service>
<channels>
<channel-definition id="my-graniteamf"
class="mx.messaging.channels.AMFChannel">
<endpoint
uri="http://{server.name}:{server.port}/{context.root}/graniteamf/amf"
class="flex.messaging.endpoints.AMFEndpoint" />
</channel-definition>
<channel-definition id="my-gravityamf"
class="org.granite.gravity.channels.GravityChannel">
<endpoint
uri="http://{server.name}:{server.port}/{context.root}/gravityamf/amf"
class="flex.messaging.endpoints.AMFEndpoint" />
</channel-definition>
</channels>
您是否檢查過以確保'contextManager.getServletContext();'返回有效值? – 2012-02-27 19:37:25
是的,我有。它使用ServletContextAware接口沒有任何問題。 – Mikhail 2012-02-27 20:39:15
你是否引用這個鏈接http://www.graniteds.org/confluence/display/DOC/4.+Data+Push+(Gravity)? – Triode 2012-02-28 06:04:40