Announcement Announcement Module
Collapse
No announcement yet.
Tomcat starts up without error, but getting 404 error when doing remote calls Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Tomcat starts up without error, but getting 404 error when doing remote calls

    Hi all,

    I am using STS 2.5.2. + Roo 1.1.1 + maven 2.2.1 + spring-flex-1.5.0.M2. I have started a Roo Project, configured persistence using the respective Roo command, then created a few entities. When I was done, I added the "Flex Project Type" to the project and configured the web.xml and the web-application-config.xml files as shown below.

    If I try to run the project, the Tomcat server is starting up without any error messages, but I can not access the RemotingService with my test swf file. Even if I try to hit the URL using Firefox I am getting a 404 error message, so I guess something is not quite right...

    Here is my web.xml
    Code:
    <?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">
    	
    	<!-- The front controller of this Spring Web application, responsible for handling all application requests -->
    	<servlet>
    	    <servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
    	    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    	    <init-param>
    	        <param-name>contextConfigLocation</param-name>
    	        <param-value>/WEB-INF/config/web-application-context.xml</param-value>
    	    </init-param>
    	    <load-on-startup>1</load-on-startup>
    	</servlet>
    	
    	<!-- Map all /messagbroker requests to the DispatcherServlet for handling -->
    	<servlet-mapping>
    	    <servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
    	    <url-pattern>/messagebroker/*</url-pattern>
    	</servlet-mapping>
    		
    </web-app>
    The corresponding web-application-context.xml file:
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    	xmlns:aop="http://www.springframework.org/schema/aop"
    	xmlns:context="http://www.springframework.org/schema/context"
    	xmlns:jee="http://www.springframework.org/schema/jee"
    	xmlns:tx="http://www.springframework.org/schema/tx"
    	xmlns:flex="http://www.springframework.org/schema/flex"
    	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    	xsi:schemaLocation="[...]">
    		
    	<context:property-placeholder location="classpath*:META-INF/spring/*.properties"/>
            <context:spring-configured/>
        <context:component-scan base-package="org.translation">
            <context:exclude-filter expression=".*_Roo_.*" type="regex"/>
            <context:exclude-filter expression="org.springframework.stereotype.Controller" type="annotation"/>
        </context:component-scan>
        <bean class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close" id="dataSource">
            <property name="driverClassName" value="${database.driverClassName}"/>
            <property name="url" value="${database.url}"/>
            <property name="username" value="${database.username}"/>
            <property name="password" value="${database.password}"/>
            <property name="validationQuery" value="SELECT 1 FROM DUAL"/>
            <property name="testOnBorrow" value="true"/>
        </bean>
        <bean class="org.springframework.orm.jpa.JpaTransactionManager" id="transactionManager">
            <property name="entityManagerFactory" ref="entityManagerFactory"/>
        </bean>
        <tx:annotation-driven mode="aspectj" transaction-manager="transactionManager"/>
        <bean class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean" id="entityManagerFactory">
            <property name="dataSource" ref="dataSource"/>
        </bean>
        
        <flex:message-broker/>
        
    </beans>
    Console output:
    Code:
    14.02.2011 20:19:19 org.apache.catalina.core.AprLifecycleListener init
    INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Programme\Java\jdk1.6.0_23\bin;.;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Programme\ATI Technologies\ATI.ACE\Core-Static;C:\Programme\TortoiseSVN\bin;C:\Programme\Java\jdk1.6.0_23\bin;C:\springsource\maven-2.2.1.RELEASE\bin;C:\Programme\QuickTime\QTSystem\
    14.02.2011 20:19:19 org.apache.tomcat.util.digester.SetPropertiesRule begin
    WARNUNG: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.j2ee.server:Translation' did not find a matching property.
    14.02.2011 20:19:19 org.apache.coyote.http11.Http11Protocol init
    INFO: Initializing Coyote HTTP/1.1 on http-8080
    14.02.2011 20:19:19 org.apache.catalina.startup.Catalina load
    INFO: Initialization processed in 1051 ms
    14.02.2011 20:19:19 org.apache.catalina.core.StandardService start
    INFO: Starting service Catalina
    14.02.2011 20:19:19 org.apache.catalina.core.StandardEngine start
    INFO: Starting Servlet Engine: Apache Tomcat/6.0.32
    14.02.2011 20:19:20 org.apache.catalina.core.ApplicationContext log
    INFO: Initializing Spring FrameworkServlet 'Spring MVC Dispatcher Servlet'
    [BlazeDS]Endpoint 'my-amf' created with security: None
    at URL: http://localhost:8080/translation/messagebroker/amf
    [BlazeDS]Endpoint 'my-private-amf' created with security: None
    at URL: http://localhost:8080/translation/messagebroker/amfprivate
    [BlazeDS]Endpoint 'my-secure-amf' created with security: None
    at URL: https://localhost:8080/translation/messagebroker/amfsecure
    [BlazeDS]MessageBroker id: _messageBroker classLoader is: the MessageBroker's class loader and the context class loader (classLoader hashCode: 16022517 (parent hashCode: 28904249 (parent system))
    14.02.2011 20:19:49 org.apache.coyote.http11.Http11Protocol start
    INFO: Starting Coyote HTTP/1.1 on http-8080
    14.02.2011 20:19:49 org.apache.jk.common.ChannelSocket init
    INFO: JK: ajp13 listening on /0.0.0.0:8009
    14.02.2011 20:19:49 org.apache.jk.server.JkMain start
    INFO: Jk running ID=0 time=0/31  config=null
    14.02.2011 20:19:49 org.apache.catalina.startup.Catalina start
    INFO: Server startup in 29425 ms
    Any help would be greatly appreciated. I've tried pretty much everything that came to my mind and am really stuck right now

    Thanks,
    Nick

  • #2
    How are you setting up your RemotingDestination? Try turning up the logging level on org.springframework.flex.remoting.RemotingDestinat ionExporter to INFO to verify that the destination is getting created at startup.

    Comment


    • #3
      Hi Jeremy,

      To set up the RemotingDestination, I first added the following annotations to the Java class that hosts the Remoting functions:

      Code:
      @Transactional
      @Service("TranslationService")
      @RemotingDestination(channels={"my-amf","my-secure-amf"})
      public class TranslationService {
      
      [...]
      
      }
      As this did not work, I've removed it again and tried the following at the end of web-application-context.xml. However, both did not help to solve the problem.

      Code:
      <bean class="org.translation.service.TranslationService" id="TranslationService" />
      <flex:remoting-destination ref="TranslationService" />
      I turned up the logging level for the class you described, but nothing has changed at the console output. Is the below the correct syntax to update logging?

      Code:
          <logging>
          	<target class="org.springframework.flex.remoting.RemotingDestinat" level="Info">
          	<filters>
          		<pattern>ionExporter</pattern>
          	</filters>    	
          	</target>
          </logging>
      Thanks!
      Last edited by Nick778; Feb 14th, 2011, 05:47 PM.

      Comment


      • #4
        It just occurred to me that with the mixed Spring MVC setup you're using, you probably need to set the mapping order for Flex, so that it has a change to handle a given request before the normal Spring MVC @Controller handling:

        Code:
        <flex:message-broker mapping-order="1"/>
        As for the logging, no, that looks like the BlazeDS logging config in services-config.xml. We use commons logging, so you'd either need to configure java.util logging or log4j depending on which implementation is being used.

        If setting the mapping-order doesn't do the trick, could we have a look at the code on the client side that you're using to invoked the destination, and perhaps your services-config.xml as well?

        Comment


        • #5
          I added the mapping order, but it still did not work. However, setting the logging level to INFO in the log4j properties showed me that obviously the destination is getting created (see bottom of the code snippet):

          Code:
          15.02.2011 01:29:18 org.apache.catalina.core.AprLifecycleListener init
          INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [...]
          15.02.2011 01:29:18 org.apache.tomcat.util.digester.SetPropertiesRule begin
          WARNUNG: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.j2ee.server:Translation' did not find a matching property.
          15.02.2011 01:29:19 org.apache.coyote.http11.Http11Protocol init
          INFO: Initializing Coyote HTTP/1.1 on http-8080
          15.02.2011 01:29:19 org.apache.catalina.startup.Catalina load
          INFO: Initialization processed in 1215 ms
          15.02.2011 01:29:19 org.apache.catalina.core.StandardService start
          INFO: Starting service Catalina
          15.02.2011 01:29:19 org.apache.catalina.core.StandardEngine start
          INFO: Starting Servlet Engine: Apache Tomcat/6.0.32
          15.02.2011 01:29:20 org.apache.catalina.core.ApplicationContext log
          INFO: Initializing Spring FrameworkServlet 'Spring MVC Dispatcher Servlet'
          2011-02-15 01:29:20,453 [main] INFO  org.springframework.web.servlet.DispatcherServlet - FrameworkServlet 'Spring MVC Dispatcher Servlet': initialization started
          2011-02-15 01:29:20,500 [main] INFO  org.springframework.web.context.support.XmlWebApplicationContext - Refreshing WebApplicationContext for namespace 'Spring MVC Dispatcher Servlet-servlet': startup date [Tue Feb 15 01:29:20 CET 2011]; root of context hierarchy
          2011-02-15 01:29:20,593 [main] INFO  org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from ServletContext resource [/WEB-INF/config/web-application-context.xml]
          2011-02-15 01:29:21,656 [main] INFO  org.springframework.beans.factory.config.PropertyPlaceholderConfigurer - Loading properties file from file [[...]\.metadata\.plugins\org.eclipse.wst.server.core\tmp3\wtpwebapps\Translation\WEB-INF\classes\META-INF\spring\database.properties]
          2011-02-15 01:29:21,750 [main] INFO  org.springframework.beans.factory.support.DefaultListableBeanFactory - Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@1d0d124: defining beans [org.springframework.beans.factory.config.PropertyPlaceholderConfigurer#0,org.springframework.context.config.internalBeanConfigurerAspect,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.annotation.internalPersistenceAnnotationProcessor,dataSource,transactionManager,org.springframework.transaction.config.internalTransactionAspect,entityManagerFactory,_messageBrokerHandlerAdapter,_messageBrokerDefaultHandlerMapping,_jsonConfigMapEditorConfigurer,_messageBrokerMessagingProcessor,_messageBrokerRemotingProcessor,_flexRemotingAnnotationPostProcessor,_hibernateSerializationConfigPostProcessor,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,translationService,org.springframework.flex.core.io.JpaHibernateConfigProcessor#0]; root of factory hierarchy
          2011-02-15 01:29:21,906 [main] INFO  org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean - Building JPA container EntityManagerFactory for persistence unit 'persistenceUnit'
          2011-02-15 01:29:22,109 [main] INFO  org.hibernate.annotations.common.Version - Hibernate Commons Annotations 3.2.0.Final
          2011-02-15 01:29:22,125 [main] INFO  org.hibernate.cfg.Environment - Hibernate 3.6.0.Final
          2011-02-15 01:29:22,125 [main] INFO  org.hibernate.cfg.Environment - hibernate.properties not found
          2011-02-15 01:29:22,125 [main] INFO  org.hibernate.cfg.Environment - Bytecode provider name : javassist
          2011-02-15 01:29:22,156 [main] INFO  org.hibernate.cfg.Environment - using JDK 1.4 java.sql.Timestamp handling
          2011-02-15 01:29:22,296 [main] INFO  org.hibernate.ejb.Version - Hibernate EntityManager 3.6.0.Final
          2011-02-15 01:29:22,359 [main] INFO  org.hibernate.ejb.Ejb3Configuration - Processing PersistenceUnitInfo [
          	name: persistenceUnit
          	...]
          2011-02-15 01:29:22,718 [main] INFO  org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: 
          
          [... a lot of Hibernate stuff ...]
          
          2011-02-15 01:29:40,875 [main] INFO  org.hibernate.tool.hbm2ddl.SchemaExport - schema export complete
          2011-02-15 01:29:41,156 [main] INFO  org.springframework.flex.config.FlexConfigurationManager - Loading Flex services configuration from: ServletContext resource [/WEB-INF/flex/services-config.xml]
          2011-02-15 01:29:41,375 [main] INFO  org.springframework.flex.core.MessageBrokerFactoryBean - BlazeDS - Community Edition: 4.0.0.14931
          [BlazeDS]Endpoint 'my-amf' created with security: None
          at URL: http://localhost:8080/translation/messagebroker/amf
          [BlazeDS]Endpoint 'my-secure-amf' created with security: None
          at URL: https://localhost:8080/translation/messagebroker/amfsecure
          2011-02-15 01:29:41,421 [main] INFO  org.springframework.flex.core.MessageBrokerFactoryBean - MessageBroker with id '_messageBroker' is starting.
          [BlazeDS]MessageBroker id: _messageBroker classLoader is: the MessageBroker's class loader and the context class loader (classLoader hashCode: 16022517 (parent hashCode: 16795905 (parent system))
          2011-02-15 01:29:41,890 [main] INFO  org.springframework.flex.core.io.HibernateConfigProcessor - Hibernate detected and AMF serialization support automatically installed successfully.
          2011-02-15 01:29:41,890 [main] INFO  org.springframework.flex.core.MessageBrokerFactoryBean - MessageBroker with id '_messageBroker' is ready (startup time: '469' ms)
          2011-02-15 01:29:41,890 [main] INFO  org.springframework.web.servlet.handler.SimpleUrlHandlerMapping - Default mapping to handler '_messageBroker'
          2011-02-15 01:29:41,921 [main] INFO  org.springframework.flex.remoting.RemotingDestinationExporter - Created remoting destination with id 'translationService'
          2011-02-15 01:29:41,921 [main] INFO  org.springframework.flex.remoting.RemotingDestinationExporter - Remoting destination 'translationService' has been started started successfully.
          2011-02-15 01:29:42,078 [main] INFO  org.springframework.web.servlet.DispatcherServlet - FrameworkServlet 'Spring MVC Dispatcher Servlet': initialization completed in 21625 ms
          15.02.2011 01:29:42 org.apache.coyote.http11.Http11Protocol start
          INFO: Starting Coyote HTTP/1.1 on http-8080
          15.02.2011 01:29:42 org.apache.jk.common.ChannelSocket init
          INFO: JK: ajp13 listening on /0.0.0.0:8009
          15.02.2011 01:29:42 org.apache.jk.server.JkMain start
          INFO: Jk running ID=0 time=0/47  config=null
          15.02.2011 01:29:42 org.apache.catalina.startup.Catalina start
          INFO: Server startup in 22419 ms
          My services-config.xml looks like this:

          Code:
          <?xml version="1.0" encoding="UTF-8"?>
          <services-config>
          
              <services>
                  <default-channels>
                     <channel ref="my-amf"/>
                  </default-channels>
              </services>
          
              <channels>
                  <channel-definition id="my-amf" class="mx.messaging.channels.AMFChannel">
                      <endpoint url="http://localhost:8080/translation/messagebroker/amf" class="flex.messaging.endpoints.AMFEndpoint"/>
          			<!-- <properties>
          				<polling-enabled>false</polling-enabled>
          			</properties> -->            
                  </channel-definition>
                  
          		<channel-definition id="my-secure-amf" class="mx.messaging.channels.SecureAMFChannel">
                      <endpoint url="https://localhost:8080/translation/messagebroker/amfsecure" class="flex.messaging.endpoints.SecureAMFEndpoint"/>
                      <properties>
                          <add-no-cache-headers>false</add-no-cache-headers>
                      </properties>
                  </channel-definition>
              </channels>
              
              <logging>
                  <target class="flex.messaging.log.ConsoleTarget" level="Debug">
                      <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>
          The code on the client side is just for testing purposes right now, so pretty basic:

          Code:
          <?xml version="1.0" encoding="utf-8"?>
          <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
          			   xmlns:s="library://ns.adobe.com/flex/spark" 
          			   xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">
          	<fx:Declarations>
          		<s:RemoteObject id="ro" destination="translationService" endpoint="http://localhost:8080/translation/messagebroker/amf" />
          	</fx:Declarations>
          	
          	<s:TextArea text="{ro.test()}"/>
          	
          </s:Application>
          The test() method just returns a string with some text in it.

          Comment


          • #6
            Oh, and this is what the Debug Flash Player returns as soon as I open the generated swf file:

            Code:
            [RPC Fault faultString="Send failed" faultCode="Client.Error.MessageSend" faultDetail="Channel.Connect.Failed error NetConnection.Call.Failed: HTTP: Status 404: url: 'http://localhost:8080/translation/messagebroker/amf'"]
            	at mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::faultHandler()[E:\dev\4.x\frameworks\projects\rpc\src\mx\rpc\AbstractInvoker.as:345]
            	at mx.rpc::Responder/fault()[E:\dev\4.x\frameworks\projects\rpc\src\mx\rpc\Responder.as:68]
            	at mx.rpc::AsyncRequest/fault()[E:\dev\4.x\frameworks\projects\rpc\src\mx\rpc\AsyncRequest.as:113]
            	at mx.messaging::ChannelSet/faultPendingSends()[E:\dev\4.x\frameworks\projects\rpc\src\mx\messaging\ChannelSet.as:1614]
            	at mx.messaging::ChannelSet/channelFaultHandler()[E:\dev\4.x\frameworks\projects\rpc\src\mx\messaging\ChannelSet.as:1206]
            	at flash.events::EventDispatcher/dispatchEventFunction()
            	at flash.events::EventDispatcher/dispatchEvent()
            	at mx.messaging::Channel/connectFailed()[E:\dev\4.x\frameworks\projects\rpc\src\mx\messaging\Channel.as:1128]
            	at mx.messaging.channels::PollingChannel/connectFailed()[E:\dev\4.x\frameworks\projects\rpc\src\mx\messaging\channels\PollingChannel.as:406]
            	at mx.messaging.channels::AMFChannel/statusHandler()[E:\dev\4.x\frameworks\projects\rpc\src\mx\messaging\channels\AMFChannel.as:453]

            Comment


            • #7
              Well, this isn't the problem, but that code's not going to do quite what you think it is...should be something more like:

              Code:
              <?xml version="1.0" encoding="utf-8"?>
              <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
              			   xmlns:s="library://ns.adobe.com/flex/spark" 
              			   xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" applicationComplete="init()">
              	
              	<fx:Script>
              		<![CDATA[
              			private function init():void {
              				ro.test();
              			} 
              		]]>
              	</fx:Script>
              	
              	<fx:Declarations>
              		<s:RemoteObject id="ro" destination="translationService" endpoint="http://localhost:8080/translation/messagebroker/amf" />
              	</fx:Declarations>
              	
              	<s:TextArea text="{ro.test.lastResult}"/>
              </s:Application>
              I'm sure I'm lacking some simple piece of information that would help me pin down your problem. Can you attach a .zip of your project?

              Comment


              • #8
                Oh, thanks for that! I didn't do any Flex programming in a while - looks like I need to get back into the topic again

                I'm sure you're right. It seems to me like I'm almost there, but some little piece might be wrong or missing, but I just don't see it. However, I don't really want to post my whole project publicly here in the forum, and it's bigger than the allowed file size anyway. Is there another way to get it over to you? I can easily upload it to my server and drop you a link if that helps.

                Thanks for all your help so far, I really appreciate that!
                Last edited by Nick778; Feb 14th, 2011, 09:08 PM.

                Comment

                Working...
                X