How to fix common item import errors

Fix: java.io.IOException: No such file or directory at java.io.UnixFileSystem.createFileExclusively(Native Method)

Error:
When importing, you see this error:

java.io.IOException: No such file or directory
    at java.io.UnixFileSystem.createFileExclusively(Native Method)
    at java.io.File.createNewFile(File.java:850)
    at edu.sdsc.grid.io.local.LocalFile.createNewFile(LocalFile.java:481)
    at org.dspace.storage.bitstore.BitstreamStorageManager.store(BitstreamStorageManager.java:325)
    at org.dspace.content.Bitstream.create(Bitstream.java:184)
    at org.dspace.content.Bundle.createBitstream(Bundle.java:355)
    at org.dspace.app.itemimport.ItemImport.processContentFileEntry(ItemImport.java:1045)
    at org.dspace.app.itemimport.ItemImport.processContentsFile(ItemImport.java:972)
    at org.dspace.app.itemimport.ItemImport.addItem(ItemImport.java:609)
    at org.dspace.app.itemimport.ItemImport.addItems(ItemImport.java:476)
    at org.dspace.app.itemimport.ItemImport.main(ItemImport.java:385)
java.io.IOException: No such file or directory

If you are importing a collecting of items, it will often fail at different items.

Solution::
The normal issue that causes this is if you have been running the importer as a different user to the user that is running tomcat, or another user has been changing files (maybe running the filter-media cron job as root etc). Check that all of the directories under dspace/assetstore/ are owned by the correct user.

DSpace randomly selects a set of directories to put a new file in, and if one of these happens to not be owned by the same user you are running the importer as, then it won't be able to write the file, and will stop. So check they are all owned by the correct user or that you have the correct permissions to write to them.

Because Dspace randomly chooses the directories to write the file to, the importer will stop and different places randomly.

You can fix the problem by using a command such as

chown -R user [dspace]/assetstore/

where user is the username that the assetstore should be owned by (often tomcat or dspace) and dspace is the location of your DSpace installation.