PDA

View Full Version : Couldn't establish a connection to exposed service



armandlek16
Sep 16th, 2009, 05:19 PM
I am struggling with spring blazeds integration. Can anyone help?
I have exposed a service called 'licenceService' through Spring but I am unable to connect to that service from my flex client. It gives me the following error: Couldn't establish a connection to 'licenceService'


web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app 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"
version="2.4">

<display-name>Spike</display-name>

<!-- ================================================== ======== -->
<!-- Context Parameters -->
<!-- ================================================== ======== -->

<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/web-application-context.xml
</param-value>
</context-param>
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>/WEB-INF/log4j.properties</param-value>
</context-param>
<context-param>
<param-name>log4jRefreshInterval</param-name>
<param-value>1000</param-value>
</context-param>

<!-- ================================================== ======== -->
<!-- Listeners -->
<!-- ================================================== ======== -->

<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListe ner</listener-class>
</listener>
<listener>
<listener-class>flex.messaging.HttpFlexSession</listener-class>
</listener>


<!-- ================================================== ======== -->
<!-- Servlets -->
<!-- ================================================== ======== -->

<servlet>
<servlet-name>Spike</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>

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

<!-- ================================================== ======== -->
<!-- Welcome Files -->
<!-- ================================================== ======== -->

<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
</welcome-file-list>
</web-app>


web-application-context.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"
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">

<import resource="hibernate-application-context.xml"/>
</beans>

Spike-servlet.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:flex="http://www.springframework.org/schema/flex"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
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/flex
http://www.springframework.org/schema/flex/spring-flex-1.0.xsd">

<flex:message-broker/>

<bean id="licenceService" class="com.destiny.service.implementations.LicenceService Impl">
<flex:remoting-destination/>
<property name="licenceDao" ref="licenceDao"/>
</bean>
</beans>

When deploying my application i can see the following logs:

2009-09-16 22:43:00,218 INFO [org.springframework.flex.core.MessageBrokerFactory Bean] - BlazeDS - Community Edition: 3.2.0.3978
[BlazeDS]Endpoint my-amf created with security: None
at URL: http://{server.name}:{server.port}/{context.root}/messagebroker/amf
[BlazeDS]Endpoint my-polling-amf created with security: None
at URL: http://{server.name}:{server.port}/{context.root}/messagebroker/amfpolling
[BlazeDS]Endpoint my-secure-amf created with security: None
at URL: https://{server.name}:{server.port}/{context.root}/messagebroker/amfsecure
2009-09-16 22:43:00,343 INFO [org.springframework.flex.core.MessageBrokerFactory Bean] - MessageBroker with id '_messageBroker' is starting.
2009-09-16 22:43:00,656 INFO [org.springframework.flex.core.MessageBrokerFactory Bean] - MessageBroker with id '_messageBroker' is ready (startup time: '313' ms)
2009-09-16 22:43:00,671 INFO [org.springframework.flex.remoting.RemotingDestinat ionExporter] - Created remoting destination with id 'licenceService'
2009-09-16 22:43:00,671 INFO [org.springframework.flex.remoting.RemotingDestinat ionExporter] - Remoting destination 'licenceService' has been started started successfully.
2009-09-16 22:43:00,687 INFO [org.springframework.web.servlet.DispatcherServlet] - FrameworkServlet 'Spike': initialization completed in 1266 ms

To me it looks like the service is exposed but nothing is happening. Please help.

jeremyg484
Sep 25th, 2009, 12:37 PM
This isn't really enough information to go on...would need to see how you are invoking the service from the client as well as your service-config.xml setup. I suspect you aren't getting the ChannelSet wired into the RemoteObject correctly on the Flex side.

p.s. Please use the code tags when posting code samples!