Skip to main content

Include JAI in a .war package?

5 replies [Last post]
danmichaelson
Offline
Joined: 2009-01-28
Points: 0

Hi,

Is it possible to include JAI entirely in a .war package (a web application for Tomcat)? That format is my deliverable for a web application hosted on a university Tomcat web server, along with many other university web applications; JAI is a dependency of my web app.

Previously I have asked university sysadmins to install JAI in the server's JRE, and they did so. The problem is when they upgraded the operating system a while ago, they temporarily lost JAI, leading to some confusion; subsequently they asked me to deliver the next version of my web app without "external" dependencies, if possible. It was a reasonable request, but is this possible, with JAI?

Thanks for any insight.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
mattiasj
Offline
Joined: 2007-10-11
Points: 0

Please note that adding jai_codec.jar to your WAR may trigger ClassLoader leaks which will cause java.lang.OutOfMemoryError: PermGen space if the webapp is redeployed enough times.

See http://java.net/jira/browse/JAI_CORE-155

Nidel, Mike

the real question is the native libraries. if you need them for performance, you just need to put them on the system path when tomcat runs. i guess that would depend on whoever administers your tomcat server. if you can't do that, i don't know of a way to have native libraries be visible within a webapp. you could just get by with the pure java implementations.

Mike

> -----Original Message-----
> From: jai-interest@javadesktop.org [mailto:jai-
> interest@javadesktop.org]
> Sent: Wednesday, January 28, 2009 10:38 AM
> To: interest@jai.dev.java.net
> Subject: [JAI] Include JAI in a .war package?
>
> Hi,
>
> Is it possible to include JAI entirely in a .war package (a web
> application for Tomcat)? That format is my deliverable for a web
> application hosted on a university Tomcat web server, along with many
> other university web applications; JAI is a dependency of my web app.
>
> Previously I have asked university sysadmins to install JAI in the
> server's JRE, and they did so. The problem is when they upgraded the
> operating system a while ago, they temporarily lost JAI, leading to
> some confusion; subsequently they asked me to deliver the next version
> of my web app without "external" dependencies, if possible. It was a
> reasonable request, but is this possible, with JAI?
>
> Thanks for any insight.
> [Message sent by forum member 'danmichaelson' (danmichaelson)]
>
> http://forums.java.net/jive/thread.jspa?messageID=328666
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
> For additional commands, e-mail: interest-help@jai.dev.java.net

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
For additional commands, e-mail: interest-help@jai.dev.java.net

danmichaelson
Offline
Joined: 2009-01-28
Points: 0

I think I can get by without native libraries for performance.

In that case, is it enough to put the pure-Java JAI .jar's in the lib folder of my webapp?

I noticed in a doc that I may to do set a system property to suppress warnings about missing native library; is that possible to do purely within the context of my web app?

The problem is I develop on OS X which I believe ships with a native JAI, so it's hard for me to test this.

Thanks very much.

Nidel, Mike

putting the pure java jars in your webapp should work. there are some
tricky situations you can get into with statics if you were to have
multiple webapps try to use JAI. but as long as yours is the only one
you're ok.

you can do a System.setProperty() to set the property to suppress the
warnings. as long as you do it before the native libraries are attempted
to be loaded you should be ok. trouble is you don't know exactly what
part of your app will be loaded first. maybe if you have a servlet that
loads on startup, you could put it in the init() or the static initializer.

this is ugly hackish stuff. i've had to deal with this kind of thing a lot
and i wish there were a better way to bundle libraries into a web container.

> -----Original Message-----
> From: jai-interest@javadesktop.org [mailto:jai-
> interest@javadesktop.org]
> Sent: Wednesday, January 28, 2009 11:08 AM
> To: interest@jai.dev.java.net
> Subject: Re: RE: [JAI] Include JAI in a .war package?
>
> I think I can get by without native libraries for performance.
>
> In that case, is it enough to put the pure-Java JAI .jar's in the lib
> folder of my webapp?
>
> I noticed in a doc that I may to do set a system property to suppress
> warnings about missing native library; is that possible to do purely
> within the context of my web app?
>
> The problem is I develop on OS X which I believe ships with a native
> JAI, so it's hard for me to test this.
>
> Thanks very much.
> [Message sent by forum member 'danmichaelson' (danmichaelson)]
>
> http://forums.java.net/jive/thread.jspa?messageID=328680
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
> For additional commands, e-mail: interest-help@jai.dev.java.net

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
For additional commands, e-mail: interest-help@jai.dev.java.net

Fabrizio Giudici

Nidel, Mike wrote:
> putting the pure java jars in your webapp should work. there are some
> tricky situations you can get into with statics if you were to have
> multiple webapps try to use JAI. but as long as yours is the only one
> you're ok.
>
> you can do a System.setProperty() to set the property to suppress the
> warnings. as long as you do it before the native libraries are attempted
> to be loaded you should be ok. trouble is you don't know exactly what
> part of your app will be loaded first. maybe if you have a servlet that
> loads on startup, you could put it in the init() or the static initializer.
>
Better point is a listener of the ServletContext, which is for sure
created before everything goes on line.
> this is ugly hackish stuff. i've had to deal with this kind of thing a lot
> and i wish there were a better way to bundle libraries into a web container.
>
>

--
Fabrizio Giudici - Java Architect, Project Manager
Tidalwave s.a.s. - "We make Java work. Everywhere."
weblogs.java.net/blog/fabriziogiudici - www.tidalwave.it/blog
Fabrizio.Giudici@tidalwave.it - mobile: +39 348.150.6941

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
For additional commands, e-mail: interest-help@jai.dev.java.net