我在下面的代码中遇到非法状态异常
PropertyDao propertyDao = PropertyDao.getInstance();
public class JMySpellCheckerServlet extends TinyMCESpellCheckerServlet {
private static final long serialVersionUID = -2460237918745522935L;
private SpellChecker loadSpellChecker(final String lang) throws SpellCheckException
{
PropertyDao propertyDao = PropertyDao.getInstance();
McsProperty messageLangProperty =
propertyDao.getMcsProperty(PropertyDao.PROPERTY_MESSAGE_LANG);
}
}
答案 0 :(得分:0)
显然@Application上下文尚不可用......你可以像这样明确地设置它(在调用PropertyDao.getInstance之前):
if ( !Contexts.isApplicationContextActive() ) {
Lifecycle.setupApplication();
}