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 <[EMAIL PROTECTED]> 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 <[EMAIL PROTECTED]> 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 [EMAIL PROTECTED] 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 <[EMAIL PROTECTED]> 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.