Visualizzazione dei risultati da 1 a 3 su 3
  1. #1
    Utente di HTML.it
    Registrato dal
    Oct 2002
    Messaggi
    98

    Cannot find FacesContext

    ho cedrcato in rete ma non riesco a risolvere l'errore.

    Io vorrei fare una pagina di login utente, e in base all'utente che si loga la pagina permette alcune cosa o tutto.

    sono fermo ancora alla pag di login, la indirizzo giusta ma mi crea errore sul tag alla riga 9: <f:view>


    index.jsp
    codice:
    <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <% response.sendRedirect("faces/calculator.jsp"); %>
    wen.xml
    codice:
    <?xml version="1.0" encoding="UTF-8"?> <web-app id="WebApp_ID" version="2.5"  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_2_5.xsd">  <display-name>SSWA</display-name>    <context-param>   <param-name>contextConfigLocation</param-name>   <param-value>/WEB-INF/applicationContext-business.xml             /WEB-INF/applicationContext-security.xml</param-value>  </context-param>  <context-param>   <param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>   <param-value>resources.application</param-value>  </context-param>    <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>  <listener>   <listener-class>com.sun.faces.config.ConfigureListener</listener-class>  </listener>    <listener>   <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>  </listener>  <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>  <welcome-file-list>   <welcome-file>index.html</welcome-file>   <welcome-file>index.htm</welcome-file>   <welcome-file>index.jsp</welcome-file>   <welcome-file>default.html</welcome-file>   <welcome-file>default.htm</welcome-file>   <welcome-file>default.jsp</welcome-file>  </welcome-file-list> </web-app>
    faces-confing.xlm
    codice:
    <?xml version="1.0" encoding="UTF-8"?>  <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/we...config_1_2.xsd"     version="1.2">      <application>     	<el-resolver>org.springframework.web.jsf.el.SpringBeanFacesELResolver</el-resolver>     </application>      	<managed-bean> 		<managed-bean-name>calculatorController</managed-bean-name> 		<managed-bean-class>org.swview.springsecuritytestapp.jsf.CalculatorController</managed-bean-class> 		<managed-bean-scope>request</managed-bean-scope> 		<managed-property> 			<property-name>calculator</property-name> 			<value>#{calculatorBean}</value> 		</managed-property> 	</managed-bean> 	      <managed-bean>     	<managed-bean-name>login</managed-bean-name>      	<managed-bean-class>it.bean.Login</managed-bean-class>      	<managed-bean-scope>request</managed-bean-scope>      	<managed-property>      		<property-name>password</property-name>      		<property-class>java.lang.String</property-class>      		<value/>      	</managed-property>      	     	<managed-property>      		<property-name>user</property-name>      		<property-class>java.lang.String</property-class>      		<value/>      	</managed-property>      </managed-bean>                <navigation-rule>      	<display-name>login</display-name>      	<from-view-id>/login.jsp</from-view-id>      	<navigation-case>      		<from-outcome>submit</from-outcome>      		<to-view-id>/calculator.jsp</to-view-id>      	</navigation-case>      </navigation-rule>   </faces-config>
    applicationContext-secutity.xlm
    codice:
    <?xml version="1.0" encoding="UTF-8"?> <beans:beans xmlns="http://www.springframework.org/schema/security" 	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 	xmlns:beans="http://www.springframework.org/schema/beans" 	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schem...-beans-3.0.xsd 		http://www.springframework.org/schema/security http://www.springframework.org/schem...curity-3.0.xsd"> 	 	<global-method-security> 		<protect-pointcut access="ROLE_SPECIAL_USER" expression="execution(* org.swview.springsecuritytestapp.logic.Calculator.add(..))"/> 		<protect-pointcut access="ROLE_GENERAL_USER" expression="execution(* org.swview.springsecuritytestapp.logic.Calculator.subtract(..))"/> 	</global-method-security> 	 	<http auto-config='true'> 		<intercept-url pattern="/login.jsp*" access="IS_AUTHENTICATED_ANONYMOUSLY"/> 		<intercept-url pattern="/**" access="ROLE_USER" /> 		<form-login login-page='/login.jsp'/> 	</http>           <authentication-manager>         <authentication-provider>             <password-encoder hash="md5"/>             <user-service>                 <user name="kamal" password="65dc70650690999922d7dcd99dbd4033" authorities="ROLE_SPECIAL_USER" />                 <user name="test" password="2a2d595e6ed9a0b24f027f2b63b134d6" authorities="ROLE_GENERAL_USER" />             </user-service>         </authentication-provider>     </authentication-manager>  </beans:beans>
    login.jsp
    codice:
    	<%@page contentType="text/html"%> <%@page pageEncoding="UTF-8"%>  <%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%> <%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">  <f:view>     <h:form>         
    
    Inserisci la UserName: <h:inputText value="#{Login.user}" id="name" required="true" /></p>         
    
    Inserisci la password: <h:inputText value="#{Login.password}" id="pwd" required="true" /></p>         <h:commandButton value="Submit" action="submit" />     </h:form> </f:view>
    errore
    codice:
    19:20:51,149 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/SSWA].[jsp]] Servlet.service() for servlet jsp threw exception: java.lang.RuntimeException: Cannot find FacesContext 	at javax.faces.webapp.UIComponentClassicTagBase.getFacesContext(UIComponentClassicTagBase.java:1852) [:2.0.3-] 	at javax.faces.webapp.UIComponentClassicTagBase.setJspId(UIComponentClassicTagBase.java:1669) [:2.0.3-] 	at org.apache.jsp.login_jsp._jspx_meth_f_005fview_005f0(login_jsp.java:96) 	at org.apache.jsp.login_jsp._jspService(login_jsp.java:74) ...............

  2. #2
    Utente di HTML.it
    Registrato dal
    Oct 2002
    Messaggi
    98
    Sapete dirmi in quale direzione muovermi per risolvere il problema?

  3. #3
    Utente di HTML.it
    Registrato dal
    Oct 2002
    Messaggi
    98
    ho fatto queste modifiche e non funziona

    web.xml
    codice:
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app id="WebApp_ID" version="2.5"
     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_2_5.xsd">
     <display-name>SSWA</display-name>
     <context-param>
      <param-name>contextConfigLocation</param-name>
      <param-value>/WEB-INF/applicationContext-business.xml
              /WEB-INF/applicationContext-security.xml</param-value>
     </context-param>
     <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>
     <listener>
      <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
     </listener>
     <servlet>
      <servlet-name>FacesServlet</servlet-name>
      <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
      <load-on-startup>1</load-on-startup>
     </servlet>
     <servlet-mapping>
      <servlet-name>FacesServlet</servlet-name>
      <url-pattern>/faces/*</url-pattern>
     </servlet-mapping>
     <servlet-mapping>
      <servlet-name>FacesServlet</servlet-name>
      <url-pattern>*.jsf</url-pattern>
     </servlet-mapping>
     <servlet-mapping>
      <servlet-name>FacesServlet</servlet-name>
      <url-pattern>*.faces</url-pattern>
     </servlet-mapping>
     <welcome-file-list>
      <welcome-file>index.html</welcome-file>
      <welcome-file>index.htm</welcome-file>
      <welcome-file>index.jsp</welcome-file>
      <welcome-file>default.html</welcome-file>
      <welcome-file>default.htm</welcome-file>
      <welcome-file>default.jsp</welcome-file>
     </welcome-file-list>
     <login-config>
      <auth-method>BASIC</auth-method>
      <form-login-config>
       <form-login-page>/login.jsp</form-login-page>
       <form-error-page>/index.jsp</form-error-page>
      </form-login-config>
     </login-config>
    </web-app>
    faces-config.xml
    codice:
    <?xml version="1.0" encoding="UTF-8"?>
    <faces-config version="1.2" xmlns="http://java.sun.com/xml/ns/javaee"
     xmlns:xi="http://www.w3.org/2001/XInclude"
     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/w...sconfig_1_2.xsd">
     <managed-bean>
      <managed-bean-name>calculatorController</managed-bean-name>
      <managed-bean-class>org.swview.springsecuritytestapp.jsf.CalculatorController</managed-bean-class>
      <managed-bean-scope>request</managed-bean-scope>
      <managed-property>
       <property-name>calculator</property-name>
       <value>#{calculatorBean}</value>
      </managed-property>
     </managed-bean>
     
     <managed-bean>
      <managed-bean-name>login</managed-bean-name>
      <managed-bean-class>it.bean.Login</managed-bean-class>
      <managed-bean-scope>request</managed-bean-scope>
      <managed-property>
       <property-name>password</property-name>
       <property-class>java.lang.String</property-class>
       <value/>
      </managed-property>
      <managed-property>
       <property-name>user</property-name>
       <property-class>java.lang.String</property-class>
       <value/>
      </managed-property>
     </managed-bean>
     <navigation-rule>
      <display-name>login</display-name>
      <from-view-id>/login.jsp</from-view-id>
      <navigation-case>
       <from-outcome>submit</from-outcome>
       <to-view-id>/calculator.jsp</to-view-id>
      </navigation-case>
     </navigation-rule>
     <application>
      <el-resolver>org.springframework.web.jsf.el.SpringBeanFacesELResolver</el-resolver>
     </application>
     
    </faces-config>
    applicationContext-security.xml
    codice:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans:beans xmlns="http://www.springframework.org/schema/security"
    	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    	xmlns:beans="http://www.springframework.org/schema/beans"
    	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schem...-beans-3.0.xsd
    		http://www.springframework.org/schema/security http://www.springframework.org/schem...curity-3.0.xsd">
    	
    	<global-method-security>
    		<protect-pointcut access="ROLE_SPECIAL_USER" expression="execution(* org.swview.springsecuritytestapp.logic.Calculator.add(..))"/>
    		<protect-pointcut access="ROLE_GENERAL_USER" expression="execution(* org.swview.springsecuritytestapp.logic.Calculator.subtract(..))"/>
    	</global-method-security>
    	
    	<!-- 
    	<http auto-config="true" >
    <intercept-url pattern="/*" access="hasRole('ROLE_USER')"/>
    <form-login login-page="/login.jsp" />
    </http>
    	
    -->  
    	<http auto-config='true'>
    <intercept-url pattern="/login.jsp*" access="IS_AUTHENTICATED_ANONYMOUSLY"/>
    <intercept-url pattern="/**" access="ROLE_USER" />
    <form-login login-page='/login.jsp'/>
    </http> 
     
    	
        <!--
        Usernames/Passwords are
            kamal/swview
            test/spring
        -->
        <authentication-manager>
            <authentication-provider>
                <password-encoder hash="md5"/>
                <user-service>
                    <user name="kamal" password="65dc70650690999922d7dcd99dbd4033" authorities="ROLE_SPECIAL_USER" />
                    <user name="test" password="2a2d595e6ed9a0b24f027f2b63b134d6" authorities="ROLE_GENERAL_USER" />
                </user-service>
            </authentication-provider>
        </authentication-manager>
    
    </beans:beans>
    applicationContext-business.xml
    codice:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schem...-beans-3.0.xsd">
    
    	<bean id="calculatorBean" class="org.swview.springsecuritytestapp.logic.CalculatorIpml">
    	</bean>
    	
    	<bean id="login" class="it.bean.Login">
    	</bean>
    </beans>
    
    login.jsp
    
    
    codice:
    <%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
    <%@taglib prefix="f"  uri="http://java.sun.com/jsf/core"%>
    <%@taglib prefix="h"  uri="http://java.sun.com/jsf/html"%>
    <?xml version='1.0' encoding='windows-1252'?>
    <jsp :root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Calculator</title>
    </head>
    <body>
    
    <f:view>
        <h:form>
            
    
    Inserisci la UserName: <h:inputText value="#{Login.user}" id="name" required="true" /></p>
            
    
    Inserisci la password: <h:inputText value="#{Login.password}" id="pwd" required="true" /></p>
            <h:commandButton value="Submit" action="submit" />
        </h:form>
    </f:view></body></html>
    ERRORE
    codice:
    HTTP Status 500 - 
    
    --------------------------------------------------------------------------------
    
    type Exception report
    
    message 
    
    description The server encountered an internal error () that prevented it from fulfilling this request.
    
    exception 
    
    org.apache.jasper.JasperException: An exception occurred processing JSP page /login.jsp at line 17
    
    14: </head>
    15: <body>
    16: 
    17: <f:view>
    18:     <h:form>
    19:         
    
    Inserisci la UserName: <h:inputText value="#{Login.user}" id="name" required="true" /></p>
    20:         
    
    Inserisci la password: <h:inputText value="#{Login.password}" id="pwd" required="true" /></p>
    
    
    Stacktrace:
    	org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:498)

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.