如何通过apache Royale uisng RemoteObject与Spring + blazeDS服务进行通信

时间:2019-05-10 06:15:54

标签: apache-royale

我在这里有疑问现在,我现在最不用担心UI。 我的最终目标是从Apache Royale远程对象与Spring Services(在remoting-config.xml中定义的BlazeDS目标)进行对话。

我就是这样开始工作的。 1)我在现有的spring服务中创建了方法,该方法已与balzeD集成在一起,如前所述。 2)我使用apache royale编写了一个新项目,它只是想与spring service交流。然后,在相同的tomcat中部署了2个WARS之后,但是由于出现错误,我无法从apache royale与我的服务进行交谈。

我的MXML:

<fx:Declarations>


        <mx:RemoteObject id="loaderService"  endpoint="http://localhost:8081/STARS/messagebroker/amf"  

        destination="reportService" result="handleLoadResult(event)"  fault="handleFault(event)" showBusyCursor="true" />

        <mx:RemoteObject id="remoteObject" destination="helloWorldRemotingService" endpoint="http://localhost:8081/STARS/messagebroker/amf"  

         result="handleLoadResult(event)"  fault="handleFault(event)" showBusyCursor="true"/>



    </fx:Declarations>






   <mx:VBox width="400">
        <mx:HBox>
            <mx:VBox>
                <mx:Label text="Name to send via AMF"/>
                <mx:TextInput id="name_txt"/>
            </mx:VBox>
            <mx:Button label="Send to Name" click="loaderService.welcome()"/>
        </mx:HBox>
        <mx:Label text="{loaderService.welcome.lastResult}" height="15"/>
    </mx:VBox>

我的错误:

Exception: java.lang.NullPointerException 
        at java.util.concurrent.ConcurrentHashMap.get(ConcurrentHashMap.java:936) 
        at flex.messaging.MessageBroker.routeMessageToService(MessageBroker.java:1373) 
        at flex.messaging.endpoints.AbstractEndpoint.serviceMessage(AbstractEndpoint.java:1005) 
        at flex.messaging.endpoints.amf.MessageBrokerFilter.invoke(MessageBrokerFilter.java:103) 
        at flex.messaging.endpoints.amf.LegacyFilter.invoke(LegacyFilter.java:158) 
        at flex.messaging.endpoints.amf.SessionFilter.invoke(SessionFilter.java:44) 
        at flex.messaging.endpoints.amf.BatchProcessFilter.invoke(BatchProcessFilter.java:67) 
        at flex.messaging.endpoints.amf.SerializationFilter.invoke(SerializationFilter.java:166) 
        at flex.messaging.endpoints.BaseHTTPEndpoint.service(BaseHTTPEndpoint.java:291) 
        at flex.messaging.MessageBrokerServlet.service(MessageBrokerServlet.java:353) 
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:742) 
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) 
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) 
        at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) 
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) 
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) 
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330) 
        at org.springframework.security.web.authentication.preauth.AbstractPreAuthenticatedProcessingFilter.doFilter(AbstractPreAuthenticatedProcessingFilter.java:107) 
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) 
        at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:118) 
        at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:84) 
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) 
        at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113) 
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) 
        at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:103) 
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) 
        at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:154) 
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) 
        at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45) 
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) 
        at org.springframework.security.web.authentication.www.BasicAuthenticationFilter.doFilter(BasicAuthenticationFilter.java:150) 
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) 
        at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:199) 
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) 
        at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:110) 
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) 
        at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:50) 
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) 
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) 
        at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87) 
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) 
        at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192) 
        at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160) 
        at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346) 
        at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:262) 
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) 
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) 
        at com.sp.cpem.filter.ExceptionHandlerFilter.doFilterInternal(ExceptionHandlerFilter.java:25) 
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) 
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) 
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) 
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199) 
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) 
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:493) 
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137) 
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81) 
        at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:660) 
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87) 
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343) 
        at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:798) 
        at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) 
        at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:806) 
        at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1498) 
        at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) 
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) 
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) 
        at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) 
        at java.lang.Thread.run(Thread.java:748) 


[ 
  errorReply: Flex Message (flex.messaging.messages.ErrorMessage) 
    clientId = 470F44C5-680A-3F0D-D58C-605A866C0B1F 
    correlationId =BlazeDS]Unhandled error when processing a message: java.lang.NullPointerException 
  incomingMessage: Flex Message (flex.messaging.messages.RemotingMessage) 
    operation = null 
    clientId = 470F44C5-680A-3F0D-D58C-605A866C0B1F 
    destination = null 
    messageId = 
    timestamp = 1557396783081 
    timeToLive = 0 
    body = 
    [ 
      {headers={DSMessagingVersion=1, DSId=nil}, timeToLive=0, clientId=null, destination=, messageId=4CC0F8ED-8234-AEA2-F9B4-5CD3FD2D0DF0, correlationId=, body={}, operat 
ion=5, timestamp=0} 
    ] 
    hdr(DSEndpoint) = my-amf 
    destination = null 
    messageId = 470F4616-520F-9E4E-0484-14188756FFA6 
    timestamp = 1557396783218 
    timeToLive = 0 
    body = null 
    code =  Server.Processing 
    message =  There was an unhandled failure on the server. java.lang.NullPointerException 
    details =  null 
    rootCause =  null 
    body =  null 
    extendedData =  null 


Service: 
public class HelloWorldRemotingService { 

        private static Log logger = LogFactory.getLog(HelloWorldRemotingService.class); 

        public HelloWorldRemotingService() { 
                super(); 
                logger.debug("#################################Helloworld###############################################################"); 
        } 

        public String processHello(final String nameToSayHelloTo) 
           { 
                logger.debug("** Found @@@@@@@@@@@@@@@@@@@records:"); 
              return "Hello, " + nameToSayHelloTo + "!"; 
           } 

} 


Remote-config.xml: 

<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="alertHomeService">                                    
                <properties>                                        
                        <source>com.sp.cpem.service.AlertHomeService</source>
                </properties>
        </destination>
        <destination id="helloWorldRemotingService">                                    
                <properties>                                        
                        <source>com.sp.cpem.service.HelloWorldRemotingService</source>
                </properties>
        </destination>

请向我提供步骤,如果有示例,请告诉我。预先感谢

1 个答案:

答案 0 :(得分:1)

对于我所看到的,您正在Royale中使用MX仿真组件(MXRoyale库)。 这是一个working example project,您可以使用example java project进行测试。

关于代码,RemoteObject声明的终结点以“ amf”结尾,但是对于您显示的代码,它似乎以“ my-amf”结尾。

然后您在Java中调用了welcome()方法,但是您的服务似乎没有该方法。您有processHello

您必须仔细检查代码,以确保所有观点都被正确理解。