But then I need an injector in that context...I suppose the suggestion is to inject the injector into MyPanel?
@Inject Injector injector; It looks funny, but probably cleaner than pulling the services. On Mon, Jun 15, 2009 at 3:56 PM, Igor Vaynberg <igor.vaynb...@gmail.com>wrote: > why not simply have MyThread injected by guice... > > Thread t=injector.getinstance(MyThread.class); > > -igor > > On Mon, Jun 15, 2009 at 1:34 PM, Aaron Dixon<atdi...@gmail.com> wrote: > > I'm using Guice component injection with Wicket and it works grreat: > > > > MyPanel { > > > > @Inject > > private MyService myService; > > > > MyPanel(String id) { > > super(id); > > myService.doSomething(); > > } > > > > //... > > } > > > > HOWEVER, now I'm tryin' to send my service to a thread that I create, > like > > so: > > > > MyPanel { > > > > @Inject > > private MyService myService; > > > > MyPanel(String id) { > > super(id); > > myService.doSomething(); > > } > > > > void onEvent() { > > Thread t = new MyThread(myService) { > > > > // ...uses passed-in myService in run() method > > > > } > > } > > } > > > > BUT of course Guice is proxying my service and it doesn't expect it in a > > non-Wicket thread. At runtime I get: > > > > org.apache.wicket.WicketRuntimeException: There is no application > attached > > to current thread pool-1-thread-1 > > at org.apache.wicket.Application.get(Application.java:166) > > at > > > org.apache.wicket.guice.GuiceProxyTargetLocator.locateProxyTarget(GuiceProxyTargetLocator.java:48) > > at > > > org.apache.wicket.proxy.LazyInitProxyFactory$CGLibInterceptor.intercept(LazyInitProxyFactory.java:316) > > at > > > WICKET_com.conducive.data.dao.MyService$$EnhancerByCGLIB$$6fc4e9bf.getManagedSession(<generated>) > > at > > > com.conducive.ui.userPages.monitor.result.MyThread.run(MonitorRetrieverTask.java:33) > > at > > java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441) > > at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) > > at java.util.concurrent.FutureTask.run(FutureTask.java:138) > > at > > > java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) > > at > > > java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) > > at java.lang.Thread.run(Thread.java:619) > > > > This makes sense to me why this is happening (Guice/Wicket need a Wicket > > context to deserialize the instance). > > > > SO, I guess this means I have to pull-and-set those services on the > thread > > myself...unless there is a better way? > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > For additional commands, e-mail: users-h...@wicket.apache.org > >