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
1 Answer
Reset to default 0After 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.