You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-users@xmlgraphics.apache.org by Damir Todorovac <d_...@yahoo.com> on 2003/10/29 13:40:51 UTC

Problem with gif images within war files

I'm using fop 0.20.4 in a servlet which runs on wls
6.1. We create pdfs which consist of text and gifs.
The gif images are located in a jar file which is
under WEB-INF/lib of the war file. I'm retrieving the
URL of the gif with 


Thread.getCurrentThread().getContextClassLoader().getResource("logo.gif")

The returned url is used in the 'src' attribute of the
'fo:external-graphic' tag:

<fo:external-graphic
src="zip:C:/apps/Tip210/cs/websrv/bin/wls615/wlserver6.1/config/dochelper_2005/applications/.wlnotdelete/wlap61515/WEB-INF/_tmp_war_dochelper_2005_dochelper_2005_server_dochelpertest/WEB-INF/lib/image
s61077.jar!/images/logo.gif">
</fo:external-graphic>

While rendering the following error is reported:

Error in XObject : Error while loading image
zip:C:/apps/Tip210/cs/websrv/bin/wls615/wlserver6.1/config/dochelper_2005/applications/.wlnotdelete/wlap61515/WEB-INF/_tmp_war_dochelper_2005_dochelper_2005_server_dochelpertest/WEB-INF/lib/image
s61077.jar!/images/logo.gif : class
java.lang.NullPointerException - null 

The NullPointerException is thrown by the following
code in the method loadImage() of the class
org.apache.fop.image.GifImage:

ImageProducer ip =
(ImageProducer)this.m_href.getContent()

I tested the same with gifs which reside under the
document root of the war file. In this case i retrieve
the url with 

	getServletContext().getResource("logo.gif")

The error is the same. With jpegs it works fine. The
loadImage() method of org.apache.fop.image.JpegImage
is loading the jpeg with an input stream. I don't know
if this error only occurs in WLS, but i suggest to
also use input streams in the loadImage() method of
GifImage.  

regards,

Damir  

__________________________________
Do you Yahoo!?
Exclusive Video Premiere - Britney Spears
http://launch.yahoo.com/promos/britneyspears/

---------------------------------------------------------------------
To unsubscribe, e-mail: fop-user-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-user-help@xml.apache.org


RE: Problem with gif images within war files

Posted by "Andreas L. Delmelle" <a_...@pandora.be>.
> -----Original Message-----
> From: Damir Todorovac [mailto:d_todorovac@yahoo.com]
>
> I don't agree with you. The url is absolutely correct.
> Read rfc 1738 http://www.w3.org/Addressing/rfc1738.txt
>

Your objection is duly noted --but doesn't change the fact that the
mentioned RFC *NOWHERE* states that this is allowed (except for 'mailto:'
and 'news:' URLs). On the contrary, for every other special URL ( 'http:',
'ftp:', 'nntp:', 'telnet:' ... ) these are required, as well as for every
other type of generic URL which is based on the IP schemepart.

A very common example is the 'file:' URL. It is mentioned in this context in
numerous Java books. It works and will be interpreted correctly, but
actually it is not even a *valid* URL.

Apart from that, your suggestion looks good and will certainly be taken into
consideration.
( although I'm not sure whether the supplementary introduction of the
Toolkit object has certain pitfalls... )

Greetz,

Andreas


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-user-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-user-help@xml.apache.org


RE: Problem with gif images within war files

Posted by Damir Todorovac <d_...@yahoo.com>.
I don't agree with you. The url is absolutely correct.
Read rfc 1738 http://www.w3.org/Addressing/rfc1738.txt

Fact is, that the loadImage() method of
org.apache.fop.image.GifImage does not work with
Weblogic when gif images reside within war files. The
problem is url.getContent() which throws a
NullPointerException. Custom resolvers for URLs don't
solve this problem as you mentioned. In my opinion the
loadImage() method needs to be changed. Otherwise
using gif images which are located in war files will
not work with Weblogic. 

I found the following workaround for loadImage(), i
just replaced 

ImageProducer ip =
(ImageProducer)this.m_href.getContent();

with 

Toolkit toolkit = Toolkit.getDefaultToolkit();
Image image = toolkit.getImage(m_href);
ImageProducer ip = image.getSource();

This works fine. The fop developers should consider to
change the implementation of loadImage().

regards,

Damir

--- "Andreas L. Delmelle" <a_...@pandora.be>
wrote:
> > -----Original Message-----
> > From: Damir Todorovac
> [mailto:d_todorovac@yahoo.com]
> >
> > I'm using fop 0.20.4 in a servlet which runs on
> wls
> > 6.1. We create pdfs which consist of text and
> gifs.
> > The gif images are located in a jar file which is
> > under WEB-INF/lib of the war file. I'm retrieving
> the
> 
> <snip />
> 
> > The returned url is used in the 'src' attribute of
> the
> > 'fo:external-graphic' tag:
> >
> > <fo:external-graphic
> >
>
src="zip:C:/apps/Tip210/cs/websrv/bin/wls615/wlserver6.1/config/do
> >
>
chelper_2005/applications/.wlnotdelete/wlap61515/WEB-INF/_tmp_war_
> >
>
dochelper_2005_dochelper_2005_server_dochelpertest/WEB-INF/lib/image
> > s61077.jar!/images/logo.gif">
> > </fo:external-graphic>
> 
> First of all: the above URL is actually not a URL.
> At the least, it should
> be sth like
> 'zip://' etc.
> 
> Secondly, try to use
> <fo:external-graphic src="url(...)" /> (place the
> above url between the
> brackets)
> 
> And if that doesn't do the trick, I recall a post
> from a week or two ago
> about this very same type of problem. *The*
> suggested solution is to write a
> custom Resolver for this type of URL, although WRT
> details I can't help you
> any further (as I've not really an idea on how to do
> that), but I'm sure
> there's someone over here who can provide you with
> more info about that, so
> if the first tip doesn't work, be sure to re-post
> this issue. (-- or google
> around a bit for 'custom url resolvers'...)
> 
> Hope this helps!
> 
> Greetz,
> 
> Andreas
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> fop-user-unsubscribe@xml.apache.org
> For additional commands, e-mail:
> fop-user-help@xml.apache.org
> 


__________________________________
Do you Yahoo!?
Exclusive Video Premiere - Britney Spears
http://launch.yahoo.com/promos/britneyspears/

---------------------------------------------------------------------
To unsubscribe, e-mail: fop-user-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-user-help@xml.apache.org


RE: Problem with gif images within war files

Posted by Glen Mazza <gr...@yahoo.com>.
I had a similar problem, within a servlet, and was
warned not to explicitly hardcode paths for code that
will be deployed in an unexploded WAR file
(http://marc.theaimsgroup.com/?l=struts-user&m=105761364603542&w=2).
 I don't know how helpful this issue might be to your
problem, however.

Please let us know what works for you so others can
learn about this.

Glen

--- "Andreas L. Delmelle" <a_...@pandora.be>
wrote:
> > -----Original Message-----
> > From: Damir Todorovac
> [mailto:d_todorovac@yahoo.com]
> >
> > I'm using fop 0.20.4 in a servlet which runs on
> wls
> > 6.1. We create pdfs which consist of text and
> gifs.
> > The gif images are located in a jar file which is
> > under WEB-INF/lib of the war file. I'm retrieving
> the
> 
> <snip />
> 
> > The returned url is used in the 'src' attribute of
> the
> > 'fo:external-graphic' tag:
> >
> > <fo:external-graphic
> >
>
src="zip:C:/apps/Tip210/cs/websrv/bin/wls615/wlserver6.1/config/do
> >
>
chelper_2005/applications/.wlnotdelete/wlap61515/WEB-INF/_tmp_war_
> >
>
dochelper_2005_dochelper_2005_server_dochelpertest/WEB-INF/lib/image
> > s61077.jar!/images/logo.gif">
> > </fo:external-graphic>
> 
> First of all: the above URL is actually not a URL.
> At the least, it should
> be sth like
> 'zip://' etc.
> 
> Secondly, try to use
> <fo:external-graphic src="url(...)" /> (place the
> above url between the
> brackets)


__________________________________
Do you Yahoo!?
Exclusive Video Premiere - Britney Spears
http://launch.yahoo.com/promos/britneyspears/

---------------------------------------------------------------------
To unsubscribe, e-mail: fop-user-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-user-help@xml.apache.org


RE: Problem with gif images within war files

Posted by "Andreas L. Delmelle" <a_...@pandora.be>.
> -----Original Message-----
> From: Damir Todorovac [mailto:d_todorovac@yahoo.com]
>
> I'm using fop 0.20.4 in a servlet which runs on wls
> 6.1. We create pdfs which consist of text and gifs.
> The gif images are located in a jar file which is
> under WEB-INF/lib of the war file. I'm retrieving the

<snip />

> The returned url is used in the 'src' attribute of the
> 'fo:external-graphic' tag:
>
> <fo:external-graphic
> src="zip:C:/apps/Tip210/cs/websrv/bin/wls615/wlserver6.1/config/do
> chelper_2005/applications/.wlnotdelete/wlap61515/WEB-INF/_tmp_war_
> dochelper_2005_dochelper_2005_server_dochelpertest/WEB-INF/lib/image
> s61077.jar!/images/logo.gif">
> </fo:external-graphic>

First of all: the above URL is actually not a URL. At the least, it should
be sth like
'zip://' etc.

Secondly, try to use
<fo:external-graphic src="url(...)" /> (place the above url between the
brackets)

And if that doesn't do the trick, I recall a post from a week or two ago
about this very same type of problem. *The* suggested solution is to write a
custom Resolver for this type of URL, although WRT details I can't help you
any further (as I've not really an idea on how to do that), but I'm sure
there's someone over here who can provide you with more info about that, so
if the first tip doesn't work, be sure to re-post this issue. (-- or google
around a bit for 'custom url resolvers'...)

Hope this helps!

Greetz,

Andreas


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-user-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-user-help@xml.apache.org