简体   繁体   中英

JSF 2.3 - Cannot invoke "javax.faces.context.FacesContext.getAttributes()" because "this.context" is null

The problem is when execute the lines with jsf tags in the jsp file. I execute a normal jsp file and works. Before the error was "Cannot find the Faces Context", but I update the jar of jsf-impl and jsf-api to the last version, and then give me this error. I look for error and the problem should be with the URL pattern matches request URL but matches. This is the error:

6: -->
7: <jsp:root version="2.1" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:jsp="http://java.sun.com/JSP/Page" xmlns:webuijsf="http://www.sun.com/webui/webuijsf">
8:     <jsp:directive.page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"/>
9:     <f:view>
10:         <webuijsf:page id="page1">
11:             <webuijsf:html id="html1">
12:                 <webuijsf:head id="head1">


Stacktrace:] con causa raíz
java.lang.NullPointerException: Cannot invoke "javax.faces.context.FacesContext.getAttributes()" because "this.context" is null
    at javax.faces.webapp.UIComponentClassicTagBase.setJspId(UIComponentClassicTagBase.java:1856)
    at org.apache.jsp.Login.Usuarios_005fLogin_jsp._jspx_meth_f_005fview_005f0(Usuarios_005fLogin_jsp.java:210)
    at org.apache.jsp.Login.Usuarios_005fLogin_jsp._jspService(Usuarios_005fLogin_jsp.java:177)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:764)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:466)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:379)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:327)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:764)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:227)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:197)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
    at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:687)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:360)
    at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:399)
    at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:890)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1787)
    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
    at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
    at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.base/java.lang.Thread.run(Thread.java:833)

Web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd" id="WebApp_ID" version="4.0">
  <display-name>Faccil2.0</display-name>
  <welcome-file-list>
        <welcome-file>/faces/Login/Usuarios_Login.jsp</welcome-file>
        <welcome-file>/faces/Home.jsp</welcome-file>
    </welcome-file-list>
  <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>/faces/*</url-pattern>
  </servlet-mapping>
  <context-param>
    <description>State saving method: 'client' or 'server' (=default). See JSF Specification 2.5.2</description>
    <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
    <param-value>client</param-value>
  </context-param>
  <context-param>
    <param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
    <param-value>resources.application</param-value>
  </context-param>
  <listener>
    <listener-class>com.sun.faces.config.ConfigureListener</listener-class>
  </listener>
</web-app>

faces-config.xml

<?xml version="1.0" encoding="UTF-8"?>
<faces-config
    xmlns="http://xmlns.jcp.org/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-facesconfig_2_3.xsd"
    version="2.3">
    <managed-bean>
        <managed-bean-name>SessionBean1</managed-bean-name>
        <managed-bean-class>faccilvisualweb.SessionBean1</managed-bean-class>
        <managed-bean-scope>session</managed-bean-scope>
    </managed-bean>
    <managed-bean>
        <managed-bean-name>ApplicationBean1</managed-bean-name>
        <managed-bean-class>faccilvisualweb.ApplicationBean1</managed-bean-class>
        <managed-bean-scope>application</managed-bean-scope>
    </managed-bean>
    <managed-bean>
        <managed-bean-name>RequestBean1</managed-bean-name>
        <managed-bean-class>faccilvisualweb.RequestBean1</managed-bean-class>
        <managed-bean-scope>request</managed-bean-scope>
    </managed-bean>
    <managed-bean>
        <managed-bean-name>Login$Usuarios_Login</managed-bean-name>
        <managed-bean-class>faccilvisualweb.Login.Usuarios_Login</managed-bean-class>
        <managed-bean-scope>request</managed-bean-scope>
    </managed-bean>
    <managed-bean>
        <managed-bean-name>Configuracion$Categorias$Categorias_Agregar_tabla</managed-bean-name>
        <managed-bean-class>faccilvisualweb.Configuracion.Categorias.Categorias_Agregar_tabla</managed-bean-class>
        <managed-bean-scope>request</managed-bean-scope>
    </managed-bean>
    <managed-bean>
        <managed-bean-name>Global$Footer</managed-bean-name>
        <managed-bean-class>faccilvisualweb.Global.Footer</managed-bean-class>
        <managed-bean-scope>request</managed-bean-scope>
    </managed-bean>
    <managed-bean>
        <managed-bean-name>Configuracion$Categorias$Categorias</managed-bean-name>
        <managed-bean-class>faccilvisualweb.Configuracion.Categorias.Categorias</managed-bean-class>
        <managed-bean-scope>request</managed-bean-scope>
    </managed-bean>
    <managed-bean>
        <managed-bean-name>Configuracion$Categorias$Agregar_Modificar_Categoria</managed-bean-name>
        <managed-bean-class>faccilvisualweb.Configuracion.Categorias.Agregar_Modificar_Categoria</managed-bean-class>
        <managed-bean-scope>request</managed-bean-scope>
    </managed-bean>
    <navigation-rule>
        <from-view-id>/Configuracion/Categorias/Categorias.jsp</from-view-id>
        <navigation-case>
            <from-outcome>case1</from-outcome>
            <to-view-id>/Login/Usuarios_Login.jsp</to-view-id>
        </navigation-case>
        <navigation-case>
            <from-outcome>case2</from-outcome>
            <to-view-id>/Configuracion/Categorias/Agregar_Modificar_Categoria.jsp</to-view-id>
        </navigation-case>
    </navigation-rule>
    <navigation-rule>
        <from-view-id>/Configuracion/Categorias/Agregar_Modificar_Categoria.jsp</from-view-id>
        <navigation-case>
            <from-outcome>case1</from-outcome>
            <to-view-id>/Configuracion/Categorias/Categorias.jsp</to-view-id>
        </navigation-case>
    </navigation-rule>
    <managed-bean>
        <managed-bean-name>Configuracion$Series$Series</managed-bean-name>
        <managed-bean-class>faccilvisualweb.Configuracion.Series.Series</managed-bean-class>
        <managed-bean-scope>request</managed-bean-scope>
    </managed-bean>
    <managed-bean>
        <managed-bean-name>Configuracion$Series$Series_Agregar_Tabla</managed-bean-name>
        <managed-bean-class>faccilvisualweb.Configuracion.Series.Series_Agregar_Tabla</managed-bean-class>
        <managed-bean-scope>request</managed-bean-scope>
    </managed-bean>
    <managed-bean>
        <managed-bean-name>Configuracion$Series$Agregar_Modificar_Serie</managed-bean-name>
        <managed-bean-class>faccilvisualweb.Configuracion.Series.Agregar_Modificar_Serie</managed-bean-class>
        <managed-bean-scope>request</managed-bean-scope>
    </managed-bean>
    <navigation-rule>
        <from-view-id>/Configuracion/Series/Agregar_Modificar_Serie.jsp</from-view-id>
        <navigation-case>
            <from-outcome>case1</from-outcome>
            <to-view-id>/Configuracion/Series/Series.jsp</to-view-id>
        </navigation-case>
    </navigation-rule>
    <navigation-rule>
        <from-view-id>/Configuracion/Series/Series.jsp</from-view-id>
        <navigation-case>
            <from-outcome>case1</from-outcome>
            <to-view-id>/Login/Usuarios_Login.jsp</to-view-id>
        </navigation-case>
        <navigation-case>
            <from-outcome>case2</from-outcome>
            <to-view-id>/Configuracion/Series/Agregar_Modificar_Serie.jsp</to-view-id>
        </navigation-case>
    </navigation-rule>
    <managed-bean>
        <managed-bean-name>Configuracion$MisDatos$DatosUsuario</managed-bean-name>
        <managed-bean-class>faccilvisualweb.Configuracion.MisDatos.DatosUsuario</managed-bean-class>
        <managed-bean-scope>request</managed-bean-scope>
    </managed-bean>
    <managed-bean>
        <managed-bean-name>Configuracion$MisDatos$DatosUsuario_Formulario</managed-bean-name>
        <managed-bean-class>faccilvisualweb.Configuracion.MisDatos.DatosUsuario_Formulario</managed-bean-class>
        <managed-bean-scope>request</managed-bean-scope>
    </managed-bean>
    <navigation-rule>
        <from-view-id>/Login/Usuarios_Login.jsp</from-view-id>
        <navigation-case>
            <from-outcome>case1</from-outcome>
            <to-view-id>/Facturas/Facturas.jsp</to-view-id>
        </navigation-case>
        <navigation-case>
            <from-outcome>case2</from-outcome>
            <to-view-id>/Login/Logout.jsp</to-view-id>
        </navigation-case>
    </navigation-rule>
    <managed-bean>
        <managed-bean-name>Productos$Productos</managed-bean-name>
        <managed-bean-class>faccilvisualweb.Productos.Productos</managed-bean-class>
        <managed-bean-scope>request</managed-bean-scope>
    </managed-bean>
    <managed-bean>
        <managed-bean-name>Clientes$Clientes</managed-bean-name>
        <managed-bean-class>faccilvisualweb.Clientes.Clientes</managed-bean-class>
        <managed-bean-scope>request</managed-bean-scope>
    </managed-bean>
    <managed-bean>
        <managed-bean-name>Clientes$Clientes_Agregar_Tabla</managed-bean-name>
        <managed-bean-class>faccilvisualweb.Clientes.Clientes_Agregar_Tabla</managed-bean-class>
        <managed-bean-scope>request</managed-bean-scope>
    </managed-bean>
    <managed-bean>
        <managed-bean-name>Productos$Productos_Agregar_Tabla</managed-bean-name>
        <managed-bean-class>faccilvisualweb.Productos.Productos_Agregar_Tabla</managed-bean-class>
        <managed-bean-scope>request</managed-bean-scope>
    </managed-bean>
    <managed-bean>
        <managed-bean-name>Clientes$Agregar_Cliente</managed-bean-name>
        <managed-bean-class>faccilvisualweb.Clientes.Agregar_Cliente</managed-bean-class>
        <managed-bean-scope>request</managed-bean-scope>
    </managed-bean>
    <managed-bean>
        <managed-bean-name>Productos$Agregar_Producto</managed-bean-name>
        <managed-bean-class>faccilvisualweb.Productos.Agregar_Producto</managed-bean-class>
        <managed-bean-scope>request</managed-bean-scope>
    </managed-bean>
    <navigation-rule>
        <from-view-id>/Clientes/Clientes.jsp</from-view-id>
        <navigation-case>
            <from-outcome>case1</from-outcome>
            <to-view-id>/Login/Usuarios_Login.jsp</to-view-id>
        </navigation-case>
        <navigation-case>
            <from-outcome>case2</from-outcome>
            <to-view-id>/Clientes/Agregar_Cliente.jsp</to-view-id>
        </navigation-case>
        <navigation-case>
            <from-outcome>case3</from-outcome>
            <to-view-id>/Clientes/Modificar_Cliente.jsp</to-view-id>
        </navigation-case>
    </navigation-rule>
    <navigation-rule>
        <from-view-id>/Productos/Productos.jsp</from-view-id>
        <navigation-case>
            <from-outcome>case1</from-outcome>
            <to-view-id>/Login/Usuarios_Login.jsp</to-view-id>
        </navigation-case>
        <navigation-case>
            <from-outcome>case2</from-outcome>
            <to-view-id>/Productos/Agregar_Producto.jsp</to-view-id>
        </navigation-case>
        <navigation-case>
            <from-outcome>case3</from-outcome>
            <to-view-id>/Productos/Modificar_Producto.jsp</to-view-id>
        </navigation-case>
    </navigation-rule>
    <navigation-rule>
        <from-view-id>/Clientes/Agregar_Cliente.jsp</from-view-id>
        <navigation-case>
            <from-outcome>case1</from-outcome>
            <to-view-id>/Clientes/Clientes.jsp</to-view-id>
        </navigation-case>
    </navigation-rule>
    <navigation-rule>
        <from-view-id>/Productos/Agregar_Producto.jsp</from-view-id>
        <navigation-case>
            <from-outcome>case1</from-outcome>
            <to-view-id>/Productos/Productos.jsp</to-view-id>
        </navigation-case>
    </navigation-rule>
    <managed-bean>
        <managed-bean-name>Productos$Modificar_Producto</managed-bean-name>
        <managed-bean-class>faccilvisualweb.Productos.Modificar_Producto</managed-bean-class>
        <managed-bean-scope>request</managed-bean-scope>
    </managed-bean>
    <navigation-rule>
        <from-view-id>/Productos/Modificar_Producto.jsp</from-view-id>
        <navigation-case>
            <from-outcome>case1</from-outcome>
            <to-view-id>/Productos/Productos.jsp</to-view-id>
        </navigation-case>
    </navigation-rule>
    <managed-bean>
        <managed-bean-name>Clientes$Modificar_Cliente</managed-bean-name>
        <managed-bean-class>faccilvisualweb.Clientes.Modificar_Cliente</managed-bean-class>
        <managed-bean-scope>request</managed-bean-scope>
    </managed-bean>
    <navigation-rule>
        <from-view-id>/Clientes/Modificar_Cliente.jsp</from-view-id>
        <navigation-case>
            <from-outcome>case1</from-outcome>
            <to-view-id>/Clientes/Clientes.jsp</to-view-id>
        </navigation-case>
    </navigation-rule>
    <application>
        <message-bundle>faccilvisualweb.Faccil</message-bundle>
    </application>
    <managed-bean>
        <managed-bean-name>Registro$Registro</managed-bean-name>
        <managed-bean-class>faccilvisualweb.Registro.Registro</managed-bean-class>
        <managed-bean-scope>request</managed-bean-scope>
    </managed-bean>
    <managed-bean>
        <managed-bean-name>Registro$Registro_Formulario</managed-bean-name>
        <managed-bean-class>faccilvisualweb.Registro.Registro_Formulario</managed-bean-class>
        <managed-bean-scope>request</managed-bean-scope>
    </managed-bean>
    <managed-bean>
        <managed-bean-name>Facturas$Facturas</managed-bean-name>
        <managed-bean-class>faccilvisualweb.Facturas.Facturas</managed-bean-class>
        <managed-bean-scope>request</managed-bean-scope>
    </managed-bean>
    <managed-bean>
        <managed-bean-name>Facturas$FacturasListados</managed-bean-name>
        <managed-bean-class>faccilvisualweb.Facturas.FacturasListados</managed-bean-class>
        <managed-bean-scope>request</managed-bean-scope>
    </managed-bean>
    <managed-bean>
        <managed-bean-name>Login$Login</managed-bean-name>
        <managed-bean-class>faccilvisualweb.Login.Login</managed-bean-class>
        <managed-bean-scope>request</managed-bean-scope>
    </managed-bean>
    <navigation-rule>
        <from-view-id>/Login/Login.jsp</from-view-id>
        <navigation-case>
            <from-outcome>case2</from-outcome>
            <to-view-id>/Login/Recordatorio.jsp</to-view-id>
        </navigation-case>
        <navigation-case>
            <from-outcome>case1</from-outcome>
            <to-view-id>/Facturas/Facturas.jsp</to-view-id>
        </navigation-case>
        <navigation-case>
            <from-outcome>case3</from-outcome>
            <to-view-id>/Login/Logout.jsp</to-view-id>
        </navigation-case>
    </navigation-rule>
    <managed-bean>
        <managed-bean-name>Login$Recordatorio</managed-bean-name>
        <managed-bean-class>faccilvisualweb.Login.Recordatorio</managed-bean-class>
        <managed-bean-scope>request</managed-bean-scope>
    </managed-bean>
    <navigation-rule>
        <from-view-id>/Facturas/Facturas.jsp</from-view-id>
        <navigation-case>
            <from-outcome>case2</from-outcome>
            <to-view-id>/Facturas/AgregarFactura.jsp</to-view-id>
        </navigation-case>
        <navigation-case>
            <from-outcome>case1</from-outcome>
            <to-view-id>/Login/Logout.jsp</to-view-id>
        </navigation-case>
    </navigation-rule>
    <managed-bean>
        <managed-bean-name>Global$FooterFaces</managed-bean-name>
        <managed-bean-class>faccilvisualweb.Global.FooterFaces</managed-bean-class>
        <managed-bean-scope>request</managed-bean-scope>
    </managed-bean>
    <managed-bean>
        <managed-bean-name>Global$FooterFaces2Niveles</managed-bean-name>
        <managed-bean-class>faccilvisualweb.Global.FooterFaces2Niveles</managed-bean-class>
        <managed-bean-scope>request</managed-bean-scope>
    </managed-bean>
    <managed-bean>
        <managed-bean-name>Login$Logout</managed-bean-name>
        <managed-bean-class>faccilvisualweb.Login.Logout</managed-bean-class>
        <managed-bean-scope>request</managed-bean-scope>
    </managed-bean>
    <navigation-rule>
        <from-view-id>/Login/Logout.jsp</from-view-id>
        <navigation-case>
            <from-outcome>case1</from-outcome>
            <to-view-id>/Facturas/Facturas.jsp</to-view-id>
        </navigation-case>
    </navigation-rule>
    <managed-bean>
        <managed-bean-name>RegistroGratuito$Registro_Formulario</managed-bean-name>
        <managed-bean-class>faccilvisualweb.RegistroGratuito.Registro_Formulario</managed-bean-class>
        <managed-bean-scope>request</managed-bean-scope>
    </managed-bean>
    <managed-bean>
        <managed-bean-name>RegistroGratuito$Registro</managed-bean-name>
        <managed-bean-class>faccilvisualweb.RegistroGratuito.Registro</managed-bean-class>
        <managed-bean-scope>request</managed-bean-scope>
    </managed-bean>
    <managed-bean>
        <managed-bean-name>Registro$InformacionEnvio</managed-bean-name>
        <managed-bean-class>faccilvisualweb.Registro.InformacionEnvio</managed-bean-class>
        <managed-bean-scope>request</managed-bean-scope>
    </managed-bean>
    <navigation-rule>
        <from-view-id>/Registro/InformacionEnvio.jsp</from-view-id>
        <navigation-case>
            <from-outcome>case1</from-outcome>
            <to-view-id>/Login/Logout.jsp</to-view-id>
        </navigation-case>
    </navigation-rule>
    <navigation-rule>
        <from-view-id>/Registro/Registro.jsp</from-view-id>
        <navigation-case>
            <from-outcome>case1</from-outcome>
            <to-view-id>/Registro/InformacionEnvio.jsp</to-view-id>
        </navigation-case>
    </navigation-rule>
    <managed-bean>
        <managed-bean-name>RegistroGratuito$RegistroCompletado</managed-bean-name>
        <managed-bean-class>faccilvisualweb.RegistroGratuito.RegistroCompletado</managed-bean-class>
        <managed-bean-scope>request</managed-bean-scope>
    </managed-bean>
    <navigation-rule>
        <from-view-id>/RegistroGratuito/Registro.jsp</from-view-id>
        <navigation-case>
            <from-outcome>case1</from-outcome>
            <to-view-id>/RegistroGratuito/RegistroCompletado.jsp</to-view-id>
        </navigation-case>
    </navigation-rule>
    <navigation-rule>
        <from-view-id>/RegistroGratuito/RegistroCompletado.jsp</from-view-id>
        <navigation-case>
            <from-outcome>case1</from-outcome>
            <to-view-id>/Login/Logout.jsp</to-view-id>
        </navigation-case>
    </navigation-rule>
</faces-config>

Make sure that all your files are in the same folder. If there are sub folders, you need to make sure that the files are in the same sub folder too.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM