[
https://issues.apache.org/jira/browse/TIKA-4864?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18110022#comment-18110022
]
ASF GitHub Bot commented on TIKA-4864:
--------------------------------------
tballison opened a new pull request, #3110:
URL: https://github.com/apache/tika/pull/3110
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
Thanks for your contribution to [Apache Tika](https://tika.apache.org/)!
Your help is appreciated!
Before opening the pull request, please verify that
* there is an open issue on the [Tika issue
tracker](https://issues.apache.org/jira/projects/TIKA) which describes the
problem or the improvement. We cannot accept pull requests without an issue
because the change wouldn't be listed in the release notes.
* the issue ID (`TIKA-XXXX`)
- is referenced in the title of the pull request
- and placed in front of your commit messages surrounded by square
brackets (`[TIKA-XXXX] Issue or pull request title`)
* commits are squashed into a single one (or few commits for larger changes)
* Tika builds and unit tests pass with `./mvnw clean install` (`clean test`
alone cannot resolve the pipes plugin zips)
* if you used a generative AI tool: follow the [ASF Generative Tooling
Guidance](https://www.apache.org/legal/generative-tooling.html) (`Generated-by:
<tool>` in the commit message), and consider running the pre-flight in
`.skills/devs/pr-review/SKILL.md` — fix what it finds; don't paste its report
here
* there should be no conflicts when merging the pull request branch into the
*recent* `main` branch. If there are conflicts, please try to rebase the pull
request branch on top of a freshly pulled `main` branch
* if you add new module that downstream users will depend upon add it to
relevant group in `tika-bom/pom.xml`.
We will be able to faster integrate your pull request if these conditions
are met. If you have any questions how to fix your problem or about using Tika
in general, please sign up for the [Tika mailing
list](http://tika.apache.org/mail-lists.html). Thanks!
> Default plugins directory resolution depends on the working directory
> ---------------------------------------------------------------------
>
> Key: TIKA-4864
> URL: https://issues.apache.org/jira/browse/TIKA-4864
> Project: Tika
> Issue Type: Bug
> Affects Versions: 4.0.0
> Reporter: Dominik Schmidt
> Priority: Major
> Fix For: 4.1.0
>
>
> The 4.0.0 docker image (and any classpath-launched tika-server) loses all
> pipes plugins when the process working directory is not the install
> directory. The server starts fine, but the first parse fails:
> org.apache.tika.exception.TikaConfigException: Unknown fetcher type:
> 'file-system-fetcher'
> for instance id '__tika-server'. Available types: []
> Reproduce with the released image; the only difference is the working
> directory:
> docker run -p 9998:9998 apache/tika:4.0.0-full # parses fine
> docker run -w /somewhere -p 9998:9998 apache/tika:4.0.0-full # first parse
> fails as above
> This is not a synthetic case: any orchestrator that sets the container
> working directory hits it, for example Woodpecker CI service containers
> (workspace as workdir), Kubernetes workingDir, or compose working_dir.
> Cause, in TikaServerProcess.resolveDefaultPluginsDir() (introduced with
> TIKA-4682):
> 1. It looks for plugins next to "the running jar", taken from the CodeSource
> of TikaServerProcess. In the docker image that class lives in
> lib/tika-server-core-4.0.0.jar, so the check probes
> /opt/tika-server/lib/plugins, which does not exist. The actual plugins sit
> next to the standard jar in /opt/tika-server/plugins.
> 2. It then falls back to plugins relative to the CWD. In the image that only
> works because WORKDIR /opt/tika-server happens to match.
> 3. If neither exists, the literal relative string plugins is passed on, and
> the forked PipesServer resolves it against its own CWD, ending with an empty
> plugin registry and the error above.
> The javadoc says "The plugin-roots will default to a 'plugins' directory at
> the same level as the server jar", which is what one would expect, but step 1
> checks the level of the wrong jar. There is also no CLI or environment
> override in 4.0.0, only the plugin-roots config key, so the image cannot be
> fixed from the outside without shipping a config file.
> Suggested fix: also probe the parent of the code-source directory (covers the
> lib/ layout), or resolve against the jar named on the command line rather
> than the CodeSource, and resolve the final result to an absolute path before
> handing it to the pipes fork so the fork's CWD stops mattering.
> Independently, the docker image could pin plugin-roots absolutely instead of
> relying on its WORKDIR.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)