You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Ned Collyer <ne...@gmail.com> on 2008/02/11 07:17:23 UTC

WicketTester gives No WebApplicationContext found: no ContextLoaderListener registered

Hi,

In one of my pages, i need to invoke a method from my web application.

My application class is as follows

public class MyApp extends WebApplication {
  private Thing thing;

  public void init() {
        // Attach the component injector - ie, enable spring for this
application.
        addComponentInstantiationListener(new
SpringComponentInjector(this));

    thing = new Thing();
  }

  public Thing getThing() {
    return thing;
  }
}


I use getThing() somewhere in one of my pages, and this means i need to make
a call like
((MyApp)Application.get()).getThing()


The problem arises when using the WicketTester.

If I use the MockApplication in the default constructor, then rendering the
page cannot occur.
tester = new WicketTester();
gives me a class cast exception when rendering the page.


If I pass my app to the WicketTester, i get 

No WebApplicationContext found: no ContextLoaderListener registered.

How can I register a context loader listener?


I've had a look at
http://people.apache.org/~tobrien/wicket/apidocs/org/apache/wicket/spring/injection/annot/test/AnnotApplicationContextMock.html

But adding the class has not helped.

eg,
AnnotApplicationContextMock appctx = new AnnotApplicationContextMock();
MyApp app = new MyApp();
tester = new WicketTester(app);

causes the same problem.

Any ideas would be appreciated (i know igor will answer in about 30 seconds
:))
-- 
View this message in context: http://www.nabble.com/WicketTester-gives-No-WebApplicationContext-found%3A-no-ContextLoaderListener-registered-tp15406122p15406122.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: WicketTester gives No WebApplicationContext found: no ContextLoaderListener registered

Posted by Nino Saturnino Martinez Vazquez Wael <ni...@jayway.dk>.
btw, I went that way too (moving to an method)..

Ned Collyer wrote:
> 4 minutes?  You're getting slower!
>
> That kind of worked. I'm not fond of having to reinitialise all the things I
> set inside init, so i've moved this method out to a protected void
> initSpring().
>
> Thanks for your help.
>
> Rgds
>
> Ned
>
>
> igor.vaynberg wrote:
>   
>> try the Spring page on the wiki, it shows how to mock spring for
>> wickettester
>>
>> -igor
>>
>>     
>
>   

-- 
Nino Martinez Wael
Java Specialist @ Jayway DK
http://www.jayway.dk
+45 2936 7684


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


Re: WicketTester gives No WebApplicationContext found: no ContextLoaderListener registered

Posted by Ned Collyer <ne...@gmail.com>.
4 minutes?  You're getting slower!

That kind of worked. I'm not fond of having to reinitialise all the things I
set inside init, so i've moved this method out to a protected void
initSpring().

Thanks for your help.

Rgds

Ned


igor.vaynberg wrote:
> 
> try the Spring page on the wiki, it shows how to mock spring for
> wickettester
> 
> -igor
> 

-- 
View this message in context: http://www.nabble.com/WicketTester-gives-No-WebApplicationContext-found%3A-no-ContextLoaderListener-registered-tp15406122p15406589.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: WicketTester gives No WebApplicationContext found: no ContextLoaderListener registered

Posted by Igor Vaynberg <ig...@gmail.com>.
try the Spring page on the wiki, it shows how to mock spring for wickettester

-igor


On Feb 10, 2008 10:17 PM, Ned Collyer <ne...@gmail.com> wrote:
>
> Hi,
>
> In one of my pages, i need to invoke a method from my web application.
>
> My application class is as follows
>
> public class MyApp extends WebApplication {
>   private Thing thing;
>
>   public void init() {
>         // Attach the component injector - ie, enable spring for this
> application.
>         addComponentInstantiationListener(new
> SpringComponentInjector(this));
>
>     thing = new Thing();
>   }
>
>   public Thing getThing() {
>     return thing;
>   }
> }
>
>
> I use getThing() somewhere in one of my pages, and this means i need to make
> a call like
> ((MyApp)Application.get()).getThing()
>
>
> The problem arises when using the WicketTester.
>
> If I use the MockApplication in the default constructor, then rendering the
> page cannot occur.
> tester = new WicketTester();
> gives me a class cast exception when rendering the page.
>
>
> If I pass my app to the WicketTester, i get
>
> No WebApplicationContext found: no ContextLoaderListener registered.
>
> How can I register a context loader listener?
>
>
> I've had a look at
> http://people.apache.org/~tobrien/wicket/apidocs/org/apache/wicket/spring/injection/annot/test/AnnotApplicationContextMock.html
>
> But adding the class has not helped.
>
> eg,
> AnnotApplicationContextMock appctx = new AnnotApplicationContextMock();
> MyApp app = new MyApp();
> tester = new WicketTester(app);
>
> causes the same problem.
>
> Any ideas would be appreciated (i know igor will answer in about 30 seconds
> :))
> --
> View this message in context: http://www.nabble.com/WicketTester-gives-No-WebApplicationContext-found%3A-no-ContextLoaderListener-registered-tp15406122p15406122.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
>
>

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