Announcement Announcement Module
Collapse
No announcement yet.
Spring 1.2 XmlViewResolver and dependency injected unit test Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring 1.2 XmlViewResolver and dependency injected unit test

    Hi,

    Looks like the XmlViewResolver in Spring 1.2 requires a WebApplication Context. I had a test case using AbstractDependencyInjectionSpringContextTests where I set the config location to a context definition which contains a definition of XmlViewResolver. It worked in 1.2 RC2, but in the 1.2 final release, it checks for WebApplication context and throws an exception:

    Code:
    Initialization of bean failed; nested exception is java.lang.IllegalStateException: WebApplicationObjectSupport instance [org.springframework.web.servlet.view.XmlViewResolver@1309e87] does not run in a WebApplicationContext but in: org.springframework.context.support.ClassPathXmlApplicationContext
    Is there a workaround where I can still use the dependency injected test cases to load bean definitions including XmlVewResolver beans?

    -- suresh --

  • #2
    Well. i also came across this exception.actually i am building pdf by extending my class from abstractpdfview and was using following configuration fro that.it was working fine but when i tried to run test case i came across this.



    Error creating bean with name 'pdfViewResolver' defined in class path resource [dispatcher-servlet.xml]: Initialization of bean failed; nested exception is java.lang.IllegalStateException: WebApplicationObjectSupport instance [org.springframework.web.servlet.view.XmlViewResolv er@3a346f] does not run in a WebApplicationContext but in: org.springframework.context.support.ClassPathXmlAp plicationContext: display name [org.springframework.context.support.ClassPathXmlAp plicationContext;hashCode=16778019]; startup date [Fri Feb 15 15:18:18 GMT+05:00 2008]; root of context hierarchy

    <bean id="pdfViewResolver" class="org.springframework.web.servlet.view.XmlVie wResolver">
    <property name="order" value="1"/>
    <property name="location" value="/WEB-INF/views.xml"/>
    </bean>

    and in views.xml i have

    <bean name="GenerateCertificatePDF" class="com.......CreateCertificatePDF">
    <property name="certificateService" ref="certificateService"/>
    </bean>

    so i searched net but wasnt able to find a solution.everybody is yelling to find a solution.then suddenly it start working fine.when i changed my configuration to this.

    <bean name="GenerateCertificatePDF" class="com.......CreateCertificatePDF">
    <property name="certificateService" ref="certificateService"/>
    </bean>

    <bean id="beanNameViewResolver" class="org.springframework.web.servlet.view.BeanNa meViewResolver">
    <property name="order"><value>2</value></property>
    </bean>
    i put above configuration in dispatcher.xml and problem is solved.so anybody having this ugly exception change ur ViewResolver.

    Asad

    Comment

    Working...
    X