Unable to upload file due to exception: uploads/inventory.xls (No such file or directory)

Hi Justin

I am trying to add inventory of a test item “XYZ1” to my test location “P-TESTLOC” using data import and it keeps failing and I am not sure what am I doing wrong. I get this message below. I created already the product and the location
so I believe this should work. The one thing I remember that was unique to this import was that Kelsey told us to always type in something for product (never leave that field blank – doesn’t need to be the right value so I entered “aaa”).

Thanks,

Ana Maria Maldonado

(Attachment inventory.xls is missing)

There’s an “upload” directory that’s supposed to be created on startup. It looks like on Ubuntu 18.04 it’s trying to create the directory under root (/) which it does not have permission to do.

2019-11-23 05:15:47,957 [localhost-startStop-1] INFO  core.UploadService  - Find or create uploads directory uploads
2019-11-23 05:15:47,960 [localhost-startStop-1] INFO  core.FileService  - Attempting to create directory /uploads
2019-11-23 05:15:47,962 [localhost-startStop-1] ERROR core.FileService  - - Directory /uploads cannot be created

This would happen if the system property for user.home is not populated.

directoryPath = directoryPath.replaceFirst("^~", System.getProperty("user.home"))

For now I’m going to create the directory manually.

ssh username@server
sudo mkdir /uploads
sudo chown tomcat:tomcat /uploads

One other workaround would be to override the uploads directory config property (see https://github.com/openboxes/openboxes/issues/1084)

openboxes.uploads.location = /opt/tomcat/uploads

The underlying issue has been reported in the following issue (see https://github.com/openboxes/openboxes/issues/1351) and will be fixed in an upcoming release.

Sorry for commenting on an old topic. But I am now having the exact same issue in data import process (trying to import locations). I have try creating the folder as mentioned above but I just got another error

The first error is similar to the one in this post
Unable to upload file due to exception: java.io.FileNotFoundException: /var/lib/tomcat9/uploads/locations.xls (No cush file or directory)

After creating the folder (yes I did chown as well) the error changed to Read-only file system

Unable to upload file due to exception: java.io.FileNotFoundException: /var/lib/tomcat9/uploads/locations.xls (Read-only file system)

What version of the application are you using?

Hi Justin. Appoligies for late response. I am currently using Application version 0.9.2 running on Ubuntu 22.04 LTS. Actually I found out the cause of the issue and it is actually related to OS level restriction. I found out somewhere in one of the debian forums (can’t seem to remember where I found that info) that debain has some restrictions on where tomcat can have write access (regardless of file permissions) and only certain folder will work when uploading file. So I found out that if I change upload folder to one of those location upload will work. So I added the following into openboxes-config.properties file and restart.

openboxes.uploads.location=/var/lib/tomcat9/webapps

This seems to be have solved my issue and I am now able to upload files. I am sure there will be other more elegant ways to resolve it but for me this seems to work and I am ok with having clean up webapps folder with various uploads once in a while.

Actually I found out the cause of the issue and it is actually related to OS level restriction.

Phew. I was stumped by this one after you said “yes I did chown as well”. :slight_smile:

Although, I initially missed the most important part of that exception (see below), so I think I was trying to go down a troubleshooting path assuming you were on an older version of the application.

Unable to upload file due to exception: 
   java.io.FileNotFoundException: 
      /var/lib/tomcat9/uploads/locations.xls (Read-only file system)
                                              ^^^^^^^^^^^^^^^^^^^^^

I found out somewhere in one of the debian forums (can’t seem to remember where I found that info) that debain has some restrictions on where tomcat can have write access (regardless of file permissions)

Was it something like this?

So I found out that if I change upload folder to one of those location upload will work. So I added the following into openboxes-config.properties file and restart.

I would be careful with using webapps. If someone had access to your application and accidentally (or maliciously) uploaded a .war file , your server might get compromised. I would recommend adding the config to the tomcat9.service (or whatever file is used by systemd to allow access).

It’s actually fairly straightforward to configure as well.

Hi Justin,

Yes the post I read was exactly that one. Thanks a lot for the link :slight_smile: Was reading too many posts in trying figure out the issue and lost track of where I found it. I agree that using the webapps folder is not a good idea considering the risk. For this instance, since it’s an internal only test environment I made the changes just to get the upload working. Now that I have move forward, I will change to tomcat service option as you have recommended. Thanks again for your support.

If anyone having the same issue, what I did finally was edit tomcat9 service as recommended by Justin.

in … /etc/systemd/system/multi-user.target.wants/tomcat9.service

added the line

ReadWritePaths=/var/lib/tomcat9/uploads

Please note that you may need to create uploads folder manually if it’s not there yet.

1 Like