Announcement Announcement Module
Collapse
No announcement yet.
flex:message-broker does not work on dm server Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • flex:message-broker does not work on dm server

    Hello,

    doing some tests with blazeds integration on dm server. Created the web bundle with flex integration in it.

    This works ok:

    META-INF/spring/module-context.xml
    Code:
    <?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:flex="http://www.springframework.org/schema/flex"
    	xsi:schemaLocation="
    		http://www.springframework.org/schema/beans 
    		http://www.springframework.org/schema/beans/spring-beans.xsd
    		http://www.springframework.org/schema/flex
    		http://www.springframework.org/schema/flex/spring-flex-1.0.xsd
    	"
    >
    
    	<bean id="messageBroker" class="org.springframework.flex.core.MessageBrokerFactoryBean" />
    	
    	<bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
    		<property name="mappings">
    			<value>
    				/*=messageBroker
    			</value>
    		</property>
    	</bean>
    
    	<bean class="org.springframework.flex.servlet.MessageBrokerHandlerAdapter"/>	
    
    	<bean id="ping" class="t3.service.blazeds.util.Ping">
    		<flex:remoting-destination message-broker="messageBroker"/>
    	</bean>
    
    </beans>
    META-INF/MANIFEST.MF
    Code:
    Manifest-Version: 1.0
    Bundle-ManifestVersion: 2
    Bundle-SymbolicName: t3.service.blazeds
    Bundle-Version: 1.0.0
    Bundle-Name: Blazeds Bundle
    Module-Type: Web
    Web-ContextPath: /t3/blazeds
    Web-DispatcherServletUrlPatterns: /*
    Import-Bundle: org.springframework.flex;version="[1.0.0.RELEASE,1.0.0.RELEASE]",
     com.springsource.flex.messaging;version="[3.2.0.3978,3.2.0.3978]",
     org.springframework.beans;version="[2.5.6.A,2.5.6.A]",
     org.springframework.web.servlet;version="[2.5.6.A,2.5.6.A]",
     org.springframework.aop;version="[2.5.6.A,2.5.6.A]",
     com.springsource.flex.messaging.services.remoting;version="[3.2.0.3978,3.2.0.3978]"
    Import-Package: t3.service
    MODULE-INF/WEB-INF/flex/services-config.xml
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <services-config>
    
        <channels>
        
            <channel-definition id="my-amf" class="mx.messaging.channels.AMFChannel">
                <endpoint url="http://{server.name}:{server.port}/{context.root}/amf" class="flex.messaging.endpoints.AMFEndpoint"/>
            </channel-definition>
    
        </channels>
        
    	<services>
    		<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>		
    		</service>
    		
    		<default-channels>
               <channel ref="my-amf"/>
            </default-channels>
    	</services>       
    
        <logging>
            <target class="flex.messaging.log.ConsoleTarget" level="Error">
                <properties>
                    <prefix>[BlazeDS] </prefix>
                    <includeDate>false</includeDate>
                    <includeTime>false</includeTime>
                    <includeLevel>true</includeLevel>
                    <includeCategory>false</includeCategory>
                </properties>
                <filters>
                    <pattern>Endpoint.*</pattern>
                    <pattern>Service.*</pattern>
                    <pattern>Configuration</pattern>
                </filters>
            </target>
        </logging>
    </services-config>
    but if I use the <flex:message-broker/> instead like this:

    META-INF/spring/module-context.xml
    Code:
    <?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:flex="http://www.springframework.org/schema/flex"
    	xsi:schemaLocation="
    		http://www.springframework.org/schema/beans 
    		http://www.springframework.org/schema/beans/spring-beans.xsd
    		http://www.springframework.org/schema/flex
    		http://www.springframework.org/schema/flex/spring-flex-1.0.xsd
    	"
    >
    	<flex:message-broker/>
    
    	<bean id="ping" class="t3.service.blazeds.util.Ping">
    		<flex:remoting-destination/>
    	</bean>
    
    </beans>
    MODULE-INF/WEB-INF/flex/services-config.xml
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <services-config>
    
        <channels>
        
            <channel-definition id="my-amf" class="mx.messaging.channels.AMFChannel">
                <endpoint url="http://{server.name}:{server.port}/{context.root}/amf" class="flex.messaging.endpoints.AMFEndpoint"/>
            </channel-definition>
        </channels>
        
        <logging>
            <target class="flex.messaging.log.ConsoleTarget" level="Error">
                <properties>
                    <prefix>[BlazeDS] </prefix>
                    <includeDate>false</includeDate>
                    <includeTime>false</includeTime>
                    <includeLevel>true</includeLevel>
                    <includeCategory>false</includeCategory>
                </properties>
                <filters>
                    <pattern>Endpoint.*</pattern>
                    <pattern>Service.*</pattern>
                    <pattern>Configuration</pattern>
                </filters>
            </target>
        </logging>
    </services-config>
    I'm getting the following error:
    org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name '_messageBrokerDefaultHandlerMapping': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name '_messageBroker': Invocation of init method failed; nested exception is java.lang.RuntimeException: MessageBroker already defined from MessageBrokerServlet with init parameter messageBrokerId = '_messageBroker'
    Springsource dm Server 1.0.2 containing spring framework 2.5.6.A

  • #2
    Ok, quick question before I try and test your exact scenario myself...do you get this error even after restarting dm Server completely, and not just when restarting only that module (with the server already running)?

    The reason I ask is because I think I encountered a problem at one point where for some reason in dm Server I wasn't getting the proper destroy callback for the MessageBrokerFactoryBean, thus when the module restarted I would get that error about the MessageBroker already being defined.

    Comment


    • #3
      Seems, you are correct with your suspicion.

      It works this way. If I restart the dm server with above mentioned application, I get the following error

      org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name '_messageBrokerDefaultHandlerMapping': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name '_messageBroker': Invocation of init method failed; nested exception is org.springframework.aop.framework.AopConfigExcepti on: Could not generate CGLIB subclass of class [class flex.messaging.endpoints.AMFEndpoint]: Common causes of this problem include using a final class or a non-visible class; nested exception is net.sf.cglib.core.CodeGenerationException: java.lang.reflect.InvocationTargetException-->null
      after that all attempts to republish the application will lead to the above mentioned error :

      org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name '_messageBrokerDefaultHandlerMapping': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name '_messageBroker': Invocation of init method failed; nested exception is java.lang.RuntimeException: MessageBroker already defined from MessageBrokerServlet with init parameter messageBrokerId = '_messageBroker'
      but if I throw out <flex:message-broker/> and use the direct beans definition instead - it works.

      The problem is that I can not find any doc how to use advanced features such as spring security without the <flex:message-broker/> call.

      So, we actually found out that there are 2 problems:
      1. <flex:message-broker/> does not work with dm server
      2. wrong undeployment of applications after the problem #1

      Comment


      • #4
        Originally posted by xaos View Post
        <flex:message-broker/> does not work with dm server
        Actually, it does work, you've just got to get the manifest right. We do most of our development and testing of the project on dm Server. If you've got the full project distribution, take a look in the source at the manifest for the org.springframework.flex.integration project (which is a dm Server web module we use to run Flex integration tests using the Fluint testing library). You probably need to include cglib as a dependency. I would point you directly to it in Fisheye, but that seems to be down at the moment.

        Originally posted by xaos View Post
        wrong undeployment of applications after the problem #1
        Once you get the module started successfully, this problem seems to go away. We could probably handle this a little better by doing some additional resource cleanup in the case of a failed startup attempt. Happens whether in dm Server or not. I'll open a Jira for that.

        Comment


        • #5
          You probably need to include cglib as a dependenc
          yep, I missed cglib and aopalliance dependencies. Here is the list of dependencies that work for me
          org.springframework.flex
          com.springsource.flex.messaging
          org.springframework.beans
          org.springframework.web.servlet
          org.springframework.aop
          com.springsource.flex.messaging.services.remoting
          com.springsource.net.sf.cglib
          com.springsource.org.aopalliance
          I think you should put this information into documentation - this could have saved me weeks...

          I'll open a Jira for that
          good. This little issue hides the real problem from the developer and make him waste time and nerves looking in wrong direction, so it isn't so harmless as it looks.

          And thanks for help!

          Comment


          • #6
            Here is the Jira, for anyone interested in tracking it:
            http://jira.springframework.org/browse/FLEX-61

            Comment


            • #7
              Thanks

              Just want to chime in here and say thanks for the above post. The list of maven dependencies was a big help to me as I hadn't found that consolidated elsewhere. I'm up and running now.

              Comment

              Working...
              X