我有一個調用通過標籤的動作dccr.jsp文件:java.lang.StackOverflowError的從Struts2的行動標籤調用操作時
<s:action name="query-privilege" executeResult="false" var="privilege">
<s:param name="moduleid">9</s:param>
<s:param name="privilege">v</s:param>
<s:param name="pagename">dccr</s:param>
</s:action>
我用這個動作來查詢用戶之間模塊權限,就像這樣:
<s:if test="%{#privilege.allowable == false}">
//do something
</s:if>
這裏是我的行動支持Class:
private String pagename;
private String moduleid;
private boolean allowable;
private String privilege;
private final UsertypeModuleDAO umodDao = (UsertypeModuleDAO) ServletActionContext.getServletContext().getAttribute("usermoduleDAO");
//loggers, session properties etc.
@Action(value = "/query-privilege", results = {
@Result(name = "SUCCESSdccr", location = "/dccr.jsp"),
@Result(name = "ERROR", location = "../error/messages.jsp")
})
@Override
public String execute() {
try {
char p = privilege.charAt(0);
int i = Integer.parseInt(moduleid);
allowable = queryPrivilege(i, p);
logger.info(privilege+", "+moduleid+", "+ut.getUsertypeid()+", "+allowable);
return SUCCESS + pagename;
} catch (Exception e) {
if (emps != null) {
logger.fatal("(" + emps.getIdnumber() + "):" + e.getLocalizedMessage(), e);
} else {
logger.fatal(e.getLocalizedMessage(), e);
}
e.printStackTrace();
addActionError(e.getLocalizedMessage());
return ERROR;
}
}
private boolean queryPrivilege(int moduleid, char privilege) {
DetachedCriteria criteria = DetachedCriteria.forClass(UsertypeModule.class);
criteria.createCriteria("usertypes", "ut").setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);
criteria.createCriteria("modules", "m").setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);
criteria.add(Restrictions.eq("m.moduleid", moduleid));
criteria.add(Restrictions.eq("ut.usertypeid", ut.getUsertypeid()));
UsertypeModule um = umodDao.getPrivilege(criteria);
logger.info(um.getModulename());
boolean p = false;
switch (privilege) {
case 'v': p = um.isViewable();
break;
case 'e': p = um.isEditable();
break;
case 'c': p = um.isCreateable();
break;
case 'd': p = um.isDeleteable();
break;
}
return p;
}
//getters and setters
這裏是我在我的數據訪問代碼Objec T: 'umodDao':
@SuppressWarnings("unchecked")
public UsertypeModule getPrivilege(DetachedCriteria dc){
Criteria criteria = dc.getExecutableCriteria(session);
criteria.setMaxResults(1);
return (UsertypeModule) criteria.uniqueResult();
}
當我跑我的項目並導航到dccr.jsp我得到這個錯誤:
May 31, 2011 8:34:52 AM org.apache.catalina.core.ApplicationDispatcher invoke
SEVERE: Servlet.service() for servlet jsp threw exception
java.lang.StackOverflowError
at java.util.HashMap.get(HashMap.java:300)
at java.lang.Package.getSystemPackage(Package.java:491)
at java.lang.Package.getPackage(Package.java:313)
at java.lang.Class.getPackage(Class.java:698)
at com.googlecode.s2hibernate.struts2.plugin.interceptors.SessionTransactionInjectorInterceptor.isCandidadeClass(SessionTransactionInjectorInterceptor.java:313)
at com.googlecode.s2hibernate.struts2.plugin.interceptors.SessionTransactionInjectorInterceptor.injectHibernateCoreSession(SessionTransactionInjectorInterceptor.java:340)
at com.googlecode.s2hibernate.struts2.plugin.interceptors.SessionTransactionInjectorInterceptor.injectHibernateCoreSession(SessionTransactionInjectorInterceptor.java:361)
呀,進出口使用FHP(全Hibernate插件1.4GA)和我Servlet容器在NetBeans 7.0上是Tomcat 7.0。我一直在徘徊好幾天,但在每次嘗試時都一直失敗,stacktraces指向FHP插件的SessionTransactionInjectorInterceptor.injectHibernateCoreSession方法。請幫助我,或者只是說一些可能會引起一些問題的事情。
我有一個懷疑,這個問題不得不做一些與我的tomcat的政策,因爲當我升級到FHP 2.2GA我還是用的StackOverflowError遇到然而
java.security.AccessController.doPrivileged(Native Method
)
已經包括在堆棧跟蹤中。但這只是一個懷疑。由於這個問題,我無法繼續工作,因此我正在考慮將項目恢復到最新的正在進行的修訂中,以便繼續我的工作,並最終在我能夠修復這個持久性問題時進行修改。
在於,在完整的堆棧跟蹤? – 2011-05-31 01:39:02
是的,最後一行無限重複... – Dean 2011-05-31 07:03:12
看來'SessionTransactionInjectorInterceptor'是問題的根源。我會看看那裏發生了什麼。 – 2011-05-31 11:57:50