Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

jsp - javax.faces.FacesException: java.lang.RuntimeException: Cannot find FacesContext -


i'm trying simple project work on jboss, i'm stuck @ error (i tried using .jsf on url). application in tomcat work's fine

javax.servlet.servletexception: java.lang.runtimeexception: cannot find facescontext  javax.faces.webapp.facesservlet.service  root cause  javax.faces.facesexception: java.lang.runtimeexception: cannot find facescontext  org.apache.myfaces.context.servlet.servletexternalcontextimpl.dispatch(servletexternalcontextimpl.java:425)  org.apache.myfaces.application.jsp.jspviewhandlerimpl.renderview(jspviewhandlerimpl.java:211)  org.apache.myfaces.lifecycle.renderresponseexecutor.execute(renderresponseexecutor.java:41)  org.apache.myfaces.lifecycle.lifecycleimpl.render(lifecycleimpl.java:132)  javax.faces.webapp.facesservlet.service(facesservlet.java:140)  org.jboss.web.tomcat.filters.replyheaderfilter.dofilter(replyheaderfilter.java:96 

my web.xml

<?xml version="1.0" encoding="utf-8"?> <web-app xmlns="http://java.sun.com/xml/ns/j2ee"          xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"          xsi:schemalocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"          version="2.4">  <listener>   <listener-class>org.apache.myfaces.webapp.startupservletcontextlistener</listener-class>  </listener>   <servlet>     <servlet-name>javax.faces.facesservlet</servlet-name>     <servlet-class>javax.faces.webapp.facesservlet</servlet-class>     <load-on-startup>1</load-on-startup>   </servlet>   <servlet-mapping>     <servlet-name>javax.faces.facesservlet</servlet-name>     <url-pattern>*.faces</url-pattern>   </servlet-mapping>   <filter>     <filter-name>faces-redirect-filter</filter-name>     <filter-class>core.facesredirectfilter</filter-class>   </filter>   <filter-mapping>     <filter-name>faces-redirect-filter</filter-name>     <url-pattern>*.jsp</url-pattern>   </filter-mapping>    <welcome-file-list>     <welcome-file>index.jsp</welcome-file>     <welcome-file>index.html</welcome-file>   </welcome-file-list> </web-app> 

faces-config xml

<?xml version='1.0' encoding='utf-8'?> <!doctype faces-config public "-//sun microsystems, inc.//dtd javaserver faces config 1.1//en" "http://java.sun.com/dtd/web-facesconfig_1_1.dtd">      <faces-config>   <managed-bean>     <managed-bean-name>resumebean</managed-bean-name>     <managed-bean-class>core.resumebean</managed-bean-class>     <managed-bean-scope>session</managed-bean-scope>   </managed-bean>   <managed-bean>     <managed-bean-name>colorbean</managed-bean-name>     <managed-bean-class>core.colorbean</managed-bean-class>     <managed-bean-scope>request</managed-bean-scope>   </managed-bean>   <navigation-rule>     <from-view-id>/customize.jsp</from-view-id>     <navigation-case>       <from-outcome>same-color</from-outcome>       <to-view-id>/web-inf/results/same-color.jsp</to-view-id>     </navigation-case>     <navigation-case>       <from-outcome>success</from-outcome>       <to-view-id>/web-inf/results/show-preview.jsp</to-view-id>     </navigation-case>   </navigation-rule>   <navigation-rule>     <from-view-id>/customize-bg.jsp</from-view-id>     <navigation-case>       <from-outcome>success</from-outcome>       <to-view-id>/web-inf/results/show-preview2.jsp</to-view-id>     </navigation-case>   </navigation-rule> </faces-config> 

javax.faces.facesexception: java.lang.runtimeexception: cannot find facescontext

jsf components in jsp page complaining facescontext cannot found. 1 responsible creating facesservlet.

here,

<servlet-mapping>     <servlet-name>javax.faces.facesservlet</servlet-name>     <url-pattern>*.faces</url-pattern> </servlet-mapping> 

you've declared facesservlet listen on url-pattern of *.faces. so, facesservlet run (and create facescontext) need ensure request url matches http://example.com/context/page.faces , not http://example.com/context/page.jsp.

if rather want use http://example.com/context/page.jsf, need change url-pattern of facesservlet *.jsf.


that said, facesredirectfilter suspicious well. isn't redirecting *.jsp *.jsf or so? if so, need modify filter well. however, if sole intent prevent users accessing *.jsp files directly without involvement of facesservlet, better add following security constraint web.xml:

<security-constraint>     <display-name>restrict direct access jsp files</display-name>     <web-resource-collection>         <web-resource-name>jsp files</web-resource-name>         <url-pattern>*.jsp</url-pattern>     </web-resource-collection>     <auth-constraint /> </security-constraint>  

(and remove filter).


unrelated problem, mentioned jsf 1.2, you've declared faces-config.xml jsf 1.1. jsf 1.2 implementation or newer fall jsf 1.1 compatibility. need declare jsf 1.2 well.

<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/web-facesconfig_1_2.xsd"> 

(and rid of doctype)


Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -