3

I am trying to add BlazeDS to a Spring Boot application. I have added the `MessageBrokerServlet' in my configuration for this:

@Bean
public ServletRegistrationBean messageBrokerRegistration()
{
    ServletRegistrationBean registration = new ServletRegistrationBean(new MessageBrokerServlet(), "/messagebroker/*");
    Map<String,String> params = Maps.newHashMap();
    params.put( "services.configuration.file", "/WEB-INF/flex/services-config.xml" );
    registration.setInitParameters(params);
    return registration;
}

The servlet gets loaded, but fails at runtime with:

MessageBrokerServlet in application 'undefined' failed to initialize due to runtime exception:   
Exception: flex.messaging.config.ConfigurationException: Please specify a 
valid 'services.configuration.file' in web.xml. You specified '{0}'.
This is not a valid file system path reachable via the app server and 
is also not a path to a resource in your J2EE application archive.

Looking through the source code of BlazeDS, I see that in the end, the code uses ServletContext#getResourceAsStream(path). How can I make the embedded tomcat in Spring Boot return something on that call?

I am using Spring Boot 1.1.1 which uses embedded Tomcat 7.0.54

Wim Deblauwe
  • 25,113
  • 20
  • 133
  • 211

2 Answers2

0

Servlet context resources should work in a war at least. Stick them in src/main/webapp (for a standard build layout).

Dave Syer
  • 56,583
  • 10
  • 155
  • 143
0

I was able to do this recently using the following:

@Lazy
@Bean(name="messageBroker")
public MessageBrokerFactoryBean messageBrokerFactoryBean() {
    MessageBrokerFactoryBean messageBrokerFactory = new MessageBrokerFactoryBean();
    messageBrokerFactory.setServicesConfigPath("classpath:/flex/services-config.xml");
    return  messageBrokerFactory;
}

Where services-config.xml (and my other flex config files) are in src/main/resources/flex

Hope this hope someone else!

bischoje
  • 197
  • 1
  • 8