Results 1 to 9 of 9

Thread: Flash Remoting / openamf + Spring........ Anyone?

  1. #1
    Join Date
    Nov 2004
    Posts
    1

    Default Flash Remoting / openamf + Spring........ Anyone?

    Hello All,

    Is anyone else our there using Flash Remoting (specifically via openamf) to talk to a spring app? We have a couple of fla's embedded in a couple JSP pages that use Flash Remoting to call into a webapp using Spring and Hibernate. I would love to have someone else to chat with about this share pitfalls and success.

    I believe that we are still getting an exception is Spring but I can't seem to get to the stack trace. Nothing much is being printed out in the debug log except for:

    Code:
    [DEBUG] JkCoyoteHandler - RESET
    [DEBUG] ApplicationDispatcher - servletPath=/uncaughtException.jsp, pathInfo=null, queryString=null, name=null
    [DEBUG] ApplicationDispatcher -  Path Based Forward
    [DEBUG] JspServlet - JspEngine --> /uncaughtException.jsp
    [DEBUG] JspServlet -         ServletPath: /uncaughtException.jsp
    [DEBUG] JspServlet -            PathInfo: null
    [DEBUG] JspServlet -            RealPath: /usr/local/tomcat/jakarta-tomcat-5.0.28/webapps/succeedingweb/uncaughtException.jsp
    [DEBUG] JspServlet -          RequestURI: /succeedingweb/uncaughtException.jsp
    [DEBUG] JspServlet -         QueryString: null
    [DEBUG] JspServlet -      Request Params:
    [DEBUG] ApplicationDispatcher -  Disabling the response for futher output
    [DEBUG] JkCoyoteHandler - COMMIT
    [DEBUG] JkCoyoteHandler - COMMIT sending headers org.apache.coyote.Response@be7667 === MimeHeaders ===
    The problem, the uncaughtException.jsp is not showing up in my browser. I suspect that this is because the initial request came in via openamf and the response is not actually making it back to the brower (or the redirect on the response is being sent to Flash). Either way I can't seem to see what Spring is complaining about, and that makes it hard to debug.

    Any insight would be appreciated.

    Thanks!

    --
    Dan Glauser
    dan@roundboxmedia.com

  2. #2
    Join Date
    Oct 2004
    Posts
    10

    Default Re: Flash Remoting / openamf + Spring........ Anyone?

    Hi Dan,

    We used OpenAMF very successfuly with Spring for a recent project. From your post, it seems like your OpenAMF gateway is not mapped correctly for the request. You should not be hitting ANY jsp pages when making requests to the AMF gateway. As you know, the gateway decodes and encodes HTTP requests according to the AMF binary protocol.

    Make sure your Spring DispatcherServlet(s) are not "catching" the AMF requests by mistake. The AMF gateway should be mapped to it's own exclusive URL.

    Also, you can turn on debugging for the AMF gateway to confirm that it is receiving and processing the incoming requests. You can start with INFO level since DEBUG is very verbose IMHO.

    Let me know if it works,

    Ike[/quote]

  3. #3
    Join Date
    Dec 2004
    Posts
    2

    Default

    I'm trying to use a combination of Spring/Hibernate/OpenAMF and i'm having some issues. If anyone has accomplished something similar I'd love to know how you got it to work.

    I'm using a Spring ProxyFactoryBean to expose Hibernate Interceptors to a class that I inject some Hibernate DAO/Service layer object into. This Proxy configuration works fine in most cases (xwork actions etc) except for the BussinessDelegate class I'm using with OpenAMF.

    The problem is that the dependency injectors don't work, the properties remain null on the BusinessDelegate. Here's my configuration:

    applicationContext.xml:

    <!-- references dao's, transaction management, etc -->
    <bean id="naoService" class="org.springframework.aop.framework.ProxyFact oryBean">
    <property name="interceptorNames">
    <list>
    <value>naoServiceTransactionInterceptor</value>
    <value>naoServiceBusinessObject</value>
    </list>
    </property>
    </bean>

    <bean id="dao-session-proxy-prototype" class="org.springframework.aop.framework.ProxyFact oryBean" lazy-init="true">
    <property name="singleton">
    <value>false</value>
    </property>
    <property name="interceptorNames">
    <list>
    <value>naoHibernateInterceptor</value> </list>
    </property>
    </bean>

    <!-- FLASH/OpenAMF delegates -->
    <bean id="registration-delegate" parent="dao-session-proxy-prototype">
    <property name="target">
    <bean class="com.bac.wimt.ae.delegate.RegistrationDelega te">
    <property name="caisService">
    <ref bean="caisService"/>
    </property>
    <property name="naoService">
    <ref bean="naoService"/>
    </property>
    </bean>
    </property>
    </bean>


    openamf-config.xml:

    <invoker>
    <name>Spring</name>
    <class>org.openamf.invoker.SpringBeanInvoker</class>
    </invoker>

    <service>
    <name>RegistrationDelegate</name>
    <service-location>registration-delegate</service-location>
    <invoker-ref>Spring</invoker-ref>
    <method>
    <name>getTestString</name>
    <parameter>
    <type>*</type>
    </parameter>
    </method>
    </service>


    again, the problem is that the RegistrationDelegate is succesfully created and retrieved, but the naoService member property does not get populated. Any ideas?

  4. #4
    Join Date
    Dec 2004
    Posts
    2

    Default problem solved

    DOH! ...was passing the bean class from my Service object in action script instead of the bean reference name.

  5. #5
    Join Date
    Jun 2005
    Posts
    1

    Default great help!

    just posting a "thank you" reply to ks.

    been researching how to integrate openamf into spring and came across similar problem. ks's snippet of the config files helped me over come this issue. ta

    - y

  6. #6
    Join Date
    Apr 2005
    Location
    Brazil
    Posts
    66

    Default

    could someone tell me please the steps that I'll have to follow to make my openAMF work with my spring/hibernate application???

    P.S my dispatcher is not catching the gateway request, but when I try to access my DAO's by applicationContext, the container say that I'm not on an ApplicationContext. could someone help me?

  7. #7
    Join Date
    Mar 2007
    Posts
    2

    Default

    Maybe a little late reply but hopeful this is helpful to other users viewing this topic.

    To get the OpenAMF springbean invoker working you need to load the spring context from your servlet container by editing your web.xml.

    Code:
    <!--
    <!DOCTYPE web-app PUBLIC
     "-//Sun Microsystems, Inc.//DTD Web Application 2.4//EN"
     "http://java.sun.com/dtd/web-app_2_4.dtd" >
    -->
    <web-app xmlns="http://java.sun.com/xml/ns/j2ee" version="2.4"
    	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    	xsi:schemaLocation="http:/java.sun.com/dtd/web-app_2_4.dtd">
    	
    	<context-param>
    		<param-name>contextConfigLocation</param-name>
    		<param-value>
    			/WEB-INF/config/applicationContext.xml
    		</param-value>
    	</context-param>
    	
    	<servlet>
    		<servlet-name>DefaultGateway</servlet-name>
    		<display-name>DefaultGateway</display-name>
    		<description>DefaultGateway</description>
    		<servlet-class>org.openamf.DefaultGateway</servlet-class>
    		<init-param>
    			<param-name>OPENAMF_CONFIG</param-name>
    			<param-value>/WEB-INF/openamf-config.xml</param-value>
    			<description>Location of the OpenAMF config file.</description>
    		</init-param>
    		<load-on-startup>1</load-on-startup>
    	</servlet>
    
    	<servlet-mapping>
    		<servlet-name>DefaultGateway</servlet-name>
    		<url-pattern>/gateway</url-pattern>
    	</servlet-mapping>
    
    	<listener>
    		<listener-class>
    			org.springframework.web.context.ContextLoaderListener
    		</listener-class>
    	</listener>
    </web-app>
    You can then use the openAMF invoker as described earlier above.

    Another option is to wrap the OpenAMF Gateway Servlet with Springs ServletWrappingController. I prefer this method since this transfers the control back to spring and allows you to be more flexible. This needs some more configuration. You can review it at my website.


    http://famvdploeg.com/guides/index.php/Spring#OpenAMF
    Last edited by Wytze; Mar 26th, 2007 at 08:46 AM.

  8. #8
    Join Date
    Oct 2007
    Posts
    1

    Default How to make service call from fash/openamf session aware

    Hello All,

    I need some help on understanding how SpringBeanInvoker works.
    We have flash based front end application running on Apache webserver .It talks to web based application ,which uses springframework on tomcat 6.

    Currently we are using ompenamf default gateway for flash remoting.

    Following is configuration (web.xml)
    <!-- Open AMF integration for Flash Remoting -->
    <servlet>
    <description>DefaultGateway</description>
    <display-name>DefaultGateway</display-name>
    <servlet-name>DefaultGateway</servlet-name>
    <servlet-class>org.openamf.DefaultGateway</servlet-class>
    <init-param>
    <description>Location of the VP SG AMF mappings config.</description>
    <param-name>OPENAMF_CONFIG</param-name>
    <param-value>/WEB-INF/openamf-config.xml</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
    </servlet>
    .......

    Flash front end makes several calls to various service method.
    Following is configuration (openamf-config.xml)

    <amf-serializer>
    <force-lower-case-keys>true</force-lower-case-keys>
    </amf-serializer>
    <invoker>
    <name>PageableRecordSet</name>
    <class>org.openamf.invoker.PageableResultSetServic eInvoker</class>
    </invoker>
    <invoker>
    <name>PageableRecordSet</name>
    <class>org.openamf.invoker.PageableResultSetServic eInvoker</class>
    </invoker>
    <invoker>
    <name>Java</name>
    <class>org.openamf.invoker.JavaServiceInvoker</class>
    </invoker>
    <invoker>
    <name>SessionControl</name>
    <class>org.openamf.invoker.SessionControlInvoker </class>
    </invoker>
    <!-- very important to have OpenAMF dispatch the Spring beans : Matt 5-mar-2007 -->
    <invoker>
    <name>Spring</name>
    <class>org.openamf.invoker.SpringBeanInvoker</class>
    </invoker>
    <service>
    <name>AuthenticationManagerImpl</name>
    <service-location>com.AuthenticationManagerImpl</service-location>
    <invoker-ref>Spring</invoker-ref>
    <method>
    <name>authenticateUser</name>
    <parameter>
    <type>*</type>
    </parameter>
    </method>
    <method>
    <name>getLoginConfiguration</name>
    </method>
    </service>

    <service>
    <name>Manager2Impl</name>
    <service-location>com. Manager2Impl</service-location>
    <invoker-ref>Spring</invoker-ref>
    <method>
    <name>someAction</name>
    <parameter>
    <type>*</type>
    </parameter>
    </method>
    </service>

    <service>
    <name>Manager1Impl</name>
    <service-location>com. Manager1Impl</service-location>
    <invoker-ref>Spring</invoker-ref>
    <method>
    <name>someMethod</name>
    <parameter>
    <type>*</type>
    </parameter>
    </method>
    </service>
    I would like to know how can I get session id on successful authentication . How do I use the same session id while subsequent call to functions of Manager2Impl & Manager1Impl from flash front end. How do I end a session. Basically I want to create session awareness for further service invocation on successful authentication on first call from client(flash client in our case).

    Thanks!.

  9. #9
    Join Date
    Mar 2007
    Posts
    2

    Default Custom SpringBeanInvoker

    1) I see you are using the DefaultGateway class. Using this class will allow calls on any java class. It is better to use the AdvancedGateway for better security.
    2) Extend OpenAMF's SpringbeanInvoker and overwrite the method

    Code:
    protected Object invokeServiceMethod(Object service, Class serviceClass, String methodName, List parameters) throws SecurityException, NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException
    Do some session stuff with the Session object by calling getHttpServletRequest():
    Code:
    getHttpServletRequest().getSession(); //get the session object through the request. Access other params from the HttpServletRequest object also.
    request.getServiceName(); //get the called service name
    methodName; //name of method called on service object

    Then replace the Spring invoker in the openAMF-config with your own.

    Code:
    	<invoker>
    		<name>Spring</name>
    		<!-- <class>org.openamf.invoker.SpringBeanInvoker</class> -->
    		<class>your.package.name.openamf.invoker.CustomSpringBeanInvoker</class>
    	</invoker>
    Now your own SpringbeanInvoker will be called allowing you to do some session management.

Similar Threads

  1. Spring MVC Web Framework versus Struts
    By biguniverse in forum Web Flow
    Replies: 27
    Last Post: Aug 29th, 2012, 03:57 AM
  2. Spring, Remoting and Spring Rich Client
    By shaby775 in forum Swing
    Replies: 9
    Last Post: Jan 6th, 2011, 07:30 AM
  3. Replies: 0
    Last Post: Aug 23rd, 2005, 02:41 AM
  4. A Spring Class Loader?
    By azzoti in forum Architecture
    Replies: 8
    Last Post: May 7th, 2005, 04:02 AM
  5. Replies: 14
    Last Post: Feb 21st, 2005, 05:41 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •