Hi,

I am not sure how this @Scheduled works but it seems it uses different
threads for each run.
Here are some options:
1) use ComponentRenderer (
http://www.wicket-library.com/wicket-examples-6.0.x/mailtemplate/)
2) get the application by name - Application#get(String). The name is the
name of WicketFilter you specify in web.xml
3) Create WicketTester once and pass it to your own Thread that run every N
secs/mins/hours/... I.e. do the scheduling yourself
4) I guess the library providing @Scheduled also provides some kind of
ThreadFactory where you can set/unset the application instance for each run

Martin Grigorov
Wicket Training and Consulting


On Sat, Apr 19, 2014 at 3:46 PM, Mathias Nilsson <
[email protected]> wrote:

> Hi,
>
> I', using Wicket to send html mail and I know that this has been asked many
> times but I can't reuse my wicket tester. I have a cron job
> @org.nnsoft.guice.guartz.Scheduled( cronExpression = "0/5 * * * * ?" ) that
> executes and checks for mail.
>
>
> @Inject MyApplication application
>
> WicketTester tester = new WicketTester( application ) will fail.
> There is no application attached to current thread main
>
> If I create a WicketTester and want to reuse it in the next cron job I get
> the same exception. I need to do this every time in my CronJob and it seems
> to expensive.
>
> Injector injector = Guice.createInjector(new MediaModule());
> WicketTester tester = new WicketTester( new TestApplication(injector) );
> ....use the tester
>
> Do I really need to do this every time the CronJob executes?
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/WicketTester-in-Thread-tp4665477.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>

Reply via email to