最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

jcr - Binary data download is not working with jackrabit after upgrading Tomcat from 9 to 10 - Stack Overflow

programmeradmin2浏览0评论

We are upgrading from Tomcat 9 to 10. As part of this we have migrated javax packages to compatible jakarta versions. However, I am in doubt if jackrabbit also needs to be updated to use jakarta compatible version. If yes, does the latest jackrabbit release is jakarta compatible? Also we use JCR latest version which is not updated to jakarta yet.

Problem statement: A file (particularly .pdf, .xls, .png files ) download from jackrabbit repository is failing. The node.getProperty("jcr:data").getBinary().getStream(); returns empty stream. However, download for text file works perfectly fine.

We have tried upgrading to latest version of jackrabbit, but issue still persists.

Please suggest what changes could be required to solve this problem.

We are upgrading from Tomcat 9 to 10. As part of this we have migrated javax packages to compatible jakarta versions. However, I am in doubt if jackrabbit also needs to be updated to use jakarta compatible version. If yes, does the latest jackrabbit release is jakarta compatible? Also we use JCR latest version which is not updated to jakarta yet.

Problem statement: A file (particularly .pdf, .xls, .png files ) download from jackrabbit repository is failing. The node.getProperty("jcr:data").getBinary().getStream(); returns empty stream. However, download for text file works perfectly fine.

We have tried upgrading to latest version of jackrabbit, but issue still persists.

Please suggest what changes could be required to solve this problem.

Share Improve this question asked Feb 4 at 17:07 NarayanNarayan 112 bronze badges 1
  • After some additional testing , found below. Issues is not related to file format but is related to file size. Any file with size greater than 8kb is failing to be downloaded from jackrabbit repository. – Narayan Commented Feb 5 at 8:27
Add a comment  | 

1 Answer 1

Reset to default 0

After investigation, found the below root cause for the problem.

The jackrabbit internal code is as below

protected void openStream() throws IOException {
        if (endOfStream) {
            throw new EOFException();
        }
        if (in == null) {
            try {
                in = store.openStream(this, identifier);
            } catch (DataStoreException e) {
                IOException e2 = new IOException(e.getMessage());
                e2.initCause(e);
                throw e2;
            }
        }
    }

So, if in == null then only it opens stream from Database and download it.

With commons-io libraryenter code here version 2.17.0 "in" will be reset to ClosedInputStream making it never a null.

So the jackrabbit code for in == null will never be executed and returns an empty stream.

Solution: I used the commons-io version 2.11.0 where in will be returned as it is if its null.

发布评论

评论列表(0)

  1. 暂无评论