Results 1 to 5 of 5

Thread: Noob needs some help

  1. #1
    Join Date
    May 2010
    Posts
    9

    Default Noob needs some help

    Hi Spring Forum,

    some things first: I used the search but didn't really get good answers to my problem. Second I'm kinda new to spring but I just want to try the blazeds integration since my company is using spring all the way

    So here's my situation: I use Jetty 7.1 with spring and spring-flex integration. So I created my application context that looks like this:

    Code:
    <bean id="remotingBean" class="com.eyeplorer.flex.remoting.SimpleRemoteObject"/>
    
    <flex:message-broker services-config-path="classpath*:com/eyeplorer/flex/remoting/services-config.xml">
    	<flex:mapping pattern="/messagebroker/*"/>
    </flex:message-broker>
    
    <flex:remoting-destination ref="remotingBean" destination-id="simpleRemoteService" channels="my-amf-channel" include-methods="echo"/>
    and I have the services-config.xml:
    Code:
    <services>
    		<default-channels>
    			<channel ref="my-amf-channel" />
    		</default-channels>
    	</services>
    
    	<channels>
    		<channel-definition id="my-amf-channel"
    			class="mx.messaging.channels.AMFChannel">
    			<!--
    				TODO: change that later?
    				http://{server.name}:{server.port}/{context.root}
    			-->
    			<endpoint url="http://localhost:8080/messagebroker/amf"
    				class="flex.messaging.endpoints.AMFEndpoint" />
    			<properties>
    				<polling-enabled>false</polling-enabled>
    			</properties>
    		</channel-definition>
    	</channels>
    
    	<logging>
    		<target class="flex.messaging.log.ConsoleTarget" level="Debug">
    			<properties>
    				<prefix>[BlazeDS]</prefix>
    				<includeDate>false</includeDate>
    				<includeTime>false</includeTime>
    				<includeLevel>true</includeLevel>
    				<includeCategory>true</includeCategory>
    			</properties>
    			<filters>
    				<pattern>Endpoint.*</pattern>
    				<pattern>Service.*</pattern>
    				<pattern>Message.*</pattern>
    				<pattern>DataService.*</pattern>
    				<pattern>Configuration</pattern>
    			</filters>
    		</target>
    	</logging>
    and I created a simple Java Class called SimpleRemoteObject:
    Code:
    public class SimpleRemoteObject {
    	
    	public SimpleRemoteObject() {
    		System.err.println("[SimpleRemoteObject]");
    	}
    	
    	public String echo(String someText) {
    		System.err.println("Remotely called");
    		return someText + "-" + someText;
    	}
    }
    and here's my web.xml:
    Code:
    <listener>
    		<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    	</listener>
    
    	<context-param>
    		<param-name>contextConfigLocation</param-name>
    		<param-value>classpath:com/eyeplorer/applicationContext.xml</param-value>
    	</context-param>
    When I start jetty this is the log i get:
    Code:
    >>> STARTING EMBEDDED JETTY SERVER, PRESS ANY KEY TO STOP
    INFO  - log                        - jetty-7.1.0.v20100505
    INFO  - log                        - NO JSP Support for /, did not find org.apache.jasper.servlet.JspServlet
    WARN  - log                        - java.lang.ClassNotFoundException: org.eclipse.jetty.jsp.JettyLog
    INFO  - /                          - Initializing Spring root WebApplicationContext
    INFO  - ContextLoader              - Root WebApplicationContext: initialization started
    INFO  - XmlWebApplicationContext   - Refreshing Root WebApplicationContext: startup date [Thu May 20 13:20:33 CEST 2010]; root of context hierarchy
    INFO  - XmlBeanDefinitionReader    - Loading XML bean definitions from class path resource [com/eyeplorer/applicationContext.xml]
    INFO  - DefaultListableBeanFactory - Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@178aab40: defining beans [remotingBean,_messageBrokerHandlerAdapter,_messageBrokerDefaultHandlerMapping,_jsonConfigMapEditorConfigurer,_messageBrokerMessagingProcessor,_flexRemotingAnnotationPostProcessor,_messageBrokerRemotingProcessor,org.springframework.flex.core.ExceptionTranslationAdvice#0,org.springframework.flex.core.EndpointServiceMessagePointcutAdvisor#0,org.springframework.flex.core.MessageInterceptionAdvice#0,org.springframework.flex.core.EndpointServiceMessagePointcutAdvisor#1,_messageBrokerEndpointProcessor,_messageBroker,org.springframework.flex.remoting.RemotingDestinationExporter#0]; root of factory hierarchy
    [SimpleRemoteObject]
    INFO  - FlexConfigurationManager   - Loading Flex services configuration from: URL [file:/Users/jeckyll/Documents/eyeplorer/playground/blazedsjettytest/target/classes/com/eyeplorer/flex/remoting/services-config.xml]
    INFO  - MessageBrokerFactoryBean   - BlazeDS - Community Edition: 3.2.0.3978
    [BlazeDS][WARN] [Configuration] No login command was found for 'jetty/7.1.0.v20100505'. Please ensure that the login-command tag has the correct server attribute value, or use 'all' to use the login command regardless of the server.
    [BlazeDS][INFO] [Configuration] Endpoint my-amf-channel created with security: None
    at URL: http://localhost:8080/messagebroker/amf
    INFO  - MessageBrokerFactoryBean   - MessageBroker with id '_messageBroker' is starting.
    [BlazeDS][DEBUG] [Configuration] MessageBroker id: _messageBroker classLoader is: the context class loader (classLoader hashCode: 1000613778 (parent system)
    INFO  - MessageBrokerFactoryBean   - MessageBroker with id '_messageBroker' is ready (startup time: '183' ms)
    INFO  - SimpleUrlHandlerMapping    - Mapped URL path [/messagebroker/*] onto handler [flex.messaging.MessageBroker@49f10a67]
    INFO  - emotingDestinationExporter - Created remoting destination with id 'simpleRemoteService'
    INFO  - emotingDestinationExporter - Remoting destination 'simpleRemoteService' has been started started successfully.
    INFO  - ContextLoader              - Root WebApplicationContext: initialization completed in 1087 ms
    INFO  - log                        - Started SocketConnector@0.0.0.0:8080
    In Flex I build a simple function that trys to connect to my locally running jetty based blazedsspring-magic (localhost:8080).
    I do it like this:
    Code:
    protected function applicationCompleteHandler(event:FlexEvent):void {
    				var remoteObject:RemoteObject = new RemoteObject("simpleRemoteService");
    				remoteObject.addEventListener(ResultEvent.RESULT, resultHandler);
    				remoteObject.addEventListener(FaultEvent.FAULT, faultHandler);
    				var anObject:AsyncToken = remoteObject.echo("foo");
    			}
    			
    			private function resultHandler(event:ResultEvent):void {
    				trace(event.result);
    			}
    			
    			private function faultHandler(event:FaultEvent):void {
    				trace(event.fault.message);
    			}
    But when I debug my flex app all I get is the usual
    Code:
    Channel.Connect.Failed error NetConnection.Call.Failed: HTTP: Failed: url: 'http://localhost:8080/messagebroker/amf
    I used the -services compiler option in FlashBuilder to make the mxml compiler aware of the services.
    I don't see why it's not working. In the jetty log I see that BlazeDS is starting and also the bean that should react to the remote calls is created and thelike. I specifically hardcoded the path in the channels-definition to "http://localhost:8080/messagebroker/amf" since I just wanna try it and use no context.

    Am I overseeing something or did I not read the documentations carefully enough? (Although I have to say that all are a little bit confusing)

    Any Help of you experts would be very much appreciated!

    Cheers,
    norman
    Last edited by jeckyll; May 20th, 2010 at 11:11 AM. Reason: little typo

  2. #2
    Join Date
    May 2010
    Posts
    9

    Default

    Ok, I used Charles now to track down some more information while the connection fails. The connection is refused. For me it means, that jetty is refusing the connection from the flex app.

    Any hints?

  3. #3
    Join Date
    Apr 2005
    Location
    San Francisco, CA
    Posts
    1,224

    Default

    1.) Where's your DispatcherServlet? (Should be in web.xml.) The requests won't reach the Spring-managed MessageBroker without it.

    2.) Your url for the endpoint is not taking into account the context path for the application. Unless you are deploying it as the root web application for the server, it would have to be something like:

    Code:
    url="http://localhost:8080/my_application_path/messagebroker/amf"
    Jeremy Grelle

    Staff Engineer, Web Products Team
    SpringSource

  4. #4
    Join Date
    May 2010
    Posts
    9

    Default

    Since I'm deploying as root web application I suppose I don't need a context.

    Ok, where's the dispatcher Servlet in my web.xml? When I followed the instructions I inserted the DispatcherServlet into the web.xml. but as soon as I started Jetty I got several exceptions like: _messageBroker already defined and thelike. So it seems that it should be enough to insert the flex:message-broker tag into the application context. And if I look into my jetty log, it says:
    Code:
    [BlazeDS][WARN] [Configuration] No login command was found for 'jetty/7.1.0.v20100505'. Please ensure that the login-command tag has the correct server attribute value, or use 'all' to use the login command regardless of the server.
    [BlazeDS][INFO] [Configuration] Endpoint my-amf-channel created with security: None
    at URL: http://localhost:8080/messagebroker/amf
    INFO  - MessageBrokerFactoryBean   - MessageBroker with id '_messageBroker' is starting.
    [BlazeDS][DEBUG] [Configuration] MessageBroker id: _messageBroker classLoader is: the context class loader (classLoader hashCode: 1742296210 (parent system)
    INFO  - MessageBrokerFactoryBean   - MessageBroker with id '_messageBroker' is ready (startup time: '192' ms)
    INFO  - SimpleUrlHandlerMapping    - Default mapping to handler [flex.messaging.MessageBroker@44323274]
    INFO  - emotingDestinationExporter - Created remoting destination with id 'simpleRemoteService'
    INFO  - emotingDestinationExporter - Remoting destination 'simpleRemoteService' has been started started successfully.
    Im running out of ideas so far

  5. #5
    Join Date
    May 2010
    Posts
    9

    Default Solved the problem

    Hey Jeremy, thanks for the tip. The problem was, that I applied my applicationContext to the DispatcherServlet as init-param. So it tried to wire up everything two times. For now i'm giving it an empty context and it's working now!
    I will consult our spring expert tomorrow. Thanks for the help!

Tags for this Thread

Posting Permissions

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