PDA

View Full Version : Problems with message-broker services-config-path



tpurcell
Aug 6th, 2009, 11:40 AM
Hello

I have a web app with multiple applicationContect files so in my web.xml I have:


<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>classpath*:applicationContext*.xml</param-value>
</init-param>
<load-on-startup>20</load-on-startup>
</servlet>


I've configured my message-broker a file named applicationContext-flex.xml in the following way:


<flex:message-broker services-config-path="classpath*:services-config.xml"/>

When my web app deploys I get the following message when the applicationContext files load:


DEBUG 2009-08-06 12:18:21,188 DEBUG [org.springframework.core.io.support.PathMatchingRe sourcePatternResolver] - Resolved location pattern [classpath*:applicationContext*.xml] to resources [file [/home/tpurcell/data/projects/busInTheClouds/enterprise-flex-war/enterprise-war/target/classes/applicationContext-file.xml], file [/home/tpurcell/data/projects/busInTheClouds/enterprise-flex-war/enterprise-war/target/classes/applicationContext-flex.xml], file [/home/tpurcell/data/projects/busInTheClouds/enterprise-flex-war/enterprise-war/target/classes/applicationContext-integration.xml]]


Spring starts to create the beans until it gets to the messageBroker. Then I get:


DEBUG 2009-08-06 11:38:41,893 DEBUG [org.springframework.beans.factory.support.DefaultL istableBeanFactory] - Invoking afterPropertiesSet() on bean with name '_messageBroker'
INFO 2009-08-06 11:38:41,934 INFO [org.springframework.beans.factory.support.DefaultL istableBeanFactory] - Destroying singletons in org.springframework.beans.factory.support.DefaultL istableBeanFactory@5e3a78ad: defining beans [org.springframework.integration.internalDefaultCon figuringBeanFactoryPostProcessor,org.springframewo rk.integration.file.config.FileWritingMessageHandl erFactoryBean#0,file-writer-channel-adapter,_messageBrokerHandlerAdapter,_messageBroke rDefaultHandlerMapping,_jsonConfigMapEditorConfigu rer,_messageBrokerMessagingProcessor,_flexRemoting AnnotationPostProcessor,_messageBrokerRemotingProc essor,org.springframework.flex.core.ExceptionTrans lationAdvice#0,org.springframework.flex.core.Endpo intServiceMessagePointcutAdvisor#0,org.springframe work.flex.core.MessageInterceptionAdvice#0,org.spr ingframework.flex.core.EndpointServiceMessagePoint cutAdvisor#1,_messageBrokerEndpointProcessor,_mess ageBroker,org.springframework.flex.messaging.integ ration.IntegrationAdapter#0,payload-flex-destination,connectionFactory,requestQueue,org.spr ingframework.integration.scheduling.IntervalTrigge r#0,poller,org.springframework.integration.channel .interceptor.WireTap#0,jmsin-channel,org.springframework.integration.jms.JmsDes tinationPollingSource#0,jmsin-channel-adapter,logging-channel-adapter,org.springframework.integration.handler.Lo ggingHandler#0,logging-channel-adapter.adapter,org.springframework.integration.ha ndler.BridgeHandler#0,org.springframework.integrat ion.config.ConsumerEndpointFactoryBean#0,payload-channel,nullChannel,errorChannel,org.springframewo rk.integration.handler.LoggingHandler#1,org.spring framework.integration.endpoint.EventDrivenConsumer #0,org.springframework.integration.channel.Message PublishingErrorHandler#0,taskScheduler]; root of factory hierarchy
DEBUG 2009-08-06 11:38:41,935 DEBUG [org.springframework.beans.factory.support.Disposab leBeanAdapter] - Invoking destroy() on bean with name 'taskScheduler'
INFO 2009-08-06 11:38:41,935 INFO [org.springframework.integration.scheduling.SimpleT askScheduler] - shutting down TaskExecutor
INFO 2009-08-06 11:38:41,935 INFO [org.springframework.scheduling.concurrent.ThreadPo olTaskExecutor] - Shutting down ThreadPoolExecutor
ERROR 2009-08-06 11:38:41,936 ERROR [org.springframework.web.servlet.DispatcherServlet] - Context initialization failed
org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name '_messageBrokerDefaultHandlerMapping': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name '_messageBroker': Invocation of init method failed; nested exception is java.lang.IllegalStateException: Flex configuration file does not exist at path: classpath*:services-config.xml
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.doCreateBean(AbstractAu towireCapableBeanFactory.java:480)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory$1.run(AbstractAutowireC apableBeanFactory.java:409)
at java.security.AccessController.doPrivileged(Native Method)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:380)
at org.springframework.beans.factory.support.Abstract BeanFactory$1.getObject(AbstractBeanFactory.java:2 64)
at org.springframework.beans.factory.support.DefaultS ingletonBeanRegistry.getSingleton(DefaultSingleton BeanRegistry.java:221)
at org.springframework.beans.factory.support.Abstract BeanFactory.doGetBean(AbstractBeanFactory.java:261 )
at
...


I'm running:
Apache Maven: 2.2.0 (r788681; 2009-06-26 09:04:01-0400)
Java version: 1.6.0_11
org.springframework: 2.5.5
org.springframework.integration: 1.0.3.RELEASE
org.springframework.flex: 1.0.0.RELEASE

I'm running using mvn jetty:run (jetty 6.1.14) but I packaged the app as a war and deployed to tomcat (6.0.16) and got the same result. Yes the file does exist:


tpurcell@linux-glk3:~/data/projects/busInTheClouds/enterprise-flex-war/enterprise-war/target/classes> ls -la
total 32
drwxr-xr-x 2 tpurcell users 4096 2009-08-06 12:18 .
drwxr-xr-x 4 tpurcell users 4096 2009-08-06 12:18 ..
-rw-r--r-- 1 tpurcell users 1015 2009-08-06 12:18 applicationContext-file.xml
-rw-r--r-- 1 tpurcell users 1488 2009-08-06 12:18 applicationContext-flex.xml
-rw-r--r-- 1 tpurcell users 3366 2009-08-06 12:18 applicationContext-integration.xml
-rw-r--r-- 1 tpurcell users 331 2009-08-06 12:18 commons-logging.properties
-rw-r--r-- 1 tpurcell users 867 2009-08-06 12:18 log4j.properties
-rw-r--r-- 1 tpurcell users 1249 2009-08-06 12:18 services-config.xml


I'm stuck. Any suggestions?

Thanks
Tom

jeremyg484
Aug 6th, 2009, 12:25 PM
I don't see any clear reason why it wouldn't be working. The same ResourceLoader that is able to find your app context files successfully should be the one getting used to load your services-config.xml. If you create a Jira and attach a similar example then we can try and reproduce.

tpurcell
Aug 7th, 2009, 09:42 AM
Okay

The reason why I was doing this was because I needed to do resource filtering on the services-config.xml. Since Maven by default puts resources on the classpath (target/classes) I wanted to configure the Flex to look there for its config. Since that does not seem to work I came up with this work around.

First in my pom I have the following filters/resources definitions that filter the services-config.xml file and copy it to the default location(WEB-INF/flex):


<filters>
<filter>src/main/filters/spring.filter.properties</filter>
</filters>
<resources>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*</include>
</includes>
<excludes>
<exclude>services-config.xml</exclude>
</excludes>
<filtering>true</filtering>
</resource>
<resource>
<directory>src/main/resources</directory>
<targetPath>${basedir}/src/main/webapp/WEB-INF/flex</targetPath>
<includes>
<include>services-config.xml</include>
</includes>
<filtering>true</filtering>
</resource>
</resources>


Then in the applicationContext.xml I just use the default message-broker definition:


<flex:message-broker/>


So I'm okay for now but I have created a jira issue (http://jira.springframework.org/browse/FLEX-70). I'll be posting a sample app to that issue shortly.

Thanks
Tom

jeremyg484
Aug 7th, 2009, 01:27 PM
Tom,

Thanks for opening the Jira and supplying the example to make it easy to reproduce. As it turns out, there was a bug in that we were only ever using the ResourceLoader interface instead of ResourcePatternResolver (if available). As such, a path like "classpath:services-config.xml" would work, but "classpath*:services.config.xml" would not. This has now been resolved, and the fix will be a part of the 1.0.1 release which we should get out within the next couple of weeks. The fix is also available in the latest CI build (http://s3.amazonaws.com/dist.springframework.org/snapshot/FLEX/spring-flex-1.0.1.CI-245.zip or later) if you'd like to try it out prior to the actual 1.0.1 release.