Spring BlazeDs 集成问题
2009-09-15 23:26
417 查看
环境:
Spring blazeDS Integration 1.0.0 release
blazeDS 3.2.0.3978
jdk1.6.0_06
flex sdk 3.2.0
flex builder 3
在web.xml中配置DispatcherServlet
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
<display-name>flex_server</display-name>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/context-*.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>flex</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>flex</servlet-name>
<url-pattern>/messagebroker/*</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
</web-app>
在flex-servlet.xml中定义destination
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:flex="http://www.springframework.org/schema/flex"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd http://www.springframework.org/schema/flex http://www.springframework.org/schema/flex/spring-flex-1.0.xsd"> <flex:message-broker />
<!-- premiumService是普通的业务bean -->
<flex:remoting-destination ref="premiumService"/>
</beans>
这样在remoting-config.xml中就不需要定义destination了
<?xml version="1.0" encoding="UTF-8"?>
<service id="remoting-service"
class="flex.messaging.services.RemotingService">
<adapters>
<adapter-definition id="java-object" class="flex.messaging.services.remoting.adapters.JavaAdapter" default="true"/>
</adapters>
<default-channels>
<channel ref="my-amf"/>
</default-channels>
<!--注释掉,否则启动会报错或出现其他问题
<destination id="premiumService">
<properties>
<source>org.hag.flex.service.PremiumService</source>
</properties>
</destination>
-->
</service>
测试
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
creationComplete="premiumService.getPremiumList()">
<mx:Script>
<![CDATA[
<!-- 省略import -->
private function resultHandler(evt:ResultHandler):void
{
Alert.show(evt.result.toString());
}
private function faultHandler(evt:FaultHandler):void
{
Alert.show(evt.fault.toString());
}
]]>
</mx:Script>
<mx:RemoteObject id="premiumService" ref="premiumService"
result="resultHandler(event)" fault="faultHandler(event)"/>
</mx:Application>
结果这时候报错,destination "premiumService" either does not exists....
原因是mxml编译时要根据remoting-config.xml来处理destination的定义,而我们把premiumService定义在了spring bean中,所以它根本就不知道premiumService的存在。取消掉remoting-config.xml的注释,再次对mxml进行编译(如修改后保存),在浏览器中清除缓存、刷新,OK,结果出来了。
注意在tomcat启动时又要把remoting-config.xml定义的destination注释掉,否则会出问题(那是由于blazeds找到两个相同的destination)。或者干脆在其他地方建立一个文件专门用于mxml的编译。
Spring blazeDS Integration 1.0.0 release
blazeDS 3.2.0.3978
jdk1.6.0_06
flex sdk 3.2.0
flex builder 3
在web.xml中配置DispatcherServlet
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
<display-name>flex_server</display-name>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/context-*.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>flex</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>flex</servlet-name>
<url-pattern>/messagebroker/*</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
</web-app>
在flex-servlet.xml中定义destination
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:flex="http://www.springframework.org/schema/flex"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd http://www.springframework.org/schema/flex http://www.springframework.org/schema/flex/spring-flex-1.0.xsd"> <flex:message-broker />
<!-- premiumService是普通的业务bean -->
<flex:remoting-destination ref="premiumService"/>
</beans>
这样在remoting-config.xml中就不需要定义destination了
<?xml version="1.0" encoding="UTF-8"?>
<service id="remoting-service"
class="flex.messaging.services.RemotingService">
<adapters>
<adapter-definition id="java-object" class="flex.messaging.services.remoting.adapters.JavaAdapter" default="true"/>
</adapters>
<default-channels>
<channel ref="my-amf"/>
</default-channels>
<!--注释掉,否则启动会报错或出现其他问题
<destination id="premiumService">
<properties>
<source>org.hag.flex.service.PremiumService</source>
</properties>
</destination>
-->
</service>
测试
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
creationComplete="premiumService.getPremiumList()">
<mx:Script>
<![CDATA[
<!-- 省略import -->
private function resultHandler(evt:ResultHandler):void
{
Alert.show(evt.result.toString());
}
private function faultHandler(evt:FaultHandler):void
{
Alert.show(evt.fault.toString());
}
]]>
</mx:Script>
<mx:RemoteObject id="premiumService" ref="premiumService"
result="resultHandler(event)" fault="faultHandler(event)"/>
</mx:Application>
结果这时候报错,destination "premiumService" either does not exists....
原因是mxml编译时要根据remoting-config.xml来处理destination的定义,而我们把premiumService定义在了spring bean中,所以它根本就不知道premiumService的存在。取消掉remoting-config.xml的注释,再次对mxml进行编译(如修改后保存),在浏览器中清除缓存、刷新,OK,结果出来了。
注意在tomcat启动时又要把remoting-config.xml定义的destination注释掉,否则会出问题(那是由于blazeds找到两个相同的destination)。或者干脆在其他地方建立一个文件专门用于mxml的编译。
相关文章推荐
- Spring BlazeDs 集成问题
- Spring BlazeDs 集成问题
- Spring项目集成Spring-Session以及可能遇到的问题
- blazeDS集成spring的remote访问
- Spring +redis 集成 16进制问题 \xE7\x9C\x81t\x00\x0323e
- Spring与Hibernate集成中的session问题
- eclipse搭建maven web 工程,和集成springmvc+mybatis的一些问题
- Spring与Groovy动态语言集成包冲突问题
- [札记]SSM开发框架集成问题,Spring4.3.x+Mybatis3.4.x+SpringMVC集成时遇到的jason转换问题
- Hibernate集成Spring出现写操作在只读事物中的问题
- spring-oauth集成cas单点登录,登陆完成进入授权页面后,按回退按钮进入404页面的问题
- 使用Spring集成HIbernate出现问题
- spring-oauth集成cas单点登录,登陆完成进入授权页面后,按回退按钮进入404页面的问题
- Struts2.x与Spring集成校验应注意的问题
- 解决:spring集成quartz,出现2次重复调用的问题
- idea集成spring+spring MVC+mybatis问题
- Spring boot集成Swagger2,解决页面不显示的问题
- Spring与SpringMVC集成出现的问题
- spring 集成ActiveMQ发送消息Hang住的问题
- Spring与iBATIS集成时,一对多表会出错的问题的解释