当我尝试登录我的Web应用程序时遇到问题,用户还可以,因为我可以看到HQL找到数据时的跟踪,所以堆栈跟踪更加明显如下:
对于应用程序,我使用这些库:
Tomcat 7.0
abr. 30, 2013 4:25:14 PM com.sun.faces.application.view.FaceletViewHandlingStrategy handleRenderException
SEVERE: Error Rendering View[/pages/protected/index.xhtml]
java.lang.StringIndexOutOfBoundsException: String index out of range: 0
at java.lang.String.charAt(Unknown Source)
at com.sun.faces.application.view.MultiViewHandler.getResourceURL(MultiViewHandler.java:332)
at org.primefaces.renderkit.CoreRenderer.getResourceURL(CoreRenderer.java:76)
at org.primefaces.renderkit.OutcomeTargetRenderer.getTargetURL(OutcomeTargetRenderer.java:91)
at org.primefaces.component.menu.BaseMenuRenderer.encodeMenuItem(BaseMenuRenderer.java:78)
at org.primefaces.component.tieredmenu.TieredMenuRenderer.encodeMenuContent(TieredMenuRenderer.java:104)
at org.primefaces.component.tieredmenu.TieredMenuRenderer.encodeSubmenu(TieredMenuRenderer.java:166)
at org.primefaces.component.tieredmenu.TieredMenuRenderer.encodeMenuContent(TieredMenuRenderer.java:123)
at org.primefaces.component.tieredmenu.TieredMenuRenderer.encodeMenu(TieredMenuRenderer.java:77)
at org.primefaces.component.menubar.MenubarRenderer.encodeMarkup(MenubarRenderer.java:52)
at org.primefaces.component.menu.BaseMenuRenderer.encodeEnd(BaseMenuRenderer.java:39)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:881)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1786)
at javax.faces.render.Renderer.encodeChildren(Renderer.java:168)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:851)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1779)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1782)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1782)
at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:439)
at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:124)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:120)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:594)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at com.test.ems2.filter.LoginCheckFilter.doFilter(LoginCheckFilter.java:69)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:562)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:395)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:250)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
web.xml文件
<?xml version="1.0"?>
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
<display-name>EMS2App</display-name>
<context-param>
<param-name>primefaces.THEME</param-name>
<param-value>bluesky</param-value>
</context-param>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>/pages/protected/index.xhtml</welcome-file>
</welcome-file-list>
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<filter>
<filter-name>LoginCheckFilter</filter-name>
<filter-class>com.test.ems2.filter.LoginCheckFilter</filter-class>
<init-param>
<param-name>loginActionURI</param-name>
<param-value>/EMS2APP/pages/public/login.xhtml</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>LoginCheckFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter>
<filter-name>AdminPagesFilter</filter-name>
<filter-class>com.test.ems2.filter.AdminPagesFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>AdminPagesFilter</filter-name>
<url-pattern>/pages/protected/admin/*</url-pattern>
</filter-mapping>
<filter>
<filter-name>DefaultUserPagesFilter</filter-name>
<filter-class>com.test.ems2.filter.DefaultUserPagesFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>DefaultUserPagesFilter</filter-name>
<url-pattern>/pages/protected/defaultUser/*</url-pattern>
</filter-mapping>
</web-app>
faces-config.xml文件
<?xml version="1.0"?>
<faces-config xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-facesconfig_2_1.xsd"
version="2.1">
<application>
<resource-bundle>
<base-name>messages</base-name>
<var>bundle</var>
</resource-bundle>
<message-bundle>messages</message-bundle>
</application>
</faces-config>
我的AbstractFilter类
public class AbstractFilter {
public AbstractFilter() {
super();
}
protected void doLogin(ServletRequest request, ServletResponse response, HttpServletRequest req) throws ServletException, IOException {
RequestDispatcher rd = req.getRequestDispatcher("/pages/public/login.xhtml");
rd.forward(request, response);
}
protected void accessDenied(ServletRequest request, ServletResponse response, HttpServletRequest req) throws ServletException, IOException {
RequestDispatcher rd = req.getRequestDispatcher("/pages/public/accessDenied.xhtml");
rd.forward(request, response);
}
}
我的LoginCheckFilter类:
public class LoginCheckFilter extends AbstractFilter implements Filter {
private static List<String> allowedURIs;
public void init(FilterConfig fConfig) throws ServletException {
if(allowedURIs == null){
allowedURIs = new ArrayList<String>();
allowedURIs.add(fConfig.getInitParameter("loginActionURI"));
allowedURIs.add("/EMS2App/javax.faces.resource/main.css.xhtml");
allowedURIs.add("/EMS2App/javax.faces.resource/theme.css.xhtml");
allowedURIs.add("/EMS2App/javax.faces.resource/primefaces.js.xhtml");
allowedURIs.add("/EMS2App/javax.faces.resource/primefaces.css.xhtml");
allowedURIs.add("/EMS2App/javax.faces.resource/jquery/jquery.js.xhtml");
allowedURIs.add("/EMS2App/javax.faces.resource/messages/messages.png.xhtml");
allowedURIs.add("/EMS2App/javax.faces.resource/images/ui-icons_2e83ff_256x240.png.xhtml");
allowedURIs.add("/EMS2App/javax.faces.resource/images/ui-icons_38667f_256x240.png.xhtml");
}
}
public void destroy() {
}
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
HttpServletRequest req = (HttpServletRequest) request;
HttpSession session = req.getSession();
if (session.isNew()) {
doLogin(request, response, req);
return;
}
User user = (User) session.getAttribute("user");
if (user == null && !allowedURIs.contains(req.getRequestURI())) {
System.out.println(req.getRequestURI());
doLogin(request, response, req);
return;
}
chain.doFilter(request, response); //error -> row 69
}
}
文件:/pages/protected/index.xhtml
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core" xmlns:p="http://primefaces.org/ui" >
<h:body>
<ui:composition template="/pages/protected/templates/master.xhtml">
<ui:define name="divMain">
#{bundle.welcomeMessage} :<br/>
</ui:define>
</ui:composition>
</h:body>
</html>
master.xhtml
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui"
xmlns:f="http://java.sun.com/jsf/core">
<h:head>
<title>EMS2</title>
<h:outputStylesheet library="css" name="main.css" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</h:head>
<h:body>
<f:view contentType="text/html; charset=UTF-8" encoding="UTF-8" >
<div id="divTop" style="vertical-align: middle;">
<ui:insert name="divTop">
<ui:include src="top.xhtml" />
</ui:insert>
</div>
<div id="divMain">
<p:growl id="messageGrowl" />
<ui:insert name="divMain" />
</div>
<div id="divLeft">
<ui:insert name="divDown">
<ui:include src="down.xhtml" />
</ui:insert>
</div>
<h:outputScript library="javascript" name="jscodes.js" />
</f:view>
</h:body>
</html>
down.xhtml
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui">
<h:body>
<ui:composition>
<h:form>
<p>Test test test</p><br />
</h:form>
</ui:composition>
</h:body>
</html>
top.xhtml
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui">
<h:body>
<ui:composition>
<div id="topMessage">
<h1>
<h:form>
<p:menubar>
<p:submenu label="Personnes">
<p:menuitem label="Ajouter Personne" url="#"/>
<p:menuitem label="Miss a jour Personne" url="#"/>
</p:submenu>
<p:submenu label="Absences">
<p:menuitem label="Poser des absences" url="#"/>
<p:menuitem label="Validation des absences" url="#"/>
<p:menuitem label="Gestion de absences" url="#"/>
</p:submenu>
<p:submenu label="Pointage">
<p:menuitem label="Saisie des temps" url="#"/>
<p:menuitem label="Validation des temps" url="#"/>
<p:menuitem label="Extration des temps Vers PowerMax" url="#"/>
</p:submenu>
<p:submenu label="Projet/Activite">
<p:submenu label="Activite">
<p:menuitem label="Creer Activite" url="/pages/protected/admin/dialogs/creerActivite.xhtml" />
<p:menuitem label="Miss a jour l'Activite" url="/pages/protected/admin/dialogs/missAJourActivite.xhtml" />
</p:submenu>
<p:submenu label="Projet">
<p:menuitem label="Creer projet" url="/pages/protected/admin/dialogs/creerProjet.xhtml" />
<p:menuitem label="Miss a jour projet" url="/pages/protected/admin/dialogs/missAJourProjet.xhtml" />
</p:submenu>
</p:submenu>
<p:submenu label="Rapport">
<p:menuitem label="Statistique projet" url="#"/>
<p:menuitem label="Statistique diverses" url="#"/>
</p:submenu>
</p:menubar>
#{bundle.loginWelcomeMessage}: #{userMB.user.name} | <p:commandButton value="#{bundle.logOut}" action="#{userMB.logOut()}" ajax="false" style="font-size: 20px;" />
</h:form>
</h1>
</div>
</ui:composition>
</h:body>
</html>