*“Don't cross the streams.”*

—
"Hell hath no limits, nor is circumscrib'd In one self-place; but where we
are is hell, And where hell is, there must we ever be" --Christopher
Marlowe, Doctor Faustus (v. 111-13)


On Mon, Apr 14, 2025 at 17:23 Chuck Caldarale <n82...@gmail.com> wrote:

>
> > On 2025 Apr 14, at 15:57, Thad Humphries <thad.humphr...@gmail.com>
> wrote:
> >
> > Thank you, Mark. Copying both jai-imageio jars into $CATALINA_BASE/lib
> > works.
>
>
> Hopefully, you moved the jars (as Mark suggested) rather than just copying
> them. Putting the same jar in multiple places in a branch of the class
> loader tree can lead to all sorts of “interesting” problems...
>
>   - Chuck
>
>
> > On Mon, Apr 14, 2025 at 6:13 AM Mark Thomas <ma...@apache.org> wrote:
> >
> >> Thad,
> >>
> >> A quick read of https://github.com/jai-imageio/jai-imageio-core
> suggests
> >> a possible cause.
> >>
> >> The library is using the SPI plugin mechanism of ImageIO.
> >>
> >> I haven't confirmed this with a code inspection but what I assume is
> >> happening is that the web application is registering an extension at the
> >> JRE level with ImageIO but with the implementation only visible to the
> >> web application. With multiple web applications you are ending up with a
> >> single registration (not sure if it is the first or the last web
> >> application that tries to register it) and all web applications try and
> >> use the same one.
> >>
> >> I'm surprised you didn't have CNFE even when using the same version in
> >> multiple web applications.
> >>
> >> The fix is to move the library JARs out of the web application and into
> >> $CATALINA_BASE/lib. That way you will have a single registration that is
> >> visible to all web applications. That assumes there is a version that
> >> will work for all the web applications. If the web applications need
> >> different versions you will likely need a Tomcat instance for each
> version.
> >>
> >> HTH,
> >>
> >> Mark
> >>
> >> On 12/04/2025 21:22, Thad Humphries wrote:
> >>> I have a problem that appears to be one webapp in Tomcat 9 having a
> >> portion
> >>> of its classpath masked by another webapp. I am running Tomcat 9
> >> (versions
> >>> see below) on macOS 15.4 with Amazon's OpenJDK 11.0.22+7-LTS.
> >>>
> >>> I have 3 webapps all of which use PDFBox 2 and jai-imageio-core
> >>> (standalone) v1.4.0, largely for converting pages of a PDF to a Java
> >>> BufferedImage and then to PNG for display in a browser. None of these
> >>> webapps use com.twelvemonkeys.imageio.
> >>>
> >>> Last week I was presented with a PDF with JPEG2000 images on some
> pages.
> >>> Having no luck on a command line with PDFBox 2 and
> jai-imageio-jpeg2000,
> >> I
> >>> tried PDFBox 3. That worked so I updated my most recent app to PDFBox 3
> >> and
> >>> added jai-imageio-jpeg2000. That worked fine from NetBeans and the
> Tomcat
> >>> 9.0.67 dev server. However when I deployed my app to Tomcat 9.0.80 with
> >> the
> >>> other two apps, the JPEG2000 images failed, producing this in my app's
> >> log:
> >>>
> >>> ERROR PDFStreamEngine.operatorException() - Cannot read JPEG2000 image:
> >>> Java Advanced Imaging (JAI) Image I/O Tools are not installed
> >>> org.apache.pdfbox.filter.MissingImageReaderException: Cannot read
> >> JPEG2000
> >>> image: Java Advanced Imaging (JAI) Image I/O Tools are not installed
> >>> at org.apache.pdfbox.filter.Filter.findImageReader(Filter.java:171)
> >>> ~[pdfbox-3.0.4.jar:3.0.4]
> >>> ...
> >>>
> >>> Both jai-imageio-core and jai-imageio-jpeg2000 are in WEB-INF/lib so
> why
> >>> wasn't JPEG2000 found?
> >>>
> >>> I downloaded Tomcat 9.0.104 and deployed my new app. The JPEG2000
> images
> >>> were fine. I installed one of the older apps via manager, and my new
> app
> >>> still worked. I restarted Tomcat and the images failed. Then I copied
> >>> jai-imageio-jpeg2000 to the old app's WEB-INF/lib, restarted Tomcat,
> and
> >>> the JPEG2000 images were again fine.
> >>>
> >>> I've since tried this test with both 9.0.80 and 9.0.104 and see the
> same
> >>> results. Interestingly, on startup I see the older app's deployment
> >>> descriptor loads first in catalina.out. I understand the order is
> >>> non-deterministic, but it appears that if the first webapp with
> >>> jai-imageio-core does not jai-imageio-jpeg2000 with it, the second app
> >>> can't find jai-imageio-jpeg2000 in its WEB-INF/lib.
> >>>
> >>> I know jai-imageio in webapps is a strange beast, going back to the
> >>> original Sun versions and Tomcat 4 and 5. When I was running
> >> TwelveMonkeys
> >>> I had a special context listener for that library, but I dropped that
> >>> library years ago because jai-imageio-core standalone was all I needed.
> >>>
> >>> Any thoughts, ideas, or known problems with the combinations I've
> >> described
> >>> above? Any solutions other than copying jai-imageio-jpeg2000 to the
> other
> >>> apps' WEB-INF/lib?
> >>>
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
> >> For additional commands, e-mail: users-h...@tomcat.apache.org
> >>
> >>
> >
> > --
> > "Hell hath no limits, nor is circumscrib'd In one self-place; but where
> we
> > are is hell, And where hell is, there must we ever be" --Christopher
> > Marlowe, *Doctor Faustus* (v. 111-13)
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: users-h...@tomcat.apache.org
>
>

Reply via email to