Ajuda Flex + SpringIntegration

17 respostas
fabioebner

Pessoal, estou tentando integrar o meu projeto Flex com o Spring pelo SpringIntegration, estou seguindo o exemplo desse site: http://www.springbyexample.org/examples/simple-flex-webapp.html

porem estou com alguns problemas, alguem pode me ajudar?

meu web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4"
	xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
	<display-name>CartorioMaps</display-name>

	<context-param>
		<param-name>flex.class.path</param-name>
		<param-value>/WEB-INF/flex/hotfixes,/WEB-INF/flex/jars</param-value>
	</context-param>

	<!-- Http Flex Session attribute and binding listener support -->
	<listener>
		<listener-class>flex.messaging.HttpFlexSession</listener-class>
	</listener>

	<context-param>
		<param-name>contextConfigLocation</param-name>
		<param-value>/WEB-INF/applicationContext.xml</param-value>
	</context-param>

	<listener>
		<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
	</listener>

	<!-- MessageBroker Servlet -->
	<servlet>
		<servlet-name>MessageBrokerServlet</servlet-name>
		<servlet-class>flex.messaging.MessageBrokerServlet</servlet-class>
		<init-param>
			<param-name>services.configuration.file</param-name>
			<param-value>/WEB-INF/flex/services-config.xml</param-value>
		</init-param>
		<init-param>
			<param-name>flex.write.path</param-name>
			<param-value>/WEB-INF/flex</param-value>
		</init-param>
		<load-on-startup>2</load-on-startup>
	</servlet>

	<servlet-mapping>
		<servlet-name>MessageBrokerServlet</servlet-name>
		<url-pattern>/messagebroker/*</url-pattern>
	</servlet-mapping>

	<servlet>
		<servlet-name>spring-flex</servlet-name>
		<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
		<init-param>
			<param-name>contextConfigLocation</param-name>
			<param-value>/WEB-INF/flex-servlet-context.xml</param-value>
		</init-param>
		<load-on-startup>1</load-on-startup>
	</servlet>


	<servlet-mapping>
		<servlet-name>spring-flex</servlet-name>
		<url-pattern>/spring/*</url-pattern>
	</servlet-mapping>









	
	<welcome-file-list>
		<welcome-file>index.html</welcome-file>
		<welcome-file>index.htm</welcome-file>
		<welcome-file>index.jsp</welcome-file>
		<welcome-file>default.html</welcome-file>
		<welcome-file>default.htm</welcome-file>
		<welcome-file>default.jsp</welcome-file>
	</welcome-file-list>




</web-app>
meu remote-config.xml
<?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="person-amf"/>
    </default-channels>

</service>
meu services-config.xml
<?xml version="1.0" encoding="UTF-8"?>
<services-config>

    <services>
        <service-include file-path="remoting-config.xml" />

        <default-channels>
           <channel ref="person-amf"/>
        </default-channels>
    </services>

    <channels>
        <channel-definition id="person-amf" class="mx.messaging.channels.AMFChannel">
            <endpoint url="http://{server.name}:{server.port}/{context.root}/spring/messagebroker/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>false</includeLevel>
                <includeCategory>false</includeCategory>
            </properties>
            <filters>
                <pattern>Endpoint.*</pattern>
                <pattern>Service.*</pattern>
                <pattern>Configuration</pattern>
            </filters>
        </target>
    </logging>

    <system>
        <redeploy>
            <enabled>false</enabled>
        </redeploy>
    </system>

</services-config>
meu flex-servlet-context.xml
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:p="http://www.springframework.org/schema/p"
       xmlns:context="http://www.springframework.org/schema/context"
       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/context 
                           http://www.springframework.org/schema/context/spring-context.xsd
                           http://www.springframework.org/schema/flex
                           http://www.springframework.org/schema/flex/spring-flex-1.0.xsd">

    <context:component-scan base-package="br.com.dnasolution" />

    <flex:message-broker/>  

   

</beans>
meu applicationContext.xml
<?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:aop="http://www.springframework.org/schema/aop"
	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/aop
		http://www.springframework.org/schema/aop/spring-aop-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		">
   
    
	    

    
	<context:annotation-config/>
    <context:component-scan base-package="br"/>
    
	<aop:aspectj-autoproxy/>

    <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean" >
    <property name="dataSource">
     <ref local="c3p0DataSource"/>
    </property>
 	 <property name="annotatedClasses">
		    <list>
		       <value>br.com.dnasolution.cartoriomaps.entity.TbCartorio</value>
		       <value>br.com.dnasolution.cartoriomaps.entity.TbNatureza</value>
		     </list>
		   </property>

    	<property name="hibernateProperties">
    		<props>
 			    <prop key="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</prop>
    			<prop key="hibernate.connection.autocommit">false</prop>
    		</props>
        </property>

    </bean>

    <bean id="c3p0DataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
    	<property name="driverClass" value="org.postgresql.Driver"/>
    	<property name="jdbcUrl" value="jdbc:postgresql://localhost:5432/db_asdasd"/>
    	<property name="user" value="asdasd"/>
    	<property name="password" value="asdasdas"/>
        <property name="initialPoolSize" value="5"/>
        <property name="minPoolSize" value="5"/>
        <property name="maxPoolSize" value="15"/>
        <property name="checkoutTimeout" value="1000"/>
        <property name="maxStatements" value="50"/>
        <property name="testConnectionOnCheckin" value="true"/>
        <property name="idleConnectionTestPeriod" value="60"/>
    </bean>

    <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
    	<property name="sessionFactory" ref="sessionFactory"/>
    </bean>
</beans>

no meu xmlxml eu fiz o seguinte:

<mx:RemoteObject id="cartoroi" destination="cartorioFACADE" showBusyCursor="true" fault="erro(event)" result="foi(event)"/>
tenho as funcoes
public function iniciar(event:Event):void{
			cartoroi.teste("Binhoca");
			currentState=PRINCIPAL_STATE;
		}
		
		public function erro(event:FaultEvent):void{
			Alert.show(event.fault.message);
		}
		public function foi(event:ResultEvent):void{
			Alert.show(event.result.toString());
		}
tenhoa minha classe q eu quero expor
package br.com.dnasolution.cartoriomaps.facade;

import org.springframework.context.annotation.Scope;
import org.springframework.flex.remoting.RemotingDestination;
import org.springframework.stereotype.Service;

@Service("cartorioFACADE")
@RemotingDestination
public class CartorioFACADE {
	public String teste(String nome){
		return nome + "foiiiiiiiiiiiiiii";
	}
}

e recebo o seguinte erro:

faultCode:InvokeFailed faultString:'[MessagingError message='Destination 'cartorioFACADE' either does not exist or the destination has no channels defined (and the application does not define any default channels.)']' faultDetail:'Couldn't establish a connection to 'cartorioFACADE''

alguem pode me ajudar? pelo q eu entendi ele fala q nao possui nenhum canal de comunicacao entre o flex e o java criado, mas eu declaro ali o meu "person-amf"

e nada

17 Respostas

B

coloca @RemoteInclude em cima do metodo, talvez funcione.

rchgonzaga

Fabio, boa tarde

Baixe este projeto: http://coenraets.org/downloads/spring-flex-testdrive-RC1v2.zip

É do Christophe Coenraets, um cada da Adobe.

Neste projeto ai tem um exemplo de tudo usando Spring, eu usei bastante, vale a pena dar uma olhada.

Abraços
Rafael Gonzaga

fabioebner

[quote]Ae pessoal consegui "uma parte" agora da o seguinte erro:

faultCode:Server.Processing faultString:'No destination with id 'cartorioFACADE' is registered with any service.' faultDetail:'null'

segue os arquivos

web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4" 
         xmlns="http://java.sun.com/xml/ns/j2ee" 
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
         xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee 
                             http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
    <display-name>CartorioMaps</display-name>
    
    <filter>
        <filter-name>encoding-filter</filter-name>
        <filter-class>
            org.springframework.web.filter.CharacterEncodingFilter
        </filter-class>
        <init-param>
            <param-name>encoding</param-name>
            <param-value>UTF-8</param-value>
        </init-param>
    </filter>

    <filter-mapping>
        <filter-name>encoding-filter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

    <servlet>
        <servlet-name>simple-form</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
		<init-param>
			<param-name>contextConfigLocation</param-name>
			<param-value></param-value>
		</init-param>
    </servlet>

    <servlet>
        <servlet-name>spring-flex</servlet-name>  
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>/WEB-INF/applicationContext.xml</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>
        
  <servlet>
		<servlet-name>MessageBrokerServlet</servlet-name>
		<servlet-class>flex.messaging.MessageBrokerServlet</servlet-class>
		<init-param>
			<param-name>services.configuration.file</param-name>
			<param-value>/WEB-INF/flex/services-config.xml</param-value>
		</init-param>
		<init-param>
			<param-name>flex.write.path</param-name>
			<param-value>/WEB-INF/flex</param-value>
		</init-param>
		<load-on-startup>2</load-on-startup>
	</servlet>

	<servlet-mapping>
		<servlet-name>MessageBrokerServlet</servlet-name>
		<url-pattern>/messagebroker/*</url-pattern>
	</servlet-mapping>

    <servlet-mapping>
        <servlet-name>spring-flex</servlet-name>
        <url-pattern>/spring/*</url-pattern>  
    </servlet-mapping>

    
    <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>

</web-app>
remote-config.xml
<?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="person-amf"/>
    </default-channels>
</service>
services-config.xml
<?xml version="1.0" encoding="UTF-8"?>
<services-config>

    <services>
        <service-include file-path="remoting-config.xml" />
        <default-channels>
           <channel ref="person-amf"/>
        </default-channels>
    </services>

    <channels>
        <channel-definition id="person-amf" class="mx.messaging.channels.AMFChannel">
            <endpoint url="http://{server.name}:{server.port}/{context.root}/messagebroker/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>false</includeLevel>
                <includeCategory>false</includeCategory>
            </properties>
            <filters>
                <pattern>Endpoint.*</pattern>
                <pattern>Service.*</pattern>
                <pattern>Configuration</pattern>
            </filters>
        </target>
    </logging>

    <system>
        <redeploy>
            <enabled>false</enabled>
        </redeploy>
    </system>

</services-config>
applicationContext.xml
<?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:aop="http://www.springframework.org/schema/aop"
	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/aop
		http://www.springframework.org/schema/aop/spring-aop-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 />
    
	<context:annotation-config/>
    <context:component-scan base-package="br"/>
    
	<aop:aspectj-autoproxy/>

    <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean" >
    <property name="dataSource">
     <ref local="c3p0DataSource"/>
    </property>
 	 <property name="annotatedClasses">
		    <list>
		       <value>br.com.dnasolution.cartoriomaps.entity.TbCartorio</value>
		       <value>br.com.dnasolution.cartoriomaps.entity.TbNatureza</value>
		     </list>
		   </property>

    	<property name="hibernateProperties">
    		<props>
 			    <prop key="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</prop>
    			<prop key="hibernate.connection.autocommit">false</prop>
    		</props>
        </property>

    </bean>

    <bean id="c3p0DataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
    	<property name="driverClass" value="org.postgresql.Driver"/>
    	<property name="jdbcUrl" value="jdbc:postgresql://localhost:5432/db_asdasd"/>
    	<property name="user" value="3213"/>
    	<property name="password" value="asdd"/>
        <property name="initialPoolSize" value="5"/>
        <property name="minPoolSize" value="5"/>
        <property name="maxPoolSize" value="15"/>
        <property name="checkoutTimeout" value="1000"/>
        <property name="maxStatements" value="50"/>
        <property name="testConnectionOnCheckin" value="true"/>
        <property name="idleConnectionTestPeriod" value="60"/>
    </bean>

    <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
    	<property name="sessionFactory" ref="sessionFactory"/>
    </bean>
</beans>
e a CartorioFACADE
package br.com.dnasolution.cartoriomaps.facade;

import org.springframework.context.annotation.Scope;
import org.springframework.flex.remoting.RemotingDestination;
import org.springframework.stereotype.Service;

@Service
@RemotingDestination
public class CartorioFACADE {
	public String teste(String nome){
		return nome + "foiiiiiiiiiiiiiii";
	}
}

o Erro:

faultCode:Server.Processing faultString:'No destination with id 'cartorioFACADE' is registered with any service.' faultDetail:'null'

ja tentei colocar o
<flex:remoting-destination ref="personDao" />
no meu applicationContext.xml ma nada tbm
rchgonzaga

tenta anotar o service com:

@Service(“xxxxXXXX”)

fabioebner

E mlkao… nada feito… tentei de todas as formas coloquei o service o RemotingDestination etc etc… se eu nao colocar o <destination id="cartorioFACADE"> <properties> <source>br.com.dnasolution.cartoriomaps.facade.CartorioFACADE</source> </properties> </destination>

no remote-config nao vai… se alguem descobrir alguma coisa ae avisa eu :smiley:

valeu

rchgonzaga

fabioebner:
E mlkao… nada feito… tentei de todas as formas coloquei o service o RemotingDestination etc etc… se eu nao colocar o <destination id="cartorioFACADE"> <properties> <source>br.com.dnasolution.cartoriomaps.facade.CartorioFACADE</source> </properties> </destination>

no remote-config nao vai… se alguem descobrir alguma coisa ae avisa eu :smiley:

valeu

Cara, baixa esse arquivo que te mandei … usa ele como exemplo … não vai ter erro!!!

rchgonzaga

segue novamente o link

http://coenraets.org/downloads/spring-flex-testdrive-RC1v2.zip

fabioebner

Amigo ja tentei mas tbm nao deu…

legionarioba
fabioebner:
Pessoal, estou tentando integrar o meu projeto Flex com o Spring pelo SpringIntegration, estou seguindo o exemplo desse site: http://www.springbyexample.org/examples/simple-flex-webapp.html

porem estou com alguns problemas, alguem pode me ajudar?

meu web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4"
	xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
	<display-name>CartorioMaps</display-name>

	<context-param>
		<param-name>flex.class.path</param-name>
		<param-value>/WEB-INF/flex/hotfixes,/WEB-INF/flex/jars</param-value>
	</context-param>

	<!-- Http Flex Session attribute and binding listener support -->
	<listener>
		<listener-class>flex.messaging.HttpFlexSession</listener-class>
	</listener>

	<context-param>
		<param-name>contextConfigLocation</param-name>
		<param-value>/WEB-INF/applicationContext.xml</param-value>
	</context-param>

	<listener>
		<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
	</listener>

	<!-- MessageBroker Servlet -->
	<servlet>
		<servlet-name>MessageBrokerServlet</servlet-name>
		<servlet-class>flex.messaging.MessageBrokerServlet</servlet-class>
		<init-param>
			<param-name>services.configuration.file</param-name>
			<param-value>/WEB-INF/flex/services-config.xml</param-value>
		</init-param>
		<init-param>
			<param-name>flex.write.path</param-name>
			<param-value>/WEB-INF/flex</param-value>
		</init-param>
		<load-on-startup>2</load-on-startup>
	</servlet>

	<servlet-mapping>
		<servlet-name>MessageBrokerServlet</servlet-name>
		<url-pattern>/messagebroker/*</url-pattern>
	</servlet-mapping>

	<servlet>
		<servlet-name>spring-flex</servlet-name>
		<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
		<init-param>
			<param-name>contextConfigLocation</param-name>
			<param-value>/WEB-INF/flex-servlet-context.xml</param-value>
		</init-param>
		<load-on-startup>1</load-on-startup>
	</servlet>


	<servlet-mapping>
		<servlet-name>spring-flex</servlet-name>
		<url-pattern>/spring/*</url-pattern>
	</servlet-mapping>









	
	<welcome-file-list>
		<welcome-file>index.html</welcome-file>
		<welcome-file>index.htm</welcome-file>
		<welcome-file>index.jsp</welcome-file>
		<welcome-file>default.html</welcome-file>
		<welcome-file>default.htm</welcome-file>
		<welcome-file>default.jsp</welcome-file>
	</welcome-file-list>




</web-app>
meu remote-config.xml
<?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="person-amf"/>
    </default-channels>

</service>
meu services-config.xml
<?xml version="1.0" encoding="UTF-8"?>
<services-config>

    <services>
        <service-include file-path="remoting-config.xml" />

        <default-channels>
           <channel ref="person-amf"/>
        </default-channels>
    </services>

    <channels>
        <channel-definition id="person-amf" class="mx.messaging.channels.AMFChannel">
            <endpoint url="http://{server.name}:{server.port}/{context.root}/spring/messagebroker/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>false</includeLevel>
                <includeCategory>false</includeCategory>
            </properties>
            <filters>
                <pattern>Endpoint.*</pattern>
                <pattern>Service.*</pattern>
                <pattern>Configuration</pattern>
            </filters>
        </target>
    </logging>

    <system>
        <redeploy>
            <enabled>false</enabled>
        </redeploy>
    </system>

</services-config>
meu flex-servlet-context.xml
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:p="http://www.springframework.org/schema/p"
       xmlns:context="http://www.springframework.org/schema/context"
       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/context 
                           http://www.springframework.org/schema/context/spring-context.xsd
                           http://www.springframework.org/schema/flex
                           http://www.springframework.org/schema/flex/spring-flex-1.0.xsd">

    <context:component-scan base-package="br.com.dnasolution" />

    <flex:message-broker/>  

   

</beans>
meu applicationContext.xml
<?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:aop="http://www.springframework.org/schema/aop"
	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/aop
		http://www.springframework.org/schema/aop/spring-aop-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		">
   
    
	    

    
	<context:annotation-config/>
    <context:component-scan base-package="br"/>
    
	<aop:aspectj-autoproxy/>

    <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean" >
    <property name="dataSource">
     <ref local="c3p0DataSource"/>
    </property>
 	 <property name="annotatedClasses">
		    <list>
		       <value>br.com.dnasolution.cartoriomaps.entity.TbCartorio</value>
		       <value>br.com.dnasolution.cartoriomaps.entity.TbNatureza</value>
		     </list>
		   </property>

    	<property name="hibernateProperties">
    		<props>
 			    <prop key="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</prop>
    			<prop key="hibernate.connection.autocommit">false</prop>
    		</props>
        </property>

    </bean>

    <bean id="c3p0DataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
    	<property name="driverClass" value="org.postgresql.Driver"/>
    	<property name="jdbcUrl" value="jdbc:postgresql://localhost:5432/db_asdasd"/>
    	<property name="user" value="asdasd"/>
    	<property name="password" value="asdasdas"/>
        <property name="initialPoolSize" value="5"/>
        <property name="minPoolSize" value="5"/>
        <property name="maxPoolSize" value="15"/>
        <property name="checkoutTimeout" value="1000"/>
        <property name="maxStatements" value="50"/>
        <property name="testConnectionOnCheckin" value="true"/>
        <property name="idleConnectionTestPeriod" value="60"/>
    </bean>

    <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
    	<property name="sessionFactory" ref="sessionFactory"/>
    </bean>
</beans>

no meu xmlxml eu fiz o seguinte:

<mx:RemoteObject id="cartoroi" destination="cartorioFACADE" showBusyCursor="true" fault="erro(event)" result="foi(event)"/>
tenho as funcoes
public function iniciar(event:Event):void{
			cartoroi.teste("Binhoca");
			currentState=PRINCIPAL_STATE;
		}
		
		public function erro(event:FaultEvent):void{
			Alert.show(event.fault.message);
		}
		public function foi(event:ResultEvent):void{
			Alert.show(event.result.toString());
		}
tenhoa minha classe q eu quero expor
package br.com.dnasolution.cartoriomaps.facade;

import org.springframework.context.annotation.Scope;
import org.springframework.flex.remoting.RemotingDestination;
import org.springframework.stereotype.Service;

@Service("cartorioFACADE")
@RemotingDestination
public class CartorioFACADE {
	public String teste(String nome){
		return nome + "foiiiiiiiiiiiiiii";
	}
}

e recebo o seguinte erro:

faultCode:InvokeFailed faultString:'[MessagingError message='Destination 'cartorioFACADE' either does not exist or the destination has no channels defined (and the application does not define any default channels.)']' faultDetail:'Couldn't establish a connection to 'cartorioFACADE''

alguem pode me ajudar? pelo q eu entendi ele fala q nao possui nenhum canal de comunicacao entre o flex e o java criado, mas eu declaro ali o meu "person-amf"

e nada

Você está incluindo o services-config.xml e o remote-config.xm como parâmetro de compilação da sua aplicação flex? E o context-root também está sendo setado também? Você precisa disso, pois as variáveis {server.name} e {server.port} são montadas por "si só", mas o {context.root} precisa ser passado para o compilador flex...(via linha de comando, ou usando maven, via o plugin flexmojos)

rchgonzaga

-locale en_US -services “services-config.xml”

legionarioba

-locale en_US -services “services-config.xml” -context-root=SEUCONTEXTO

fabioebner

Aonde eu rodo isso?? estou utilizando o eclipse + flex builder plugin.

valeu

Andre_Brito

fabioebner:
Aonde eu rodo isso?? estou utilizando o eclipse + flex builder plugin.

valeu


Clica com o botão direito no projeto e vai em Flex Compiler. Lá tem uma linha que diz os parâmetros de compilação.

fabioebner

ja esta assim no meu compile arguments

Andre_Brito

Falta o -context-root, que vai indicar o nome do projeto onde ficam os arquivos do BlazeDS e os arquivos Java.
Se você tá fazendo tudo no mesmo projeto, acho que nem precisa colocar, mas tenta aí.

Bruno_Sales

Vamos lá.

Existem alguns conceitos que podem estar sendo ignorados e vou dar uma passada rápida neles.

Context
Em alguns de seus configs você mapeia o contexto “/spring” e em outros “/messagebroker” e seu acessor no flex está “/spring/messagebroker/amf”.

Logo, tente manter a consistência e saiba qual contexto você irá utilizar. Para saber qual está acessível, uma vez que você rodou a sua aplicação, vá na barra de endereços e acessa a página: http://{server.name}:{server.port}/{context.root}/spring/amf" ou http://{server.name}:{server.port}/{context.root}/messagebroker/amf" ou ainda http://{server.name}:{server.port}/{context.root}/spring/messagebroker/amf" e veja qual está acessível. (Se ele retornar uma página em branco sem erro nenhum significa que esta servlet está acessível. Exemplo de link para acessar a aplicação que eu estou desenvolvendo agora: http://localhost:8080/mm/messagebroker/amf.

Enfim, você estando com seu contexto no ar e funcionando, você já pode acessar ele.

Bean
Como você está usando o Spring, logo seus services são beans na aplicação. Isso faz com que você precise dar um lookup no servidor para pegar essas instâncias de beans que já foram criadas quando o seu servidor foi inicializado.

Para acessar esses beans você precisará de uma classe auxiliar que procure por eles. (Factory). Essas factorys são classes java que são facilmente encontradas na internet quando se procura por SpringFactory. Por padrão deve implementar FlexFactory.

Obviamente que integrar flex e spring e explicar como tudo funciona daria no mínimo umas 10 páginas do forum, por isso dei apenas uma passada rápida em tudo. Com isso sugiro que você utilize um projeto simples, que funcione, antes de tentar arrumar o seu problema. Seria melhor para você entender como as coisas funcionam. Nesse seu projeto você utiliza uma servlet org.springframework.web.servlet.DispatcherServlet que eu não tenho conhecimento sobre o que ela faz. Talvez ai esteja o problema.

Edit: Essa explicação foi baseada em integração Flex + Spring + BlazeDS. Não tenho conhecimento sobre SpringIntegration, mas não deve fugir muito.

K

é que ta escrito cartoroi no teu remote, não deveria ser cartorio?

<mx:RemoteObject id=“cartoroi” destination=“cartorioFACADE” showBusyCursor=“true” fault=“erro(event)” result=“foi(event)”/>

Criado 14 de outubro de 2009
Ultima resposta 4 de mai. de 2012
Respostas 17
Participantes 7