You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by Marco de Booij <ma...@debooy.eu> on 2012/08/26 18:30:49 UTC

HttpServletResponse

Hello,

I have a technical question.

I use:
   - apache-tomee-plus-1.1.0-SNAPSHOT from August 24
   - Ubuntu 12.04
   - java version "1.6.0_24"
     OpenJDK Runtime Environment (IcedTea6 1.11.3) 
(6b24-1.11.3-1ubuntu0.12.04.1)
     OpenJDK 64-Bit Server VM (build 20.0-b12, mixed mode)

I have an application with a JSF Managed Bean (export) that generates a 
PDF file and returns it to the browser. I call the Managed Bean as follows:
     ExportManager exportBean  = (ExportManager) 
FacesContext.getCurrentInstance().getApplication().getELResolver().getValue(context.getELContext(), 
null, "export");
     exportBean.export(exportData);

I do not want to put this bean in every application that I make. This 
way I only have the JasperReport and its dependent libraries once.
So to access this bean from other applications I can not do it this way 
(or am I wrong?). I make it a remote bean so I can define it with an 
@EJB annotation or through a JNDI lookup. This does not work because the 
FacesContext is null:
       HttpServletResponse response  = (HttpServletResponse) 
FacesContext.getCurrentInstance().getExternalContext().getResponse();

I tried to find how to get the HttpServletResponse but I could not. 
Passing the HttpServletResponse is a solution that is discouraged.

So my question is: "What is the best way to do this?" A WebService looks 
heavy to me since I only have 1 application server involved.

I got it working a while ago in Glassfish. Forgot how and I lost the war 
file and sources

Regards,

Marco


Re: Not rendering JSF tags to HTML/XHTML

Posted by David Nordahl <da...@thinkology.org>.
What file do I update that setting in, and will that affect the .jsp 
files I have?

On 08/26/2012 12:54 PM, Romain Manni-Bucau wrote:
> Xhtml is not the default extension,
>
> Maybe redefine it
> Le 26 août 2012 19:53, "David Nordahl" <da...@thinkology.org> a écrit :
>
>> I'm not getting JSF tags rendered to HTML/XHTML. I'm using the SNAPSHOT. I
>> notice the errors "INFO: faces config file is null" even though I have the
>> file faces-config.xml in my WEB-INF folder from the root folder of my war
>> file.  The file contains:
>>
>> <?xml version='1.0' encoding='UTF-8'?>
>>
>> <faces-config version="2.1"
>>      xmlns="http://java.sun.com/**xml/ns/javaee<http://java.sun.com/xml/ns/javaee>
>> "
>>      xmlns:xsi="http://www.w3.org/**2001/XMLSchema-instance<http://www.w3.org/2001/XMLSchema-instance>
>> "
>>      xsi:schemaLocation="http://**java.sun.com/xml/ns/javaee<http://java.sun.com/xml/ns/javaee>
>> http://java.sun.com/xml/ns/**javaee/web-facesconfig_2_1.xsd<http://java.sun.com/xml/ns/javaee/web-facesconfig_2_1.xsd>
>> **">
>>      <application>
>>          <resource-bundle>
>>              <base-name>/Bundle</base-name>
>>              <var>bundle</var>
>>          </resource-bundle>
>>      </application>
>> </faces-config>
>>
>> But then later on it seems to load it as viewable in the attached log
>> file, but then just after that it repeats the above errors again.
>>
>> Then I have the errors:  "WARNING: No mappings of FacesServlet found.
>> Abort destroy MyFaces."
>>
>> But present in my web.xml file is:
>>
>>      <context-param>
>> <param-name>javax.faces.**PROJECT_STAGE</param-name>
>>          <param-value>Development</**param-value>
>>      </context-param>
>>      <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>
>>
>> Attached the log output.
>>
>>
>>
>>
>>
>>
>>


Re: Myfaces errors / FacesContext not found

Posted by David Nordahl <da...@thinkology.org>.
I will check out the examples, but perhaps I am moving in the right 
direction now:

I replaced jsf libraries in my project with the myfaces ones, and now I 
get the following errors compiling my jsps:

package com.sun.faces.taglib.jsf_core does not exist
     com.sun.faces.taglib.jsf_core.ViewTag _jspx_th_f_view_0 = 
(_jspx_resourceInjector != null) ? 
_jspx_resourceInjector.createTagHandlerInstance(com.sun.faces.taglib.jsf_core.ViewTag.class) 
: new com.sun.faces.taglib.jsf_core.ViewTag();

 From what I've read in forums, I think this means it is trying to use 
Sun RI instead of Myfaces?

I'm not sure where the directive to use MyFaces over RI is set.

This particular error is referencing the line in my jsps: <f:view> but 
the taglib I see used in examples for RI and Myfaces is both: <%@taglib 
uri="http://java.sun.com/jsf/core" prefix="f" %> but for prefix "t" I 
see an Apache URI used.


On 08/26/2012 06:11 PM, Vishwanath Krishnamurthi wrote:
> Hi David,
>
> We have about three examples on JSF. Could you compare against it to see
> what might be wrong ?
>
> https://svn.apache.org/repos/asf/openejb/trunk/openejb/examples/jsf-managedBean-and-ejb
> or a similar one -
> https://svn.apache.org/repos/asf/openejb/trunk/openejb/examples/jsf-cdi-and-ejb
>
> Had updated them only recently and they work on the current snapshot.
>
> For the current error that you have - "org.apache.jasper.**JasperException:
> java.lang.RuntimeException: FacesContext not found"
> it might be that the page you accessed was not routed via the FacesServlet.
> Could you double check the url-patterns added in the web.xml and the
> address by which you are accessing the page.
>
> Also check if your page does not mix xhtml content and jsp  specfic content
> (like page directives / taglib directives)  ?
>
> A few things that may not be related to this error - but worth checking:
>
> Ensure that you don't bundle jsf related jars
> i.e these are in provided scope
>
>   <dependency>
>        <groupId>org.apache.myfaces.core</groupId>
>        <artifactId>myfaces-api</artifactId>
>        <version>2.1.8</version>
>        <scope>provided</scope>
>      </dependency>
>      <dependency>
>        <groupId>org.apache.myfaces.core</groupId>
>        <artifactId>myfaces-impl</artifactId>
>        <version>2.1.8</version>
>        <scope>provided</scope>
>      </dependency>
>
>
> web.xml header is not in the old 2.4
>
> You shouldn't be requiring a StartupServletContextPluginCha**inLoader or
> have to worry about the standard-faces-**config.xml
>
> -Vishwa
>
> On Sun, Aug 26, 2012 at 11:20 PM, David Nordahl <da...@thinkology.org>wrote:
>
>> I regenerated my project files without any xhtml files to remove that
>> variable.
>>
>> I've been trying to follow the guidelines at: http://myfaces.apache.org/**
>> extensions/scripting/**exampleconfig.html<http://myfaces.apache.org/extensions/scripting/exampleconfig.html>
>>
>> and am still having issues.  Is there a better documentation/configuration
>> checklist I should follow?
>>
>> I notice that it has an extra entry for a project's web.xml:
>>
>>      <context-param>
>>          <description>
>>              Initializes the plugins for our scripting support
>>          </description>
>> <param-name>org.apache.**myfaces.FACES_INIT_PLUGINS</**param-name>
>> <param-value>org.apache.**myfaces.extensions.scripting.**servlet.**
>> StartupServletContextPluginCha**inLoader</param-value>
>>      </context-param>
>>
>> But I don't see any StartupServletContextPluginCha**inLoader anywhere in
>> the my-faces library files included with TomEE or even in the current
>> myfaces download itself and I get an ClassNotFound exception if I try to
>> include this entry.
>>
>> I notice in the TomEE logs it mentions a WEB-INF/faces-config.xml which I
>> have defined, but also a
>> META-INF/standard-faces-**config.xml  Perhaps this is required also?
>>
>> Currently when I try to load my jsp test page, I get:
>>
>> org.apache.jasper.**JasperException: java.lang.RuntimeException:
>> FacesContext not found
>>
>>
>>
>> On 08/26/2012 12:54 PM, Romain Manni-Bucau wrote:
>>
>>> Xhtml is not the default extension,
>>>
>>> Maybe redefine it
>>> Le 26 août 2012 19:53, "David Nordahl" <da...@thinkology.org> a écrit :
>>>
>>>   I'm not getting JSF tags rendered to HTML/XHTML. I'm using the SNAPSHOT.
>>>> I
>>>> notice the errors "INFO: faces config file is null" even though I have
>>>> the
>>>> file faces-config.xml in my WEB-INF folder from the root folder of my war
>>>> file.  The file contains:
>>>>
>>>> <?xml version='1.0' encoding='UTF-8'?>
>>>>
>>>> <faces-config version="2.1"
>>>>       xmlns="http://java.sun.com/****xml/ns/javaee<http://java.sun.com/**xml/ns/javaee>
>>>> <http://java.sun.**com/xml/ns/javaee <http://java.sun.com/xml/ns/javaee>
>>>> "
>>>>       xmlns:xsi="http://www.w3.org/****2001/XMLSchema-instance<http://www.w3.org/**2001/XMLSchema-instance>
>>>> <http:**//www.w3.org/2001/XMLSchema-**instance<http://www.w3.org/2001/XMLSchema-instance>
>>>> "
>>>>       xsi:schemaLocation="http://**j**ava.sun.com/xml/ns/javaee<http://java.sun.com/xml/ns/javaee>
>>>> <http**://java.sun.com/xml/ns/javaee <http://java.sun.com/xml/ns/javaee>
>>>> http://java.sun.com/xml/ns/****javaee/web-facesconfig_2_1.xsd<http://java.sun.com/xml/ns/**javaee/web-facesconfig_2_1.xsd>
>>>> **<http://java.sun.com/xml/ns/**javaee/web-facesconfig_2_1.xsd<http://java.sun.com/xml/ns/javaee/web-facesconfig_2_1.xsd>
>>>> **>
>>>> **">
>>>>       <application>
>>>>           <resource-bundle>
>>>>               <base-name>/Bundle</base-name>
>>>>               <var>bundle</var>
>>>>           </resource-bundle>
>>>>       </application>
>>>> </faces-config>
>>>>
>>>> But then later on it seems to load it as viewable in the attached log
>>>> file, but then just after that it repeats the above errors again.
>>>>
>>>> Then I have the errors:  "WARNING: No mappings of FacesServlet found.
>>>> Abort destroy MyFaces."
>>>>
>>>> But present in my web.xml file is:
>>>>
>>>>       <context-param>
>>>> <param-name>javax.faces.****PROJECT_STAGE</param-name>
>>>>           <param-value>Development</****param-value>
>>>>       </context-param>
>>>>       <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>
>>>>
>>>> Attached the log output.
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>


Re: Myfaces errors / FacesContext not found

Posted by Vishwanath Krishnamurthi <to...@gmail.com>.
Hi David,

We have about three examples on JSF. Could you compare against it to see
what might be wrong ?

https://svn.apache.org/repos/asf/openejb/trunk/openejb/examples/jsf-managedBean-and-ejb
or a similar one -
https://svn.apache.org/repos/asf/openejb/trunk/openejb/examples/jsf-cdi-and-ejb

Had updated them only recently and they work on the current snapshot.

For the current error that you have - "org.apache.jasper.**JasperException:
java.lang.RuntimeException: FacesContext not found"
it might be that the page you accessed was not routed via the FacesServlet.
Could you double check the url-patterns added in the web.xml and the
address by which you are accessing the page.

Also check if your page does not mix xhtml content and jsp  specfic content
(like page directives / taglib directives)  ?

A few things that may not be related to this error - but worth checking:

Ensure that you don't bundle jsf related jars
i.e these are in provided scope

 <dependency>
      <groupId>org.apache.myfaces.core</groupId>
      <artifactId>myfaces-api</artifactId>
      <version>2.1.8</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.myfaces.core</groupId>
      <artifactId>myfaces-impl</artifactId>
      <version>2.1.8</version>
      <scope>provided</scope>
    </dependency>


web.xml header is not in the old 2.4

You shouldn't be requiring a StartupServletContextPluginCha**inLoader or
have to worry about the standard-faces-**config.xml

-Vishwa

On Sun, Aug 26, 2012 at 11:20 PM, David Nordahl <da...@thinkology.org>wrote:

> I regenerated my project files without any xhtml files to remove that
> variable.
>
> I've been trying to follow the guidelines at: http://myfaces.apache.org/**
> extensions/scripting/**exampleconfig.html<http://myfaces.apache.org/extensions/scripting/exampleconfig.html>
>
> and am still having issues.  Is there a better documentation/configuration
> checklist I should follow?
>
> I notice that it has an extra entry for a project's web.xml:
>
>     <context-param>
>         <description>
>             Initializes the plugins for our scripting support
>         </description>
> <param-name>org.apache.**myfaces.FACES_INIT_PLUGINS</**param-name>
> <param-value>org.apache.**myfaces.extensions.scripting.**servlet.**
> StartupServletContextPluginCha**inLoader</param-value>
>     </context-param>
>
> But I don't see any StartupServletContextPluginCha**inLoader anywhere in
> the my-faces library files included with TomEE or even in the current
> myfaces download itself and I get an ClassNotFound exception if I try to
> include this entry.
>
> I notice in the TomEE logs it mentions a WEB-INF/faces-config.xml which I
> have defined, but also a
> META-INF/standard-faces-**config.xml  Perhaps this is required also?
>
> Currently when I try to load my jsp test page, I get:
>
> org.apache.jasper.**JasperException: java.lang.RuntimeException:
> FacesContext not found
>
>
>
> On 08/26/2012 12:54 PM, Romain Manni-Bucau wrote:
>
>> Xhtml is not the default extension,
>>
>> Maybe redefine it
>> Le 26 août 2012 19:53, "David Nordahl" <da...@thinkology.org> a écrit :
>>
>>  I'm not getting JSF tags rendered to HTML/XHTML. I'm using the SNAPSHOT.
>>> I
>>> notice the errors "INFO: faces config file is null" even though I have
>>> the
>>> file faces-config.xml in my WEB-INF folder from the root folder of my war
>>> file.  The file contains:
>>>
>>> <?xml version='1.0' encoding='UTF-8'?>
>>>
>>> <faces-config version="2.1"
>>>      xmlns="http://java.sun.com/****xml/ns/javaee<http://java.sun.com/**xml/ns/javaee>
>>> <http://java.sun.**com/xml/ns/javaee <http://java.sun.com/xml/ns/javaee>
>>> >
>>> "
>>>      xmlns:xsi="http://www.w3.org/****2001/XMLSchema-instance<http://www.w3.org/**2001/XMLSchema-instance>
>>> <http:**//www.w3.org/2001/XMLSchema-**instance<http://www.w3.org/2001/XMLSchema-instance>
>>> >
>>> "
>>>      xsi:schemaLocation="http://**j**ava.sun.com/xml/ns/javaee<http://java.sun.com/xml/ns/javaee>
>>> <http**://java.sun.com/xml/ns/javaee <http://java.sun.com/xml/ns/javaee>
>>> >
>>> http://java.sun.com/xml/ns/****javaee/web-facesconfig_2_1.xsd<http://java.sun.com/xml/ns/**javaee/web-facesconfig_2_1.xsd>
>>> **<http://java.sun.com/xml/ns/**javaee/web-facesconfig_2_1.xsd<http://java.sun.com/xml/ns/javaee/web-facesconfig_2_1.xsd>
>>> **>
>>> **">
>>>      <application>
>>>          <resource-bundle>
>>>              <base-name>/Bundle</base-name>
>>>              <var>bundle</var>
>>>          </resource-bundle>
>>>      </application>
>>> </faces-config>
>>>
>>> But then later on it seems to load it as viewable in the attached log
>>> file, but then just after that it repeats the above errors again.
>>>
>>> Then I have the errors:  "WARNING: No mappings of FacesServlet found.
>>> Abort destroy MyFaces."
>>>
>>> But present in my web.xml file is:
>>>
>>>      <context-param>
>>> <param-name>javax.faces.****PROJECT_STAGE</param-name>
>>>          <param-value>Development</****param-value>
>>>      </context-param>
>>>      <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>
>>>
>>> Attached the log output.
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>

Re: Myfaces errors / FacesContext not found

Posted by David Nordahl <da...@thinkology.org>.
I regenerated my project files without any xhtml files to remove that 
variable.

I've been trying to follow the guidelines at: 
http://myfaces.apache.org/extensions/scripting/exampleconfig.html

and am still having issues.  Is there a better 
documentation/configuration checklist I should follow?

I notice that it has an extra entry for a project's web.xml:

     <context-param>
         <description>
             Initializes the plugins for our scripting support
         </description>
<param-name>org.apache.myfaces.FACES_INIT_PLUGINS</param-name>
<param-value>org.apache.myfaces.extensions.scripting.servlet.StartupServletContextPluginChainLoader</param-value>
     </context-param>

But I don't see any StartupServletContextPluginChainLoader anywhere in 
the my-faces library files included with TomEE or even in the current 
myfaces download itself and I get an ClassNotFound exception if I try to 
include this entry.

I notice in the TomEE logs it mentions a WEB-INF/faces-config.xml which 
I have defined, but also a
META-INF/standard-faces-config.xml  Perhaps this is required also?

Currently when I try to load my jsp test page, I get:

org.apache.jasper.JasperException: java.lang.RuntimeException: FacesContext not found

  


On 08/26/2012 12:54 PM, Romain Manni-Bucau wrote:
> Xhtml is not the default extension,
>
> Maybe redefine it
> Le 26 août 2012 19:53, "David Nordahl" <da...@thinkology.org> a écrit :
>
>> I'm not getting JSF tags rendered to HTML/XHTML. I'm using the SNAPSHOT. I
>> notice the errors "INFO: faces config file is null" even though I have the
>> file faces-config.xml in my WEB-INF folder from the root folder of my war
>> file.  The file contains:
>>
>> <?xml version='1.0' encoding='UTF-8'?>
>>
>> <faces-config version="2.1"
>>      xmlns="http://java.sun.com/**xml/ns/javaee<http://java.sun.com/xml/ns/javaee>
>> "
>>      xmlns:xsi="http://www.w3.org/**2001/XMLSchema-instance<http://www.w3.org/2001/XMLSchema-instance>
>> "
>>      xsi:schemaLocation="http://**java.sun.com/xml/ns/javaee<http://java.sun.com/xml/ns/javaee>
>> http://java.sun.com/xml/ns/**javaee/web-facesconfig_2_1.xsd<http://java.sun.com/xml/ns/javaee/web-facesconfig_2_1.xsd>
>> **">
>>      <application>
>>          <resource-bundle>
>>              <base-name>/Bundle</base-name>
>>              <var>bundle</var>
>>          </resource-bundle>
>>      </application>
>> </faces-config>
>>
>> But then later on it seems to load it as viewable in the attached log
>> file, but then just after that it repeats the above errors again.
>>
>> Then I have the errors:  "WARNING: No mappings of FacesServlet found.
>> Abort destroy MyFaces."
>>
>> But present in my web.xml file is:
>>
>>      <context-param>
>> <param-name>javax.faces.**PROJECT_STAGE</param-name>
>>          <param-value>Development</**param-value>
>>      </context-param>
>>      <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>
>>
>> Attached the log output.
>>
>>
>>
>>
>>
>>
>>


Re: Not rendering JSF tags to HTML/XHTML

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Xhtml is not the default extension,

Maybe redefine it
Le 26 août 2012 19:53, "David Nordahl" <da...@thinkology.org> a écrit :

> I'm not getting JSF tags rendered to HTML/XHTML. I'm using the SNAPSHOT. I
> notice the errors "INFO: faces config file is null" even though I have the
> file faces-config.xml in my WEB-INF folder from the root folder of my war
> file.  The file contains:
>
> <?xml version='1.0' encoding='UTF-8'?>
>
> <faces-config version="2.1"
>     xmlns="http://java.sun.com/**xml/ns/javaee<http://java.sun.com/xml/ns/javaee>
> "
>     xmlns:xsi="http://www.w3.org/**2001/XMLSchema-instance<http://www.w3.org/2001/XMLSchema-instance>
> "
>     xsi:schemaLocation="http://**java.sun.com/xml/ns/javaee<http://java.sun.com/xml/ns/javaee>
> http://java.sun.com/xml/ns/**javaee/web-facesconfig_2_1.xsd<http://java.sun.com/xml/ns/javaee/web-facesconfig_2_1.xsd>
> **">
>     <application>
>         <resource-bundle>
>             <base-name>/Bundle</base-name>
>             <var>bundle</var>
>         </resource-bundle>
>     </application>
> </faces-config>
>
> But then later on it seems to load it as viewable in the attached log
> file, but then just after that it repeats the above errors again.
>
> Then I have the errors:  "WARNING: No mappings of FacesServlet found.
> Abort destroy MyFaces."
>
> But present in my web.xml file is:
>
>     <context-param>
> <param-name>javax.faces.**PROJECT_STAGE</param-name>
>         <param-value>Development</**param-value>
>     </context-param>
>     <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>
>
> Attached the log output.
>
>
>
>
>
>
>

Not rendering JSF tags to HTML/XHTML

Posted by David Nordahl <da...@thinkology.org>.
I'm not getting JSF tags rendered to HTML/XHTML. I'm using the SNAPSHOT. 
I notice the errors "INFO: faces config file is null" even though I have 
the file faces-config.xml in my WEB-INF folder from the root folder of 
my war file.  The file contains:

<?xml version='1.0' encoding='UTF-8'?>

<faces-config version="2.1"
     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-facesconfig_2_1.xsd">
     <application>
         <resource-bundle>
             <base-name>/Bundle</base-name>
             <var>bundle</var>
         </resource-bundle>
     </application>
</faces-config>

But then later on it seems to load it as viewable in the attached log 
file, but then just after that it repeats the above errors again.

Then I have the errors:  "WARNING: No mappings of FacesServlet found. 
Abort destroy MyFaces."

But present in my web.xml file is:

     <context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
         <param-value>Development</param-value>
     </context-param>
     <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>

Attached the log output.







Re: HttpServletResponse

Posted by Marco de Booij <md...@scarlet.be>.
Hello,

Thank you for the idea. It crossed my mind too but I was to much 
focussed on the HttpServletResponse side. In the same bean I also set 
all information about the PDF in the HttpServletResponse. But with your 
idea I will give up the idea to put everything in a bean. I think that I 
will create a method in a utility class that accepts the 
HttpServletResponse and the data for the PDF as a parameter. This method 
then sets the information in the HttpServletResponse and puts the stream 
in there too. I only need to code this once and it will work for all 
(future) applications.

Regards,

Marco

Op 27-08-12 11:19, Jean-Louis MONTEIRO schreef:
> Hi,
>
> If your managed bean (export) is using the Servlet Response, it seems to me
> difficult to make it work without sending the serialized object itself.
> Moreover, I agree, it's not clear at all.
>
> I would recommend to change the export bean a bit and make it work with
> common Input/OutputStream.
> Then, the caller can strean the output from the export bean in the servlet
> response and does not need to send the response itself.
>
> Hope I got the question and it helps.
> JLouis
>
>
> 2012/8/26 Marco de Booij <ma...@debooy.eu>
>
>> Hello,
>>
>> I have a technical question.
>>
>> I use:
>>    - apache-tomee-plus-1.1.0-**SNAPSHOT from August 24
>>    - Ubuntu 12.04
>>    - java version "1.6.0_24"
>>      OpenJDK Runtime Environment (IcedTea6 1.11.3)
>> (6b24-1.11.3-1ubuntu0.12.04.1)
>>      OpenJDK 64-Bit Server VM (build 20.0-b12, mixed mode)
>>
>> I have an application with a JSF Managed Bean (export) that generates a
>> PDF file and returns it to the browser. I call the Managed Bean as follows:
>>      ExportManager exportBean  = (ExportManager) FacesContext.**
>> getCurrentInstance().**getApplication().**getELResolver().getValue(**context.getELContext(),
>> null, "export");
>>      exportBean.export(exportData);
>>
>> I do not want to put this bean in every application that I make. This way
>> I only have the JasperReport and its dependent libraries once.
>> So to access this bean from other applications I can not do it this way
>> (or am I wrong?). I make it a remote bean so I can define it with an @EJB
>> annotation or through a JNDI lookup. This does not work because the
>> FacesContext is null:
>>        HttpServletResponse response  = (HttpServletResponse) FacesContext.*
>> *getCurrentInstance().**getExternalContext().**getResponse();
>>
>> I tried to find how to get the HttpServletResponse but I could not.
>> Passing the HttpServletResponse is a solution that is discouraged.
>>
>> So my question is: "What is the best way to do this?" A WebService looks
>> heavy to me since I only have 1 application server involved.
>>
>> I got it working a while ago in Glassfish. Forgot how and I lost the war
>> file and sources
>>
>> Regards,
>>
>> Marco
>>
>>


Re: HttpServletResponse

Posted by Jean-Louis MONTEIRO <je...@gmail.com>.
Hi,

If your managed bean (export) is using the Servlet Response, it seems to me
difficult to make it work without sending the serialized object itself.
Moreover, I agree, it's not clear at all.

I would recommend to change the export bean a bit and make it work with
common Input/OutputStream.
Then, the caller can strean the output from the export bean in the servlet
response and does not need to send the response itself.

Hope I got the question and it helps.
JLouis


2012/8/26 Marco de Booij <ma...@debooy.eu>

> Hello,
>
> I have a technical question.
>
> I use:
>   - apache-tomee-plus-1.1.0-**SNAPSHOT from August 24
>   - Ubuntu 12.04
>   - java version "1.6.0_24"
>     OpenJDK Runtime Environment (IcedTea6 1.11.3)
> (6b24-1.11.3-1ubuntu0.12.04.1)
>     OpenJDK 64-Bit Server VM (build 20.0-b12, mixed mode)
>
> I have an application with a JSF Managed Bean (export) that generates a
> PDF file and returns it to the browser. I call the Managed Bean as follows:
>     ExportManager exportBean  = (ExportManager) FacesContext.**
> getCurrentInstance().**getApplication().**getELResolver().getValue(**context.getELContext(),
> null, "export");
>     exportBean.export(exportData);
>
> I do not want to put this bean in every application that I make. This way
> I only have the JasperReport and its dependent libraries once.
> So to access this bean from other applications I can not do it this way
> (or am I wrong?). I make it a remote bean so I can define it with an @EJB
> annotation or through a JNDI lookup. This does not work because the
> FacesContext is null:
>       HttpServletResponse response  = (HttpServletResponse) FacesContext.*
> *getCurrentInstance().**getExternalContext().**getResponse();
>
> I tried to find how to get the HttpServletResponse but I could not.
> Passing the HttpServletResponse is a solution that is discouraged.
>
> So my question is: "What is the best way to do this?" A WebService looks
> heavy to me since I only have 1 application server involved.
>
> I got it working a while ago in Glassfish. Forgot how and I lost the war
> file and sources
>
> Regards,
>
> Marco
>
>