myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Trumml <Martin.Trum...@systema.info>
Subject Re: Access to context of HTTP session
Date Sat, 28 Apr 2007 19:12:30 GMT

Well...
1) I wanted to see what happens, if I add a Filter, but the following code
throws an exception:
FacesContextFactory contextFactory =
(FacesContextFactory)FactoryFinder.getFactory(FactoryFinder.FACES_CONTEXT_FACTORY);

21:04:22,358 ERROR [[jsp]] Servlet.service() for servlet jsp threw exception
java.lang.IllegalStateException: No Factories configured for this
Application. This happens if the faces-initialization does not work at all -
make su
re that you properly include all configuration settings necessary for a
basic faces application and that all the necessary libs are included. Also
che
ck the logging output of your web application and your container for any
exceptions!
If you did that and find nothing, the mistake might be due to the fact that
you use some special web-containers which do not support registering conte
xt-listeners via TLD files and a context listener is not setup in your
web.xml.
A typical config looks like this;
<listener>
 
<listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
</listener>

        at javax.faces.FactoryFinder.getFactory(FactoryFinder.java:90)
        at
at.co.systema.ce.tests.jsf.core.filter.JSFGet.getFacesContext(JSFGet.java:76)
        at
at.co.systema.ce.tests.jsf.core.filter.JSFGet.doFilter(JSFGet.java:42)
        at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
        at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
        at
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
        at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
        at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
        at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
        at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
        at
org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
        at
org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
        at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
        at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
        at
org.jboss.web.tomcat.tc5.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:156)
        at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
        at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
        at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
        at
org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
        at
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
        at
org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
        at java.lang.Thread.run(Thread.java:595)

2) Here is the stacktrace when the context is null:
20:00:33,789 ERROR [STDERR] java.lang.Exception: Stack trace
20:00:33,789 ERROR [STDERR]     at
java.lang.Thread.dumpStack(Thread.java:1158)
20:00:33,789 ERROR [STDERR]     at
at.co.systema.ce.tests.view.UserNumberBean._hasContext(UserNumberBean.java:60)
20:00:33,789 ERROR [STDERR]     at
at.co.systema.ce.tests.view.UserNumberBean.getUserNumber(UserNumberBean.java:45)
20:00:33,789 ERROR [STDERR]     at
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
20:00:33,789 ERROR [STDERR]     at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
20:00:33,789 ERROR [STDERR]     at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
20:00:33,789 ERROR [STDERR]     at
java.lang.reflect.Method.invoke(Method.java:585)
20:00:33,789 ERROR [STDERR]     at
org.apache.myfaces.el.PropertyResolverImpl.getProperty(PropertyResolverImpl.java:383)
20:00:33,789 ERROR [STDERR]     at
org.apache.myfaces.el.PropertyResolverImpl.getValue(PropertyResolverImpl.java:68)
20:00:33,789 ERROR [STDERR]     at
org.apache.myfaces.el.ELParserHelper$MyPropertySuffix.evaluate(ELParserHelper.java:533)
20:00:33,789 ERROR [STDERR]     at
org.apache.commons.el.ComplexValue.evaluate(ComplexValue.java:145)
20:00:33,789 ERROR [STDERR]     at
org.apache.myfaces.el.ValueBindingImpl.getValue(ValueBindingImpl.java:362)
20:00:33,789 ERROR [STDERR]     at
javax.faces.component.UIOutput.getValue(UIOutput.java:75)
20:00:33,789 ERROR [STDERR]     at
org.apache.myfaces.renderkit.RendererUtils.getStringValue(RendererUtils.java:234)
20:00:33,789 ERROR [STDERR]     at
org.apache.myfaces.renderkit.html.HtmlTextRendererBase.renderInput(HtmlTextRendererBase.java:131)
20:00:33,789 ERROR [STDERR]     at
org.apache.myfaces.renderkit.html.HtmlTextRendererBase.encodeEnd(HtmlTextRendererBase.java:49)
20:00:33,789 ERROR [STDERR]     at
javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:319)
20:00:33,789 ERROR [STDERR]     at
javax.faces.webapp.UIComponentTag.encodeEnd(UIComponentTag.java:349)
20:00:33,789 ERROR [STDERR]     at
javax.faces.webapp.UIComponentTag.doEndTag(UIComponentTag.java:253)
20:00:33,789 ERROR [STDERR]     at
org.apache.jsp.greeting_jsp._jspx_meth_h_inputText_0(greeting_jsp.java:269)
20:00:33,789 ERROR [STDERR]     at
org.apache.jsp.greeting_jsp._jspx_meth_h_form_0(greeting_jsp.java:170)
20:00:33,789 ERROR [STDERR]     at
org.apache.jsp.greeting_jsp._jspx_meth_f_view_0(greeting_jsp.java:122)
20:00:33,789 ERROR [STDERR]     at
org.apache.jsp.greeting_jsp._jspService(greeting_jsp.java:87)
20:00:33,789 ERROR [STDERR]     at
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
20:00:33,789 ERROR [STDERR]     at
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
20:00:33,789 ERROR [STDERR]     at
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:334)
20:00:33,789 ERROR [STDERR]     at
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
20:00:33,789 ERROR [STDERR]     at
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
20:00:33,789 ERROR [STDERR]     at
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
20:00:33,789 ERROR [STDERR]     at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
20:00:33,789 ERROR [STDERR]     at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
20:00:33,789 ERROR [STDERR]     at
org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:672)
20:00:33,789 ERROR [STDERR]     at
org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:463)
20:00:33,789 ERROR [STDERR]     at
org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:398)
20:00:33,789 ERROR [STDERR]     at
org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:301)
20:00:33,789 ERROR [STDERR]     at
org.apache.myfaces.context.servlet.ServletExternalContextImpl.dispatch(ServletExternalContextImpl.java:405)
20:00:33,789 ERROR [STDERR]     at
org.apache.myfaces.application.jsp.JspViewHandlerImpl.renderView(JspViewHandlerImpl.java:225)
20:00:33,789 ERROR [STDERR]     at
org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:299)
20:00:33,789 ERROR [STDERR]     at
javax.faces.webapp.FacesServlet.service(FacesServlet.java:95)
20:00:33,789 ERROR [STDERR]     at
org.apache.myfaces.webapp.MyFacesServlet.service(MyFacesServlet.java:57)
20:00:33,789 ERROR [STDERR]     at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
20:00:33,789 ERROR [STDERR]     at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
20:00:33,789 ERROR [STDERR]     at
org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:672)
20:00:33,789 ERROR [STDERR]     at
org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:463)
20:00:33,789 ERROR [STDERR]     at
org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:398)
20:00:33,789 ERROR [STDERR]     at
org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:301)
20:00:33,789 ERROR [STDERR]     at
org.apache.jasper.runtime.PageContextImpl.doForward(PageContextImpl.java:688)
20:00:33,789 ERROR [STDERR]     at
org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:658)
20:00:33,789 ERROR [STDERR]     at
org.apache.jsp.index_jsp._jspService(index_jsp.java:97)
20:00:33,789 ERROR [STDERR]     at
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
20:00:33,789 ERROR [STDERR]     at
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
20:00:33,789 ERROR [STDERR]     at
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:334)
20:00:33,789 ERROR [STDERR]     at
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
20:00:33,789 ERROR [STDERR]     at
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
20:00:33,789 ERROR [STDERR]     at
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
20:00:33,789 ERROR [STDERR]     at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
20:00:33,789 ERROR [STDERR]     at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
20:00:33,789 ERROR [STDERR]     at
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
20:00:33,789 ERROR [STDERR]     at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
20:00:33,789 ERROR [STDERR]     at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
20:00:33,789 ERROR [STDERR]     at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
20:00:33,789 ERROR [STDERR]     at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
20:00:33,789 ERROR [STDERR]     at
org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
20:00:33,789 ERROR [STDERR]     at
org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
20:00:33,805 ERROR [STDERR]     at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
20:00:33,805 ERROR [STDERR]     at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
20:00:33,805 ERROR [STDERR]     at
org.jboss.web.tomcat.tc5.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:156)
20:00:33,805 ERROR [STDERR]     at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
20:00:33,805 ERROR [STDERR]     at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
20:00:33,805 ERROR [STDERR]     at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
20:00:33,805 ERROR [STDERR]     at
org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
20:00:33,805 ERROR [STDERR]     at
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
20:00:33,805 ERROR [STDERR]     at
org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
20:00:33,805 ERROR [STDERR]     at java.lang.Thread.run(Thread.java:595)


Mike Kienenberger wrote:
> 
> That's kinda odd.
> 
> Try this:
> 
> 
>     private void _hasContext()
>     {
>         FacesContext context = FacesContext.getCurrentInstance();
>         if (context != null)
>         {
>             HttpSession session =
> (HttpSession)context.getExternalContext().getSession(false);
>             System.out.println("session id = " + session.getId());
>         }
>         else
>         {
>             new Exception("context is null!").printStackTrace();
>         }
>     }
> 
> Let's find out what's going on when this is called.
> 
> On 4/28/07, Trumml <Martin.Trummer@systema.info> wrote:
>>
>> That's why I added the war file
>> [http://www.nabble.com/file/8109/ce.tests.war
>> ce.tests.war] which is deployed correctly in JBoss...
>>
>> Part of the jboss ouput:
>> 14:08:45,234 INFO  [ConnectionFactoryBindingService] Bound
>> ConnectionManager
>> 'jboss.jca:service=ConnectionFactoryBinding,name=JmsXA' to JNDI name 'jav
>> a:JmsXA'
>> 14:08:46,375 INFO  [TomcatDeployer] deploy, ctxPath=/ce.tests,
>> warUrl=.../tmp/deploy/tmp64783ce.tests-exp.war/
>> 14:08:46,687 INFO  [FacesConfigurator] Reading standard config
>> org/apache/myfaces/resource/standard-faces-config.xml
>> 14:08:46,796 INFO  [FacesConfigurator] Reading config
>> jar:file:/C:/DOKUME~1/martin6/LOKALE~1/Temp/myfaces64784.jar!/META-INF/faces-config.xml
>> 14:08:47,015 INFO  [FacesConfigurator] Reading config
>> jar:file:/C:/DOKUME~1/martin6/LOKALE~1/Temp/myfaces64785.jar!/META-INF/faces-config.xml
>> 14:08:47,437 INFO  [FacesConfigurator] Reading config
>> /WEB-INF/faces-config.xml
>> 14:08:56,937 INFO  [StartupServletContextListener] ServletContext
>> 'D:\jboss-4.0.5.ga\server\default\.\tmp\deploy\tmp64783ce.tests-exp.war\'
>> initialize
>> d.
>> 14:08:56,937 INFO  [MyFacesServlet] MyFacesServlet for context
>> 'D:\jboss-4.0.5.ga\server\default\.\tmp\deploy\tmp64783ce.tests-exp.war\'
>> initialized.
>> 14:08:57,109 INFO  [TomcatDeployer] deploy, ctxPath=/jmx-console,
>> warUrl=.../deploy/jmx-console.war/
>> 14:08:57,437 INFO  [Http11BaseProtocol] Starting Coyote HTTP/1.1 on
>> http-0.0.0.0-8080
>> 14:08:57,609 INFO  [ChannelSocket] JK: ajp13 listening on /0.0.0.0:8009
>> 14:08:57,625 INFO  [JkMain] Jk running ID=0 time=0/47  config=null
>> 14:08:57,625 INFO  [Server] JBoss (MX MicroKernel) [4.0.5.GA (build:
>> CVSTag=Branch_4_0 date=200610162339)] Started in 40s:688ms
>> 14:09:13,140 INFO  [tests]] No state saving method defined, assuming
>> default
>> server state saving
>> 14:09:13,453 INFO  [STDOUT] Using bean id 1
>> 14:09:13,453 INFO  [STDOUT] context is null!
>> 14:09:13,453 INFO  [STDOUT] Duke's number: 7
>> 14:09:13,468 INFO  [STDOUT] context is null!
>>
>>
>> Mike Kienenberger wrote:
>> >
>> > I'm assuming you're asking why your backing bean code isn't being
>> > called from inside the JSF lifecycle.
>> >
>> > I don't know.  You haven't provided any information about what code is
>> > being called or how.
>> >
>> >
>> > On 4/27/07, Trumml <Martin.Trummer@systema.info> wrote:
>> >>
>> >> Well, thanks for the fast answer but what do you mean by "executing
>> >> external
>> >> to JSF"?
>> >> Why isn't my backing bean inside the JSF lifecycle?
>> >>
>> >>
>> >> Mike Kienenberger wrote:
>> >> >
>> >> > I'm changing this to the users@myfaces mailing list.   The dev list
>> is
>> >> > for working on the MyFaces source code.
>> >> >
>> >> > FacesContext.getCurrentInstance() is only non-null during the JSF
>> >> > lifecycle.
>> >> > Apparently you're executing your backing bean code external to JSF.
>> >> >
>> >> > On 4/27/07, Trumml <Martin.Trummer@systema.info> wrote:
>> >> >>
>> >> >> I want to access the HTTP session inside of a backing bean.
>> >> >> I use jboss-4.0.5 and the attached war file:
>> >> >> http://www.nabble.com/file/8109/ce.tests.war ce.tests.war
>> >> >> But FacesContext.getCurrentInstance() always returns null :-(
>> >> >>
>> >> >> Can anyone give me some help?
>> >> >>
>> >> >> --
>> >> >> View this message in context:
>> >> >>
>> >>
>> http://www.nabble.com/Access-to-context-of-HTTP-session-tf3657714.html#a10219374
>> >> >> Sent from the My Faces - Dev mailing list archive at Nabble.com.
>> >> >>
>> >> >>
>> >> >
>> >> >
>> >>
>> >> --
>> >> View this message in context:
>> >>
>> http://www.nabble.com/Re%3A-Access-to-context-of-HTTP-session-tf3657743.html#a10219687
>> >> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>> >>
>> >>
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Re%3A-Access-to-context-of-HTTP-session-tf3657743.html#a10232407
>> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>>
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/Re%3A-Access-to-context-of-HTTP-session-tf3657743.html#a10235833
Sent from the MyFaces - Users mailing list archive at Nabble.com.


Mime
View raw message