I encountered the same problem. I have a portlet that produces a PNG image. The portlet writes the PNG data to the PortletOutputStream.
I am using jboss-portal-2.4.1-cr1 (JBoss Portal + JBoss bundle)
I found a flaw in my portlet.xml file:
<supports> <mime-type>text/html</mime-type> <portlet-mode>EDIT</portlet-mode> <portlet-mode>VIEW</portlet-mode> <portlet-mode>HELP</portlet-mode> </supports>
I'll change the mime-type to image/png and post the results later today.
I fixed my portlet.xml file but I don't think JBoss Portlal can handle a portlet that produces image/png data.
On the OpenSymphony message board, I found a discussion about producing image output from a portlet:
Nils-Helge Garli wrote:
> Hm... I might have been wrong about it. Maybe you can't generate
> image output from a portlet. Didn't see anything about that in the
> portlet spec (maybe someone can enlighten me?).
There's nothing that prohibits it, but there's also nothing that
supports it, other than the call to response.setContentType();
What a portal has to do is define a custom window state that says
"display only this portlet". When the portlet is rendered with such a
state it can assume that it will "own" the output, and can thus create
images or Excel reports or whatever.
The usual workaround for portals that doesn't have such a window state
is to link to a servlet that can generate the data instead. Using a
servlet is worse, however, since it cannot leverage any security
configuration that a portlet would be able to, and would have to ensure
on its own that any call is legitimate. But sometimes that is ok.
In the Portle 2.0 specification, the portlet class may implement the javax.portlet.ResourceServingPortlet interface
public interface ResourceServingPortlet
The ResourceServingPortlet interface allows serving resources through the portlet.
The portlet container must call this method for links created by the RenderResponse.createResouceURL() call. If the portlet creates resource URLs with RenderResponse.createResouceURL() it must implement this listener.
The ResourceServingPortlet interface contains this method:
void serveResource(ResourceRequest request,
Called by the portlet container to allow the portlet to generate the resouce content based on its current state. The portal / portlet container must not render any output in addition to the content returned by the portlet. The portal / portlet container should expect that the portlet may return binary content for a renderResource call.
We don't support Portlet 2.0, yet.
So to serve your binaries, you will have to dispatch to a servlet, from the portlet, and have the servlet stream the binary.
i hai the same problem discussed here but i'm going to fighting with an application/pdf mime tipe.
the proble is analogous, what change is the type of output returned.
I have developed a CMS portlet that contain a link to my PDF file that is stored in the CMS too, but now i need to open the pdf content only within a window, reading the PDF file from a CMS
I have already set the returned mime type in my portlet implementation
and in my portlet.xml
but as result i have only seen a "wonderful", unlimited stack trace in my server's log that say:
java.lang.IllegalArgumentException: Content type not accepted
Caused by: javax.activation.MimeTypeParseException: Type [application/pdf] not supported
any advice will be appreciated!!!
I use jboss portal 2.6.5
avelendino, you should not have attached your question to a two year old topic, you should have started a new topic instead.
The error message means exactly what is says - the only mime type supported by portlets is text/html. The only way you can supply a PDF to your users is to provide a link to the PDF within CMS. Or you could write code that reads the PDF and converts it to HTML. (Hey, a tag that did this would probably be a big hit!)