java + Wicket +休眠+ Spring
@Async方法中的Web会话不可用。
我在页面中有一个按钮,当用户单击该按钮时,它会调用“ importContactInBackground”方法。
<task:annotation-driven executor="commonTaskExecutor"/>
<task:executor id="commonTaskExecutor" pool-size="5-10" queue-capacity="20"/>
@Async
public void importContactInBackground(File file)
{
importService.import(file);
CustomSession customSession = (CustomSession)Session.get();//throws exception
LOGGER.info("Contacts are imported by {}", customSession.getUsername());
}
org.apache.wicket.WicketRuntimeException: There is no application attached to current thread commonTaskExecutor-2
at org.apache.wicket.Application.get(Application.java:235)
at org.apache.wicket.Session.get(Session.java:175)