이제는 여러 번 시도해 보았습니다. 당신이 나를 도울 수 있기를 바랍니다.AFTER_FILTER_EVENT 유형의 이벤트를 처리하는 중 예외가 발생했습니다.
JSF Mojarra 2.1, Primefaces 3.1을 사용하는 웹 프로젝트가 있습니다. 이 프로젝트는 인증을 처리하기 위해 Spring Security를 사용합니다.
프로젝트는 Glassfish 3.1.1에서 실행되므로 제공되는 JSF 버전을 사용하고 있습니다.
문제는 내가 로그온 한 후 main.xhtml 페이지를 렌더링해야 할 때 다음과 같은 예외가 발생한다는 것입니다.
java.lang.RuntimeException: WEB5001: Exception during processing of event of type AFTER_FILTER_EVENT for web module StandardEngine[glassfish-web].StandardHost[server].StandardContext[/sormAdmin2]
at com.sun.web.server.J2EEInstanceListener.handleAfterEvent(J2EEInstanceListener.java:344)
at com.sun.web.server.J2EEInstanceListener.instanceEvent(J2EEInstanceListener.java:112)
at org.apache.catalina.util.InstanceSupport.fireInstanceEvent(InstanceSupport.java:314)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:273)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:98)
at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:91)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:162)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:330)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:174)
at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:828)
at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:725)
at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1019)
at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
at java.lang.Thread.run(Thread.java:662)
의해 발생 : com.sun.web.server.J2EEInstanceListener에서 org.glassfish.api.invocation.InvocationManagerImpl.postInvoke (InvocationManagerImpl.java:190) 에서 org.glassfish.api.invocation.InvocationException .handleAfterEvent (J2EEInstanceListener.java:339) ... 로그인 페이지에서
더 28 :
$<h:panelGrid columns="2" cellpadding="5" styleClass="messageGrid">
<h:outputLabel for="username" value="Username:" />
<p:inputText value="#{loginBean.username}" id="username"
required="true" label="username" />
<h:outputLabel for="password" value="Password:" />
<p:password value="#{loginBean.password}" id="password"
required="true" label="password" feedback="false" />
<f:facet name="footer">
<p:commandButton value="Login"
action="#{loginBean.login}" />
</f:facet>
<h:messages></h:messages>
</h:panelGrid>
LoginBean :
package this.is.my.mb;
import java.io.Serializable;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collection;
import javax.annotation.PostConstruct;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;
import javax.servlet.http.HttpSession;
import this.is.my.ejb.beans.session.remote.UserRemote;
import this.is.my.ejb.ejb.vo.User;
import this.is.my.utils.EJBHandler;
import org.apache.commons.lang.NotImplementedException;
import org.primefaces.component.layout.LayoutUnit;
import org.primefaces.context.RequestContext;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.context.SecurityContextHolder;
@ManagedBean(name = "loginBean", eager=true)
@SessionScoped
public class LoginBean implements Serializable {
@PostConstruct
public void init() {
//checkUser();
}
/**
*
*/
private static final long serialVersionUID = 1L;
private UserRemote userRemote;
private User user;
private String username;
private String password;
public LoginBean() {
layoutCenter = new LayoutUnit();
layoutLeft = new LayoutUnit();
layoutRight = new LayoutUnit();
//layoutLogin = new LayoutUnit();
}
public String login() {
FacesMessage msg = new FacesMessage(FacesMessage.SEVERITY_INFO, "Welcome", getUsername());
boolean loggedIn = true;
String redirectTo = "/user/main.xhtml?faces-redirect=true";
try {
EJBHandler ejbHandler2 = new EJBHandler();
userRemote = ejbHandler2.getUserRemote();
if(userRemote != null)
user = userRemote.sjekkBruker(getUsername(), getPassword());
if(user != null) {
System.out.println("User != null: accessLevel: " + user.getAccessLevel());
Authentication rfesult = new Authentication() {
@Override
public String getName() {
// TODO Auto-generated method stub
return username;
}
@Override
public boolean isAuthenticated() {
return true;
}
@Override
public Object getPrincipal() {
throw new NotImplementedException();
}
@Override
public Object getDetails() {
throw new NotImplementedException();
}
@Override
public Collection<GrantedAuthority> getAuthorities() {
GrantedAuthority ga = new GrantedAuthority() {
private static final long serialVersionUID = 1132123132132L;
@Override
public String getAuthority() {
return "ROLE_USER";
}
};
GrantedAuthority g2a = new GrantedAuthority() {
private static final long serialVersionUID = 1132123132132L;
@Override
public String getAuthority() {
return "ROLE_STATS";
}
};
GrantedAuthority g3a = new GrantedAuthority() {
private static final long serialVersionUID = 1132123132132L;
@Override
public String getAuthority() {
return "ROLE_ADMIN";
}
};
Collection<GrantedAuthority> list = new ArrayList<GrantedAuthority>();
if(user.getAccessLevel() == 3 || user.getAccessLevel() == 1) {
list.add(ga);
}
if(user.getAccessLevel() == 2 || user.getAccessLevel() == 1) {
list.add(g2a);
}
if(user.getAccessLevel() == 1) {
list.add(g3a);
}
return list;
}
@Override
public Object getCredentials() {
throw new NotImplementedException();
}
@Override
public void setAuthenticated(boolean arg0) throws IllegalArgumentException {
throw new NotImplementedException();
}
};
checkUser();
SecurityContextHolder.getContext().setAuthentication(rfesult);
if(user.getAccessLevel() == 2) { // user only has access to statistics
redirectTo = "/stats/getstats.jsf?faces-redirect=true";
}
if(user.getAccessLevel() < 1) {
redirectTo = "/login/login.xhtml?faces-redirect=true";
msg = new FacesMessage(FacesMessage.SEVERITY_WARN, "Login failed", "Wrong username and/or password");
loggedIn = false;
}
} else {
msg = new FacesMessage(FacesMessage.SEVERITY_WARN, "Login failed", "Wrong username and/or password");
loggedIn = false;
redirectTo = null;
System.out.println("User == null");
}
} catch (SQLException e) {
e.printStackTrace();
}
FacesContext.getCurrentInstance().addMessage(null, msg);
RequestContext context = RequestContext.getCurrentInstance();
if(context != null)
context.addCallbackParam("loggedIn", loggedIn);
System.out.println(redirectTo);
return redirectTo;
}
public User getUser() {
return user;
}
public void setUser(User user) {
this.user = user;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getUsername() {
checkUser();
return username;}}
내 web.xml의 :
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="WebApp_ID" version="2.5">
<display-name>JavaServerFaces</display-name>
<!-- Change to "Production" when you are ready to deploy -->
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<!-- for EL 2.2-->
<context-param>
<param-name>com.sun.faces.expressionFactory</param-name>
<param-value>com.sun.el.ExpressionFactoryImpl</param-value>
</context-param>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/applicationContext*.xml
</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<listener>
<listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
</listener>
<listener>
<listener-class>org.springframework.security.web.session.HttpSessionEventPublisher</listener-class>
</listener>
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<error-page>
<exception-type>javax.faces.application.ViewExpiredException</exception-type>
<location>/login.xhtml</location>
</error-page>
<session-config>
<session-timeout>300</session-timeout>
</session-config>
<context-param>
<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
<param-value>.xhtml</param-value>
</context-param>
<!-- Welcome page -->
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<!-- JSF mapping -->
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<!-- Map these files with JSF -->
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.faces</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
<context-param>
<param-name>primefaces.THEME</param-name>
<param-value>redmond</param-value>
</context-param>
<mime-mapping>
<extension>png</extension>
<mime-type>image/png</mime-type>
</mime-mapping>
</web-app>
스택 트레이스가 불완전하다. 대답은 가장 안쪽 예외 (전체 스택 트레이스의 맨 아래쪽 예외)에있는 동안 가장 바깥 쪽 예외 만 표시했습니다. 질문을 편집하여 전체 스택 추적을 포함하십시오. (InvocationManagerImpl.java:190) org.glassfish.api.invocation.InvocationManagerImpl.postInvoke에서 org.glassfish.api.invocation.InvocationException \t : – BalusC
이에 의한 내가 글래스 피시 로그에서 찾을 수있는 유일한 스택 트레이스 ... 입니다 com.sun.web.server.J2EEInstanceListener.handleAfterEvent (J2EEInstanceListener.java:339) \t에서 \t ... 더보기 (28) 28 개 ...하지만 내가 그들에 도달 할 수 .. – baron5
이 문제는 지금 해결 되었습니까? 간헐적으로 매우 유사한 오류가 나타납니다. @Jonathan의 제안에 따라 이미 솔루션을 구현했으며 여전히이 문제를보고 있습니다. 감사! –