Announcement Announcement Module
Collapse
No announcement yet.
[Newbie] Help! spring and blazeds - can't start broker Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • [Newbie] Help! spring and blazeds - can't start broker

    Hello,

    I know there are a ton of issues already on this, but I can't seem to figure it out still. epic fail. Thanks for your help in advance!!

    What is the problem you ask? I am getting a NPE when I try and start a message broker. I am mainly using the instructions and example from: http://www.springbyexample.org/examp...ex-webapp.html

    I am trying to use tomcat 6. the error is from catalina.out

    The error first - probably means a lot more to you. I have attached the full log.
    Code:
    INFO: BlazeDS - Community Edition: 3.2.0.3978
    Mar 30, 2011 2:37:35 PM org.springframework.flex.core.MessageBrokerFactoryBean afterPropertiesSet
    INFO: MessageBroker with id '_messageBroker' is starting.
    Mar 30, 2011 2:37:35 PM org.springframework.beans.factory.support.DefaultSingletonBeanRegistry destroySingletons
    INFO: Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@508b00d5: defining beans [_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]; parent: org.springframework.beans.factory.support.DefaultListableBeanFactory@7f8be298
    Mar 30, 2011 2:37:35 PM org.springframework.web.servlet.FrameworkServlet initServletBean
    SEVERE: Context initialization failed
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name '_messageBrokerDefaultHandlerMapping': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '_messageBroker': Invocation of init method failed; nested exception is org.springframework.beans.factory.BeanInitializationException: MessageBroker initialization failed; nested exception is java.lang.NullPointerException
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450)
            at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:290)
            at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
            at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:287)
            at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:189)
            at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:557)
            at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:842)
            at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:416)
            at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:443)
            at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:459)
            at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:340)
            at ...
    What I have is this:
    pom:
    Code:
    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
      <modelVersion>4.0.0</modelVersion>
     
      <groupId>test.spring</groupId>
      <artifactId>flex</artifactId>
      <version>0.0.1-SNAPSHOT</version>
      <packaging>war</packaging>
     
      <properties>
        <spring.version>3.0.0.RELEASE</spring.version>
      </properties>
      
      <dependencies>
          <dependency>
          <groupId>org.springframework</groupId>
          <artifactId>spring-beans</artifactId>
          <version>${spring.version}</version>
        </dependency>
        <dependency>
          <groupId>org.springframework</groupId>
          <artifactId>spring-core</artifactId>
          <version>${spring.version}</version>
        </dependency>
            <dependency>
          <groupId>org.springframework</groupId>
          <artifactId>spring-jms</artifactId>
          <version>${spring.version}</version>
        </dependency>
            <dependency>
          <groupId>org.springframework</groupId>
          <artifactId>spring-tx</artifactId>
          <version>${spring.version}</version>
        </dependency>
        <dependency>
          <groupId>org.springframework</groupId>
          <artifactId>spring-context</artifactId>
          <version>${spring.version}</version>
        </dependency>
        <dependency>
          <groupId>org.springframework</groupId>
          <artifactId>spring-orm</artifactId>
          <version>${spring.version}</version>
        </dependency>
        <dependency>
          <groupId>org.springframework</groupId>
          <artifactId>spring-web</artifactId>
          <version>${spring.version}</version>
        </dependency>
        <dependency>
          <groupId>org.springframework</groupId>
          <artifactId>spring-webmvc</artifactId>
          <version>${spring.version}</version>
        </dependency>
        <dependency>
          <groupId>org.springframework.flex</groupId>
          <artifactId>spring-flex</artifactId>
          <version>1.0.3.RELEASE</version>
        </dependency>
      </dependencies>
    </project>
    Then the config files are simple and there is no code yet . Trying to be as simple as possible.
    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">
    
      <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
      </listener>
      <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/spring/web-application-context.xml</param-value>
      </context-param>
      
      
      <servlet>
        <servlet-name>SpringMessageBroker</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <init-param>
          <param-name>contextConfigLocation</param-name>
          <param-value>/WEB-INF/spring/flex-servlet-context.xml</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
      </servlet>
      
      <servlet-mapping>
        <servlet-name>SpringMessageBroker</servlet-name>
        <url-pattern>/messagebroker/*</url-pattern>
      </servlet-mapping>
      
    </web-app>
    flex-servlet-context.xml
    Code:
    <?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: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">
        <flex:message-broker/>
    </beans>
    web-application-context.xml
    Code:
    <?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:camel="http://camel.apache.org/schema/spring"
           xmlns:broker="http://activemq.apache.org/schema/core"
           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://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd
            http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
    
    </beans>
    and finally the services-config.xml
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <services-config>
        <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>

  • #2
    Fixed?

    Ok - so i changed the services-config.xml to be more like the default...

    I am not sure if this is all necessary (i thought it wasn't...but results don't lie)

    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://{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>

    Comment


    • #3
      Think I got the same problem.

      In my case the problem was that _messageBroker was initialized twice. Once by the ContextLoaderListener and once when the SpringDispatcherServlet parameter "contextConfigLocation" was explicitly set. Once I removed the parameter everything worked fine.

      Comment

      Working...
      X