You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by HHB <hu...@yahoo.ca> on 2009/04/06 17:20:52 UTC

Spring integration problem

Hey,
I'm trying to integrate Spring 2.5 into our Wicket 
application, I did the following:

web.xml:
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath:applicationContext.xml</param-value>
    </context-param>
    <listener>
        <listener-class>org.springframework.web.
context.ContextLoaderListener</listener-class>
    </listener>
    <filter>
        <filter-name>OpenSessionInViewFilter</filter-name>
        <filter-class>org.springframework.orm.hibernate3.
support.OpenSessionInViewFilter</filter-class>
    </filter>

    <filter>
        <filter-name>WicketFilter</filter-name>
        <filter-class>org.apache.wicket.
protocol.http.WicketFilter</filter-class>
        <init-param>
            <param-name>applicationFactoryClassName</param-name>
            <param-value>org.apache.wicket.spring.
SpringWebApplicationFactory</param-value>
        </init-param>
    </filter>
    <filter>
        <filter-name>WicketFilter</filter-name>
        <filter-class>org.apache.wicket.
protocol.http.WicketFilter</filter-class>
        <init-param>
            <param-name>applicationFactoryClassName</param-name>
            <param-value>org.apache.wicket.spring.
SpringWebApplicationFactory</param-value>
        </init-param>
    </filter>

applicationContext.xml:

    <bean id="wicketApplication" class="domain.WicketApplication"/>


pom.xml:

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring</artifactId>
            <version>2.5.6</version>
        </dependency>

        <dependency>
            <groupId>org.apache.wicket</groupId>
            <artifactId>wicket-spring</artifactId>
            <version>1.3.5</version>
        </dependency>
        <dependency>
            <groupId>org.apache.wicket</groupId>
            <artifactId>wicket-spring-annot</artifactId>
            <version>1.3.5</version>
        </dependency>

WicketApplication:

   @Override
    protected void init() {
        super.init();
        addComponentInstantiationListener
(new SpringComponentInjector(this));
    }

But when trying:
mvn test
I got the following exception:
------------------------------------
-------------------------------------------
Test set: TestSuite
------------------------------------
-------------------------------------------
Tests run: 2, Failures: 1, Errors: 0, 
Skipped: 1, Time elapsed: 0.498 sec <<< FAILURE!
init(domain.TestHomePage)  Time elapsed: 0 sec  <<< FAILURE!
java.lang.IllegalStateException: 
No WebApplicationContext found: no ContextLoaderListener registered?
	at org.springframework.web.context.support.
WebApplicationContextUtils.
getRequiredWebApplicationContext(WebApplicationContextUtils.java:70)
	at org.apache.wicket.spring.
injection.annot.SpringComponentInjector.
<init>(SpringComponentInjector.java:74)

Any ideas?
Thanks.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Spring integration problem

Posted by HHB <hu...@yahoo.ca>.
I tried what you suggested, no luck, the same error.


Leandro Féres wrote:
> 
> Sorry, didn't see (at first) that you've already done something similar.
> Anyway, try replacing "classpath:applicationContext.xml" for
> "WEB-INF/applicationContext.xml". I'm not sure if this classpath param
> works
> there.
> 
> Regards,
> 
> 
> Leandro.
> 
> 2009/4/6 Leandro Féres <le...@gmail.com>
> 
>> You must tell where's your spring context (applicationContext.xml).
>> Try this:
>>
>> <listener>
>>
>> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
>> </listener>
>> <context-param>
>>     <param-name>contextConfigLocation</param-name>
>>     <param-value>WEB-INF/applicationContext.xml</param-value>
>> </context-param>
>>
>> Regards,
>>
>>
>> Leandro.
>>
>>
>> 2009/4/6 HHB <hu...@yahoo.ca>
>>
>> Hey,
>>> I'm trying to integrate Spring 2.5 into our Wicket
>>> application, I did the following:
>>>
>>> web.xml:
>>>    <context-param>
>>>        <param-name>contextConfigLocation</param-name>
>>>        <param-value>classpath:applicationContext.xml</param-value>
>>>    </context-param>
>>>    <listener>
>>>        <listener-class>org.springframework.web.
>>> context.ContextLoaderListener</listener-class>
>>>    </listener>
>>>    <filter>
>>>        <filter-name>OpenSessionInViewFilter</filter-name>
>>>        <filter-class>org.springframework.orm.hibernate3.
>>> support.OpenSessionInViewFilter</filter-class>
>>>    </filter>
>>>
>>>    <filter>
>>>        <filter-name>WicketFilter</filter-name>
>>>        <filter-class>org.apache.wicket.
>>> protocol.http.WicketFilter</filter-class>
>>>        <init-param>
>>>            <param-name>applicationFactoryClassName</param-name>
>>>            <param-value>org.apache.wicket.spring.
>>> SpringWebApplicationFactory</param-value>
>>>        </init-param>
>>>    </filter>
>>>    <filter>
>>>        <filter-name>WicketFilter</filter-name>
>>>        <filter-class>org.apache.wicket.
>>> protocol.http.WicketFilter</filter-class>
>>>        <init-param>
>>>            <param-name>applicationFactoryClassName</param-name>
>>>            <param-value>org.apache.wicket.spring.
>>> SpringWebApplicationFactory</param-value>
>>>        </init-param>
>>>    </filter>
>>>
>>> applicationContext.xml:
>>>
>>>    <bean id="wicketApplication" class="domain.WicketApplication"/>
>>>
>>>
>>> pom.xml:
>>>
>>>        <dependency>
>>>            <groupId>org.springframework</groupId>
>>>            <artifactId>spring</artifactId>
>>>            <version>2.5.6</version>
>>>        </dependency>
>>>
>>>        <dependency>
>>>            <groupId>org.apache.wicket</groupId>
>>>            <artifactId>wicket-spring</artifactId>
>>>            <version>1.3.5</version>
>>>        </dependency>
>>>        <dependency>
>>>            <groupId>org.apache.wicket</groupId>
>>>            <artifactId>wicket-spring-annot</artifactId>
>>>            <version>1.3.5</version>
>>>        </dependency>
>>>
>>> WicketApplication:
>>>
>>>   @Override
>>>    protected void init() {
>>>        super.init();
>>>        addComponentInstantiationListener
>>> (new SpringComponentInjector(this));
>>>    }
>>>
>>> But when trying:
>>> mvn test
>>> I got the following exception:
>>> ------------------------------------
>>> -------------------------------------------
>>> Test set: TestSuite
>>> ------------------------------------
>>> -------------------------------------------
>>> Tests run: 2, Failures: 1, Errors: 0,
>>> Skipped: 1, Time elapsed: 0.498 sec <<< FAILURE!
>>> init(domain.TestHomePage)  Time elapsed: 0 sec  <<< FAILURE!
>>> java.lang.IllegalStateException:
>>> No WebApplicationContext found: no ContextLoaderListener registered?
>>>        at org.springframework.web.context.support.
>>> WebApplicationContextUtils.
>>> getRequiredWebApplicationContext(WebApplicationContextUtils.java:70)
>>>        at org.apache.wicket.spring.
>>> injection.annot.SpringComponentInjector.
>>> <init>(SpringComponentInjector.java:74)
>>>
>>> Any ideas?
>>> Thanks.
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/Spring-integration-problem-tp22911007p22911597.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Spring integration problem

Posted by Leandro Féres <le...@gmail.com>.
Sorry, didn't see (at first) that you've already done something similar.
Anyway, try replacing "classpath:applicationContext.xml" for
"WEB-INF/applicationContext.xml". I'm not sure if this classpath param works
there.

Regards,


Leandro.

2009/4/6 Leandro Féres <le...@gmail.com>

> You must tell where's your spring context (applicationContext.xml).
> Try this:
>
> <listener>
>
> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
> </listener>
> <context-param>
>     <param-name>contextConfigLocation</param-name>
>     <param-value>WEB-INF/applicationContext.xml</param-value>
> </context-param>
>
> Regards,
>
>
> Leandro.
>
>
> 2009/4/6 HHB <hu...@yahoo.ca>
>
> Hey,
>> I'm trying to integrate Spring 2.5 into our Wicket
>> application, I did the following:
>>
>> web.xml:
>>    <context-param>
>>        <param-name>contextConfigLocation</param-name>
>>        <param-value>classpath:applicationContext.xml</param-value>
>>    </context-param>
>>    <listener>
>>        <listener-class>org.springframework.web.
>> context.ContextLoaderListener</listener-class>
>>    </listener>
>>    <filter>
>>        <filter-name>OpenSessionInViewFilter</filter-name>
>>        <filter-class>org.springframework.orm.hibernate3.
>> support.OpenSessionInViewFilter</filter-class>
>>    </filter>
>>
>>    <filter>
>>        <filter-name>WicketFilter</filter-name>
>>        <filter-class>org.apache.wicket.
>> protocol.http.WicketFilter</filter-class>
>>        <init-param>
>>            <param-name>applicationFactoryClassName</param-name>
>>            <param-value>org.apache.wicket.spring.
>> SpringWebApplicationFactory</param-value>
>>        </init-param>
>>    </filter>
>>    <filter>
>>        <filter-name>WicketFilter</filter-name>
>>        <filter-class>org.apache.wicket.
>> protocol.http.WicketFilter</filter-class>
>>        <init-param>
>>            <param-name>applicationFactoryClassName</param-name>
>>            <param-value>org.apache.wicket.spring.
>> SpringWebApplicationFactory</param-value>
>>        </init-param>
>>    </filter>
>>
>> applicationContext.xml:
>>
>>    <bean id="wicketApplication" class="domain.WicketApplication"/>
>>
>>
>> pom.xml:
>>
>>        <dependency>
>>            <groupId>org.springframework</groupId>
>>            <artifactId>spring</artifactId>
>>            <version>2.5.6</version>
>>        </dependency>
>>
>>        <dependency>
>>            <groupId>org.apache.wicket</groupId>
>>            <artifactId>wicket-spring</artifactId>
>>            <version>1.3.5</version>
>>        </dependency>
>>        <dependency>
>>            <groupId>org.apache.wicket</groupId>
>>            <artifactId>wicket-spring-annot</artifactId>
>>            <version>1.3.5</version>
>>        </dependency>
>>
>> WicketApplication:
>>
>>   @Override
>>    protected void init() {
>>        super.init();
>>        addComponentInstantiationListener
>> (new SpringComponentInjector(this));
>>    }
>>
>> But when trying:
>> mvn test
>> I got the following exception:
>> ------------------------------------
>> -------------------------------------------
>> Test set: TestSuite
>> ------------------------------------
>> -------------------------------------------
>> Tests run: 2, Failures: 1, Errors: 0,
>> Skipped: 1, Time elapsed: 0.498 sec <<< FAILURE!
>> init(domain.TestHomePage)  Time elapsed: 0 sec  <<< FAILURE!
>> java.lang.IllegalStateException:
>> No WebApplicationContext found: no ContextLoaderListener registered?
>>        at org.springframework.web.context.support.
>> WebApplicationContextUtils.
>> getRequiredWebApplicationContext(WebApplicationContextUtils.java:70)
>>        at org.apache.wicket.spring.
>> injection.annot.SpringComponentInjector.
>> <init>(SpringComponentInjector.java:74)
>>
>> Any ideas?
>> Thanks.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>

Re: Spring integration problem

Posted by Leandro Féres <le...@gmail.com>.
You must tell where's your spring context (applicationContext.xml).
Try this:

<listener>

<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>WEB-INF/applicationContext.xml</param-value>
</context-param>

Regards,


Leandro.


2009/4/6 HHB <hu...@yahoo.ca>

> Hey,
> I'm trying to integrate Spring 2.5 into our Wicket
> application, I did the following:
>
> web.xml:
>    <context-param>
>        <param-name>contextConfigLocation</param-name>
>        <param-value>classpath:applicationContext.xml</param-value>
>    </context-param>
>    <listener>
>        <listener-class>org.springframework.web.
> context.ContextLoaderListener</listener-class>
>    </listener>
>    <filter>
>        <filter-name>OpenSessionInViewFilter</filter-name>
>        <filter-class>org.springframework.orm.hibernate3.
> support.OpenSessionInViewFilter</filter-class>
>    </filter>
>
>    <filter>
>        <filter-name>WicketFilter</filter-name>
>        <filter-class>org.apache.wicket.
> protocol.http.WicketFilter</filter-class>
>        <init-param>
>            <param-name>applicationFactoryClassName</param-name>
>            <param-value>org.apache.wicket.spring.
> SpringWebApplicationFactory</param-value>
>        </init-param>
>    </filter>
>    <filter>
>        <filter-name>WicketFilter</filter-name>
>        <filter-class>org.apache.wicket.
> protocol.http.WicketFilter</filter-class>
>        <init-param>
>            <param-name>applicationFactoryClassName</param-name>
>            <param-value>org.apache.wicket.spring.
> SpringWebApplicationFactory</param-value>
>        </init-param>
>    </filter>
>
> applicationContext.xml:
>
>    <bean id="wicketApplication" class="domain.WicketApplication"/>
>
>
> pom.xml:
>
>        <dependency>
>            <groupId>org.springframework</groupId>
>            <artifactId>spring</artifactId>
>            <version>2.5.6</version>
>        </dependency>
>
>        <dependency>
>            <groupId>org.apache.wicket</groupId>
>            <artifactId>wicket-spring</artifactId>
>            <version>1.3.5</version>
>        </dependency>
>        <dependency>
>            <groupId>org.apache.wicket</groupId>
>            <artifactId>wicket-spring-annot</artifactId>
>            <version>1.3.5</version>
>        </dependency>
>
> WicketApplication:
>
>   @Override
>    protected void init() {
>        super.init();
>        addComponentInstantiationListener
> (new SpringComponentInjector(this));
>    }
>
> But when trying:
> mvn test
> I got the following exception:
> ------------------------------------
> -------------------------------------------
> Test set: TestSuite
> ------------------------------------
> -------------------------------------------
> Tests run: 2, Failures: 1, Errors: 0,
> Skipped: 1, Time elapsed: 0.498 sec <<< FAILURE!
> init(domain.TestHomePage)  Time elapsed: 0 sec  <<< FAILURE!
> java.lang.IllegalStateException:
> No WebApplicationContext found: no ContextLoaderListener registered?
>        at org.springframework.web.context.support.
> WebApplicationContextUtils.
> getRequiredWebApplicationContext(WebApplicationContextUtils.java:70)
>        at org.apache.wicket.spring.
> injection.annot.SpringComponentInjector.
> <init>(SpringComponentInjector.java:74)
>
> Any ideas?
> Thanks.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: Spring integration problem

Posted by nino martinez wael <ni...@gmail.com>.
code will then look like this:

		mockery.checking(new Expectations() {
			{
				oneOf(eventRepository).update(with(any(Event.class)));

			}
		});
		tester.clickLink("content:events:0:delete");
		mockery.assertIsSatisfied();

pretty simple yet powerfull :)


2009/4/7 nino martinez wael <ni...@gmail.com>:
> Instead of using a test stub, i'd use jmock or some similar mock
> framework and get a little more control :)
>
> 2009/4/6 Olivier Michallat <om...@gmail.com>:
>> The problem is that your unit tests run out of the web container, you
>> can't rely on a servlet context listener to load the Spring context in
>> this situation.
>>
>> You need a hook to inject a mock context when testing. This post
>> describes a solution: http://blog.ehour.nl/index.php/archives/21
>>
>>
>> 2009/4/6 HHB <hu...@yahoo.ca>:
>>> Hey,
>>> I'm trying to integrate Spring 2.5 into our Wicket
>>> application, I did the following:
>>>
>>> web.xml:
>>>    <context-param>
>>>        <param-name>contextConfigLocation</param-name>
>>>        <param-value>classpath:applicationContext.xml</param-value>
>>>    </context-param>
>>>    <listener>
>>>        <listener-class>org.springframework.web.
>>> context.ContextLoaderListener</listener-class>
>>>    </listener>
>>>    <filter>
>>>        <filter-name>OpenSessionInViewFilter</filter-name>
>>>        <filter-class>org.springframework.orm.hibernate3.
>>> support.OpenSessionInViewFilter</filter-class>
>>>    </filter>
>>>
>>>    <filter>
>>>        <filter-name>WicketFilter</filter-name>
>>>        <filter-class>org.apache.wicket.
>>> protocol.http.WicketFilter</filter-class>
>>>        <init-param>
>>>            <param-name>applicationFactoryClassName</param-name>
>>>            <param-value>org.apache.wicket.spring.
>>> SpringWebApplicationFactory</param-value>
>>>        </init-param>
>>>    </filter>
>>>    <filter>
>>>        <filter-name>WicketFilter</filter-name>
>>>        <filter-class>org.apache.wicket.
>>> protocol.http.WicketFilter</filter-class>
>>>        <init-param>
>>>            <param-name>applicationFactoryClassName</param-name>
>>>            <param-value>org.apache.wicket.spring.
>>> SpringWebApplicationFactory</param-value>
>>>        </init-param>
>>>    </filter>
>>>
>>> applicationContext.xml:
>>>
>>>    <bean id="wicketApplication" class="domain.WicketApplication"/>
>>>
>>>
>>> pom.xml:
>>>
>>>        <dependency>
>>>            <groupId>org.springframework</groupId>
>>>            <artifactId>spring</artifactId>
>>>            <version>2.5.6</version>
>>>        </dependency>
>>>
>>>        <dependency>
>>>            <groupId>org.apache.wicket</groupId>
>>>            <artifactId>wicket-spring</artifactId>
>>>            <version>1.3.5</version>
>>>        </dependency>
>>>        <dependency>
>>>            <groupId>org.apache.wicket</groupId>
>>>            <artifactId>wicket-spring-annot</artifactId>
>>>            <version>1.3.5</version>
>>>        </dependency>
>>>
>>> WicketApplication:
>>>
>>>   @Override
>>>    protected void init() {
>>>        super.init();
>>>        addComponentInstantiationListener
>>> (new SpringComponentInjector(this));
>>>    }
>>>
>>> But when trying:
>>> mvn test
>>> I got the following exception:
>>> ------------------------------------
>>> -------------------------------------------
>>> Test set: TestSuite
>>> ------------------------------------
>>> -------------------------------------------
>>> Tests run: 2, Failures: 1, Errors: 0,
>>> Skipped: 1, Time elapsed: 0.498 sec <<< FAILURE!
>>> init(domain.TestHomePage)  Time elapsed: 0 sec  <<< FAILURE!
>>> java.lang.IllegalStateException:
>>> No WebApplicationContext found: no ContextLoaderListener registered?
>>>        at org.springframework.web.context.support.
>>> WebApplicationContextUtils.
>>> getRequiredWebApplicationContext(WebApplicationContextUtils.java:70)
>>>        at org.apache.wicket.spring.
>>> injection.annot.SpringComponentInjector.
>>> <init>(SpringComponentInjector.java:74)
>>>
>>> Any ideas?
>>> Thanks.
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Spring integration problem

Posted by nino martinez wael <ni...@gmail.com>.
Instead of using a test stub, i'd use jmock or some similar mock
framework and get a little more control :)

2009/4/6 Olivier Michallat <om...@gmail.com>:
> The problem is that your unit tests run out of the web container, you
> can't rely on a servlet context listener to load the Spring context in
> this situation.
>
> You need a hook to inject a mock context when testing. This post
> describes a solution: http://blog.ehour.nl/index.php/archives/21
>
>
> 2009/4/6 HHB <hu...@yahoo.ca>:
>> Hey,
>> I'm trying to integrate Spring 2.5 into our Wicket
>> application, I did the following:
>>
>> web.xml:
>>    <context-param>
>>        <param-name>contextConfigLocation</param-name>
>>        <param-value>classpath:applicationContext.xml</param-value>
>>    </context-param>
>>    <listener>
>>        <listener-class>org.springframework.web.
>> context.ContextLoaderListener</listener-class>
>>    </listener>
>>    <filter>
>>        <filter-name>OpenSessionInViewFilter</filter-name>
>>        <filter-class>org.springframework.orm.hibernate3.
>> support.OpenSessionInViewFilter</filter-class>
>>    </filter>
>>
>>    <filter>
>>        <filter-name>WicketFilter</filter-name>
>>        <filter-class>org.apache.wicket.
>> protocol.http.WicketFilter</filter-class>
>>        <init-param>
>>            <param-name>applicationFactoryClassName</param-name>
>>            <param-value>org.apache.wicket.spring.
>> SpringWebApplicationFactory</param-value>
>>        </init-param>
>>    </filter>
>>    <filter>
>>        <filter-name>WicketFilter</filter-name>
>>        <filter-class>org.apache.wicket.
>> protocol.http.WicketFilter</filter-class>
>>        <init-param>
>>            <param-name>applicationFactoryClassName</param-name>
>>            <param-value>org.apache.wicket.spring.
>> SpringWebApplicationFactory</param-value>
>>        </init-param>
>>    </filter>
>>
>> applicationContext.xml:
>>
>>    <bean id="wicketApplication" class="domain.WicketApplication"/>
>>
>>
>> pom.xml:
>>
>>        <dependency>
>>            <groupId>org.springframework</groupId>
>>            <artifactId>spring</artifactId>
>>            <version>2.5.6</version>
>>        </dependency>
>>
>>        <dependency>
>>            <groupId>org.apache.wicket</groupId>
>>            <artifactId>wicket-spring</artifactId>
>>            <version>1.3.5</version>
>>        </dependency>
>>        <dependency>
>>            <groupId>org.apache.wicket</groupId>
>>            <artifactId>wicket-spring-annot</artifactId>
>>            <version>1.3.5</version>
>>        </dependency>
>>
>> WicketApplication:
>>
>>   @Override
>>    protected void init() {
>>        super.init();
>>        addComponentInstantiationListener
>> (new SpringComponentInjector(this));
>>    }
>>
>> But when trying:
>> mvn test
>> I got the following exception:
>> ------------------------------------
>> -------------------------------------------
>> Test set: TestSuite
>> ------------------------------------
>> -------------------------------------------
>> Tests run: 2, Failures: 1, Errors: 0,
>> Skipped: 1, Time elapsed: 0.498 sec <<< FAILURE!
>> init(domain.TestHomePage)  Time elapsed: 0 sec  <<< FAILURE!
>> java.lang.IllegalStateException:
>> No WebApplicationContext found: no ContextLoaderListener registered?
>>        at org.springframework.web.context.support.
>> WebApplicationContextUtils.
>> getRequiredWebApplicationContext(WebApplicationContextUtils.java:70)
>>        at org.apache.wicket.spring.
>> injection.annot.SpringComponentInjector.
>> <init>(SpringComponentInjector.java:74)
>>
>> Any ideas?
>> Thanks.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Spring integration problem

Posted by Olivier Michallat <om...@gmail.com>.
The problem is that your unit tests run out of the web container, you
can't rely on a servlet context listener to load the Spring context in
this situation.

You need a hook to inject a mock context when testing. This post
describes a solution: http://blog.ehour.nl/index.php/archives/21


2009/4/6 HHB <hu...@yahoo.ca>:
> Hey,
> I'm trying to integrate Spring 2.5 into our Wicket
> application, I did the following:
>
> web.xml:
>    <context-param>
>        <param-name>contextConfigLocation</param-name>
>        <param-value>classpath:applicationContext.xml</param-value>
>    </context-param>
>    <listener>
>        <listener-class>org.springframework.web.
> context.ContextLoaderListener</listener-class>
>    </listener>
>    <filter>
>        <filter-name>OpenSessionInViewFilter</filter-name>
>        <filter-class>org.springframework.orm.hibernate3.
> support.OpenSessionInViewFilter</filter-class>
>    </filter>
>
>    <filter>
>        <filter-name>WicketFilter</filter-name>
>        <filter-class>org.apache.wicket.
> protocol.http.WicketFilter</filter-class>
>        <init-param>
>            <param-name>applicationFactoryClassName</param-name>
>            <param-value>org.apache.wicket.spring.
> SpringWebApplicationFactory</param-value>
>        </init-param>
>    </filter>
>    <filter>
>        <filter-name>WicketFilter</filter-name>
>        <filter-class>org.apache.wicket.
> protocol.http.WicketFilter</filter-class>
>        <init-param>
>            <param-name>applicationFactoryClassName</param-name>
>            <param-value>org.apache.wicket.spring.
> SpringWebApplicationFactory</param-value>
>        </init-param>
>    </filter>
>
> applicationContext.xml:
>
>    <bean id="wicketApplication" class="domain.WicketApplication"/>
>
>
> pom.xml:
>
>        <dependency>
>            <groupId>org.springframework</groupId>
>            <artifactId>spring</artifactId>
>            <version>2.5.6</version>
>        </dependency>
>
>        <dependency>
>            <groupId>org.apache.wicket</groupId>
>            <artifactId>wicket-spring</artifactId>
>            <version>1.3.5</version>
>        </dependency>
>        <dependency>
>            <groupId>org.apache.wicket</groupId>
>            <artifactId>wicket-spring-annot</artifactId>
>            <version>1.3.5</version>
>        </dependency>
>
> WicketApplication:
>
>   @Override
>    protected void init() {
>        super.init();
>        addComponentInstantiationListener
> (new SpringComponentInjector(this));
>    }
>
> But when trying:
> mvn test
> I got the following exception:
> ------------------------------------
> -------------------------------------------
> Test set: TestSuite
> ------------------------------------
> -------------------------------------------
> Tests run: 2, Failures: 1, Errors: 0,
> Skipped: 1, Time elapsed: 0.498 sec <<< FAILURE!
> init(domain.TestHomePage)  Time elapsed: 0 sec  <<< FAILURE!
> java.lang.IllegalStateException:
> No WebApplicationContext found: no ContextLoaderListener registered?
>        at org.springframework.web.context.support.
> WebApplicationContextUtils.
> getRequiredWebApplicationContext(WebApplicationContextUtils.java:70)
>        at org.apache.wicket.spring.
> injection.annot.SpringComponentInjector.
> <init>(SpringComponentInjector.java:74)
>
> Any ideas?
> Thanks.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org