Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cantaloupe java opts to fix jai processor for tiffs #326

Merged

Conversation

noahwsmith
Copy link
Contributor

@noahwsmith noahwsmith commented Feb 23, 2024

We're getting errors like this on certain TIFFs:

cantaloupe-1  | java.lang.IllegalAccessError: class javax.media.jai.RasterAccessor (in unnamed module @0x665bc091) cannot access class sun.awt.image.BytePackedRaster (in module java.desktop) because module java.desktop does not export sun.awt.image to unnamed module @0x665bc091
cantaloupe-1  | 	at javax.media.jai.RasterAccessor.<init>(RasterAccessor.java:802)
cantaloupe-1  | 	at com.sun.media.jai.opimage.SubsampleAverageOpImage.computeRect(SubsampleAverageOpImage.java:269)
cantaloupe-1  | 	at javax.media.jai.GeometricOpImage.computeTile(GeometricOpImage.java:683)
cantaloupe-1  | 	at com.sun.media.jai.util.SunTileScheduler.scheduleTile(SunTileScheduler.java:904)
cantaloupe-1  | 	at javax.media.jai.OpImage.getTile(OpImage.java:1129)

The Cantaloupe boot sequence says

cantaloupe-1  | 18:06:58.351 [main] INFO  e.i.l.c.d.JRubyDelegateProxy - Loading script code
cantaloupe-1  | 2024-02-23T18:06:59.413Z [main] WARN FilenoUtil : Native subprocess control requires open access to the JDK IO subsystem
cantaloupe-1  | Pass '--add-opens java.base/sun.nio.ch=ALL-UNNAMED --add-opens java.base/java.io=ALL-UNNAMED' to enable.

@noahwsmith noahwsmith requested a review from joecorall February 23, 2024 18:35
@noahwsmith
Copy link
Contributor Author

We now have this running live and formerly erroring objects are now working - e.g.
https://compass.fivecolleges.edu/islandora/object/smith%3A771030

I didn't write an issue up for this - do we need one?

@joecorall
Copy link
Contributor

@noahwsmith - what buildkit tag were you running for cantaloupe? I'm on 3.1.2 and my docker compose looks like what's below and I am able to load e.g. https://islandora-stage.lib.lehigh.edu/cantaloupe/iiif/2/https%3A%2F%2Fcompass.fivecolleges.edu%2Fsystem%2Ffiles%2F2024-01%2Fsmith_771178_OBJ.tiff/3072,2048,1024,1024/512,/0/default.jpg OK without this change.

$ yq '.services["cantaloupe-prod"]' docker-compose.yml
{
  "restart": "no",
  "tty": true,
  "security_opt": [
    "label=type:container_runtime_t"
  ],
  "profiles": [
    "prod"
  ],
  "secrets": [],
  "environment": {
    "CANTALOUPE_PROCESSOR_SELECTION_STRATEGY": "ManualSelectionStrategy",
    "CANTALOUPE_PROCESSOR_MANUALSELECTIONSTRATEGY_JPG": "Java2dProcessor",
    "CANTALOUPE_CACHE_SERVER_DERIVATIVE_ENABLED": "true",
    "CANTALOUPE_CACHE_SERVER_DERIVATIVE": "FilesystemCache",
  },
  "image": "${ISLANDORA_REPOSITORY}/cantaloupe:${ISLANDORA_TAG}",
  "labels": {
    "traefik.http.middlewares.https-redirect.redirectscheme.permanent": true,
    "traefik.http.middlewares.https-redirect.redirectscheme.scheme": "https",
    "traefik.enable": true,
    "traefik.http.middlewares.cantaloupe-custom-request-headers.headers.customrequestheaders.X-Forwarded-Path": "/cantaloupe",
    "traefik.http.middlewares.cantaloupe-strip-prefix.stripprefix.prefixes": "/cantaloupe",
    "traefik.http.middlewares.cantaloupe.chain.middlewares": "cantaloupe-strip-prefix,cantaloupe-custom-request-headers",
    "traefik.http.routers.cantaloupe_http.entrypoints": "http",
    "traefik.http.routers.cantaloupe_http.middlewares": "https-redirect",
    "traefik.http.routers.cantaloupe_http.rule": "Host(`${DOMAIN}`) && PathPrefix(`/cantaloupe`)",
    "traefik.http.routers.cantaloupe_http.service": "cantaloupe",
    "traefik.http.routers.cantaloupe_https.middlewares": "cantaloupe",
    "traefik.http.routers.cantaloupe_https.entrypoints": "https",
    "traefik.http.routers.cantaloupe_https.rule": "Host(`${DOMAIN}`) && PathPrefix(`/cantaloupe`)",
    "traefik.http.routers.cantaloupe_https.tls": true,
    "traefik.http.services.cantaloupe.loadbalancer.server.port": 8182,
    "traefik.http.routers.cantaloupe_https.tls.certresolver": "resolver"
  },
  "volumes": [
    "/opt/islandora/volumes/cantaloupe-data:/data:rw",
    "/opt/islandora/volumes/tmp/cantaloupe:/tmp:rw"
  ],
  "networks": {
    "default": {
      "aliases": [
        "cantaloupe"
      ]
    }
  }
}

@joecorall
Copy link
Contributor

Hmm looks like maybe you're overriding the processor for TIFFs to use Jai. Should we be supporting Jai? Cantaloupe seems to advise against it

From https://cantaloupe-project.github.io/manual/4.0/processors.html#JaiProcessor

Warning

Development on JAI ended a long time ago, and a minor incompatibility has cropped up in Java 9. Given that supporting JAI is likely to become more problematic as time goes on, this processor should be considered deprecated, and it may be removed in a future release.

@noahwsmith
Copy link
Contributor Author

Yes, on this project Jai is better (except this error). Jai isn't the default (which is correct) but this PR does allow Jai to work better than it does out of the box without these params. It is an edge case for sure.

Copy link
Contributor

@joecorall joecorall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given Cantaloupe's docs advising against Jai, I do not think we should be adding support for the Jai processor.

I think the best path forward is to add a new environment variable CANTALOUPE_JAVA_OPTS. After that environment variable is created, any docker container could add Jai support for TIFFs using

docker run \
  --env CANTALOUPE_JAVA_OPTS="--add-opens java.base/sun.nio.ch=ALL-UNNAMED --add-opens java.base/java.io=ALL-UNNAMED --add-exports java.desktop/sun.awt.image=ALL-UNNAMED -Dcom.sun.media.jai.disableMediaLib=true" \
  islandora/cantaloupe:some-future-tag

cantaloupe/rootfs/etc/s6-overlay/s6-rc.d/cantaloupe/run Outdated Show resolved Hide resolved
@noahwsmith
Copy link
Contributor Author

Thanks @joecorall I think that's a perfect compromise. I'll test this soon and we can get it merged this week...

@nigelgbanks
Copy link
Contributor

@noahwsmith any luck with applying @joecorall's suggested changes?

@noahwsmith
Copy link
Contributor Author

I accepted this suggested change and there are now errors on the docker build:
https://github.com/Born-Digital-US/isle-buildkit/actions/runs/8708308988/job/23885458913

@joecorall
Copy link
Contributor

@noahwsmith We need to also set the env var in the Dockerfile and update the README

@noahwsmith
Copy link
Contributor Author

Even with those changes it does still error out

compass-i2-cantaloupe-1  | s6-rc: info: service s6rc-oneshot-runner: starting
compass-i2-cantaloupe-1  | s6-rc: info: service s6rc-oneshot-runner successfully started
compass-i2-cantaloupe-1  | s6-rc: info: service fix-attrs: starting
compass-i2-cantaloupe-1  | s6-rc: info: service fix-attrs successfully started
compass-i2-cantaloupe-1  | s6-rc: info: service legacy-cont-init: starting
compass-i2-cantaloupe-1  | s6-rc: info: service legacy-cont-init successfully started
compass-i2-cantaloupe-1  | s6-rc: info: service tty: starting
compass-i2-cantaloupe-1  | s6-rc: info: service container-environment: starting
compass-i2-cantaloupe-1  | s6-rc: info: service tty successfully started
compass-i2-cantaloupe-1  | s6-rc: info: service container-environment successfully started
compass-i2-cantaloupe-1  | s6-rc: info: service database-defaults: starting
compass-i2-cantaloupe-1  | s6-rc: info: service database-defaults successfully started
compass-i2-cantaloupe-1  | s6-rc: info: service confd-oneshot: starting
compass-i2-cantaloupe-1  | s6-rc: info: service confd-oneshot successfully started
compass-i2-cantaloupe-1  | s6-rc: info: service cacert-import: starting
compass-i2-cantaloupe-1  | s6-rc: info: service cacert-import successfully started
compass-i2-cantaloupe-1  | s6-rc: info: service ready: starting
compass-i2-cantaloupe-1  | s6-rc: info: service ready successfully started
compass-i2-cantaloupe-1  | s6-rc: info: service confd: starting
compass-i2-cantaloupe-1  | s6-rc: info: service cantaloupe: starting
compass-i2-cantaloupe-1  | s6-rc: info: service confd successfully started
compass-i2-cantaloupe-1  | s6-rc: info: service cantaloupe successfully started
compass-i2-cantaloupe-1  | s6-rc: info: service legacy-services: starting
compass-i2-cantaloupe-1  | s6-rc: info: service legacy-services successfully started
compass-i2-cantaloupe-1  | Error: Could not find or load main class
compass-i2-cantaloupe-1  | Caused by: java.lang.ClassNotFoundException:
compass-i2-cantaloupe-1  | s6-rc: info: service cantaloupe finish: executing...
compass-i2-cantaloupe-1  | s6-rc: info: service cantaloupe did not recieve a signal...
compass-i2-cantaloupe-1  | s6-rc: info: service cantaloupe exiting with exit code: 1
compass-i2-cantaloupe-1  | s6-rc: info: service legacy-services: stopping
compass-i2-cantaloupe-1  | s6-rc: info: service legacy-services successfully stopped
compass-i2-cantaloupe-1  | s6-rc: info: service confd: stopping
compass-i2-cantaloupe-1  | s6-rc: info: service cantaloupe: stopping
compass-i2-cantaloupe-1  | s6-rc: info: service cantaloupe successfully stopped
compass-i2-cantaloupe-1  | s6-rc: info: service confd successfully stopped
compass-i2-cantaloupe-1  | s6-rc: info: service ready: stopping
compass-i2-cantaloupe-1  | s6-rc: info: service ready successfully stopped
compass-i2-cantaloupe-1  | s6-rc: info: service tty: stopping
compass-i2-cantaloupe-1  | s6-rc: info: service cacert-import: stopping
compass-i2-cantaloupe-1  | s6-rc: info: service tty successfully stopped
compass-i2-cantaloupe-1  | s6-rc: info: service cacert-import successfully stopped
compass-i2-cantaloupe-1  | s6-rc: info: service confd-oneshot: stopping
compass-i2-cantaloupe-1  | s6-rc: info: service confd-oneshot successfully stopped
compass-i2-cantaloupe-1  | s6-rc: info: service database-defaults: stopping
compass-i2-cantaloupe-1  | s6-rc: info: service database-defaults successfully stopped
compass-i2-cantaloupe-1  | s6-rc: info: service container-environment: stopping
compass-i2-cantaloupe-1  | s6-rc: info: service container-environment successfully stopped
compass-i2-cantaloupe-1  | s6-rc: info: service legacy-cont-init: stopping
compass-i2-cantaloupe-1  | s6-rc: info: service legacy-cont-init successfully stopped
compass-i2-cantaloupe-1  | s6-rc: info: service fix-attrs: stopping
compass-i2-cantaloupe-1  | s6-rc: info: service fix-attrs successfully stopped
compass-i2-cantaloupe-1  | s6-rc: info: service s6rc-oneshot-runner: stopping
compass-i2-cantaloupe-1  | s6-rc: info: service s6rc-oneshot-runner successfully stopped
compass-i2-cantaloupe-1 exited with code 1

remove quotes around new variable

Co-authored-by: Joe Corall <[email protected]>
Copy link
Contributor

@joecorall joecorall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$ make bake TARGET=cantaloupe
$ ./gradlew cantaloupe:test
Starting a Gradle Daemon (subsequent builds will be faster)

> Task :cantaloupe:tests:ServiceStartsWithDefaults:test
 Container cantaloupe-servicestartswithdefaults-cantaloupe-1  Stopping
 Container cantaloupe-servicestartswithdefaults-cantaloupe-1  Stopped

BUILD SUCCESSFUL in 15s
11 actionable tasks: 2 executed, 9 up-to-date

Copy link
Contributor

@nigelgbanks nigelgbanks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good stuff

@nigelgbanks nigelgbanks merged commit d7d2e1d into Islandora-Devops:main Apr 19, 2024
@noahwsmith
Copy link
Contributor Author

Deployed and working on our client site - thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants