Hi John,
The file goes in WEB-INF/applicationContext-test.xml. However, as I
explain on page 272 of the final PDF, you also have to add a context
parameter named "contextConfigLocation" with the value
"/WEB-INF/applicationContext-test.xml". This is done in
email_27/src/stripesbook/test/stripesmock/ContactFormActionBeanTest.java
because the chapter deals with testing with mock objects. To use this
configuration in the web application as opposed to a mock test, you
have to do the equivalent configuration in web.xml:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext-test.xml</param-value>
</context-param>
That will tell Spring which configuration to use.
Hope that helps.
Cheers,
Freddy
http://www.stripesbook.com
On Fri, 7 Nov 2008 16:23:21 +0000 (UTC), "John Borys"
<[EMAIL PROTECTED]> said:
> I am trying to get Freddie's example working and I'm wondering what I am
> doing
> wrong? Do I have the applicationContext-test.xml in the wrong place?
> Why is
> the spring ContextLoader unable to find this file? I know it's probably
> something simple but I'm not very good with configuration issues (which
> is why I
> chose Stripes :-) ).
>
> MockServletContext: Initializing Spring root WebApplicationContext
> [15:30:05] ERROR org.springframework.web.context.ContextLoader
> - Contextinitialization failed
> org.springframework.beans.factory.BeanDefinitionStoreException:
> IOException
> parsing XML document from ServletContext resource
> [/WEB-INF/applicationContext-test.xml]; nested exception is
> java.io.FileNotFoundException: Could not open ServletContext resource
> [/WEB-INF/applicationContext-test.xml]
> at
> org.springframework.beans.factory.xml.XmlBeanDefinitionReader.
> loadBeanDefinitions(XmlBeanDefinitionReader.java:349)
> at
> org.springframework.beans.factory.xml.XmlBeanDefinitionReader.
> loadBeanDefinitions(XmlBeanDefinitionReader.java:310)
> at
> org.springframework.beans.factory.support.
> AbstractBeanDefinitionReader.
> loadBeanDefinitions(AbstractBeanDefinitionReader.java:143)
> at
> org.springframework.beans.factory.support.
> AbstractBeanDefinitionReader.
> loadBeanDefinitions(AbstractBeanDefinitionReader.java:178)
> at
> org.springframework.beans.factory.support.
> AbstractBeanDefinitionReader.
> loadBeanDefinitions(AbstractBeanDefinitionReader.java:149)
> at
> org.springframework.web.context.support.
> XmlWebApplicationContext.
> loadBeanDefinitions(XmlWebApplicationContext.java:124)
> at
> org.springframework.web.context.support.
> XmlWebApplicationContext.
> loadBeanDefinitions(XmlWebApplicationContext.java:92)
> at
> org.springframework.context.support.
> AbstractRefreshableApplicationContext.
> refreshBeanFactory(AbstractRefreshableApplicationContext.java:123)
> at
> org.springframework.context.support.AbstractApplicationContext.
> obtainFreshBeanFactory(AbstractApplicationContext.java:423)
> at
> org.springframework.context.support.AbstractApplicationContext.
> refresh(AbstractApplicationContext.java:353)
> at
> org.springframework.web.context.ContextLoader.
> createWebApplicationContext(ContextLoader.java:255)
> at
> org.springframework.web.context.ContextLoader.
> initWebApplicationContext(ContextLoader.java:199)
> at
> org.springframework.web.context.ContextLoaderListener.
> contextInitialized(ContextLoaderListener.java:45)
> at
> stripesbook.test.stripesmock.ContactFormActionBeanTest.
> setup(ContactFormActionBeanTest.java:47)
>
> at sun.reflect.NativeMethodAccessorImpl.
> invoke0(Native Method)
>
> at sun.reflect.NativeMethodAccessorImpl.
> invoke(NativeMethodAccessorImpl.java:39)
> at
> sun.reflect.DelegatingMethodAccessorImpl.
> invoke(DelegatingMethodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:585)
> at org.junit.internal.runners.ClassRoadie.
> runBefores(ClassRoadie.java:49)
> at org.junit.internal.runners.ClassRoadie.
> runProtected(ClassRoadie.java:36)
> at org.junit.internal.runners.JUnit4ClassRunner
> .run(JUnit4ClassRunner.java:42)
> at
> org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.
> run(JUnit4TestReference.java:45)
> at org.eclipse.jdt.internal.junit.runner.TestExecution.
> run(TestExecution.java:38)
> at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner
> .runTests(RemoteTestRunner.java:460)
> at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.
> runTests(RemoteTestRunner.java:673)
> at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.
> run(RemoteTestRunner.java:386)
> at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner
> .main(RemoteTestRunner.java:196)
> Caused by: java.io.FileNotFoundException: Could not open
> ServletContext resource
> [/WEB-INF/applicationContext-test.xml]
> at
> org.springframework.web.context.support.ServletContextResource.
> getInputStream(ServletContextResource.java:116)
> at
> org.springframework.beans.factory.xml.XmlBeanDefinitionReader.
> loadBeanDefinitions(XmlBeanDefinitionReader.java:336)
> ... 26 more
>
>
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's
> challenge
> Build the coolest Linux based applications with Moblin SDK & win great
> prizes
> Grand prize is a trip for two to an Open Source event anywhere in the
> world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> Stripes-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/stripes-users
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Stripes-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-users