- Fix: java.io.IOException: No such file or directory at java.io.UnixFileSystem.createFileExclusively(Native Method)
- Saved searches
- Use saved searches to filter your results more quickly
- java.io.IOException: Operation not permitted #241
- java.io.IOException: Operation not permitted #241
- Comments
- java.io.IOException: Permission denied
- Горячий, чтобы избавиться от java.io.Exception в java.io.WinNTFileSystem.createFileExclusively?
- 1 ответ
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.
Saved searches
Use saved searches to filter your results more quickly
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
java.io.IOException: Operation not permitted #241
java.io.IOException: Operation not permitted #241
waiting for user response Team cannot make further progress on this issue until the original reporter responds.
Comments
java.io.IOException: Operation not permitted
java.io.UnixFileSystem.createFileExclusively0(Native Method)
java.io.UnixFileSystem.createFileExclusively(UnixFileSystem.java:317)
java.io.File.createNewFile(File.java:1008)
com.github.dhaval2404.imagepicker.util.FileUtil.getImageFile(FileUtil.kt:51)
com.github.dhaval2404.imagepicker.provider.CropProvider.cropImage(CropProvider.kt:105)
com.github.dhaval2404.imagepicker.provider.CropProvider.startIntent(CropProvider.kt:95)
com.github.dhaval2404.imagepicker.ImagePickerActivity.setImage(ImagePickerActivity.kt:128)
com.github.dhaval2404.imagepicker.provider.GalleryProvider.handleResult(GalleryProvider.kt:75)
com.github.dhaval2404.imagepicker.provider.GalleryProvider.onActivityResult(GalleryProvider.kt:61)
com.github.dhaval2404.imagepicker.ImagePickerActivity.onActivityResult(ImagePickerActivity.kt:110)
android.app.Activity.dispatchActivityResult(Activity.java:8541)
android.app.ActivityThread.deliverResults(ActivityThread.java:5499)
android.app.ActivityThread.handleSendResult(ActivityThread.java:5547)
android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:51)
android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
android.app.ActivityThread$H.handleMessage(ActivityThread.java:2307)
android.os.Handler.dispatchMessage(Handler.java:106)
android.os.Looper.loop(Looper.java:246)
android.app.ActivityThread.main(ActivityThread.java:8506)
java.lang.reflect.Method.invoke(Native Method)
com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1139)
java.io.IOException: Permission denied
posted 11 years ago
java.io.IOException: Permission denied
at java.io.UnixFileSystem.createFileExclusively(Native Method)
at java.io.File.createNewFile(File.java:883)
at IOtest.FIle_1.main(FIle_1.java:25)
public static void main(String[] args)
String fileName=File.separator+»hello.txt»;
File f=new File(fileName);
if(!f.exists()) <
try <
f.createNewFile();
>catch(Exception e) <
e.printStackTrace();
>
>
else <
System.out.println(«hi»);
>
posted 11 years ago
posted 11 years ago
and output:
java.io.IOException: No such file or directory
at java.io.UnixFileSystem.createFileExclusively(Native Method)
at java.io.File.createNewFile(File.java:883)
at IOtest.FIle_1.main(FIle_1.java:22)
code:
public static void main(String[] args) <
File fDir=new File(File.separator+»file_test»);
File file1=new File(fDir,»file1.txt»);
if(fDir.exists()) <
System.out.println(fDir.getPath());
>else <
fDir.mkdir();
>
if(file1.exists()) <
System.out.println(file1.getPath());
file1.delete();
>else <
try <
file1.createNewFile();
> catch (IOException e) <
e.printStackTrace();
>
>
Sheriff
posted 11 years ago
You’re trying to create files /hello.txt /test_file. The leading slash means you want to put them in the root of your file system. From the exception I see that you are using a Linux or UNIX file system (perhaps Mac OS even). The thing is, on Linux and UNIX systems, not every user can write to any location. Usually all users have only access to their own home folder, and the /tmp folder, with the exception of the root user who can do anything he wants on the system.
So, if you want to write to the root of the file system (which you really really really shouldn’t!) you’ll need to run your code as a user who has more rights. On Ubuntu you need to put sudo before the command, e.g. sudo java IOTest.File_1, and that will still fail if you’re not allowed to run sudo.
And could you please UseCodeTags next time?
SCJP 1.4 — SCJP 6 — SCWCD 5 — OCEEJBD 6 — OCEJPAD 6
How To Ask Questions How To Answer Questions
Горячий, чтобы избавиться от java.io.Exception в java.io.WinNTFileSystem.createFileExclusively?
У меня в настоящее время проблема с тем, что я сталкиваюсь с исключением, которое я никогда раньше не видел, и почему я не знаю, как его обрабатывать. Я хочу создать файл в соответствии с заданными параметрами, но он не будет работать.
public static Path createFile(String destDir, String fileName) throws IOException < FileAccess.createDirectory( destDir); Path xpath = new Path( destDir + Path.SEPARATOR + fileName); if (! xpath.toFile().exists()) < xpath.toFile().createNewFile(); if(FileAccess.TRACE_FILE)Trace.println1("return xpath; > public static void createDirectory(String destDir) < Path dirpath = new Path(destDir); if (! dirpath.toFile().exists()) < dirpath.toFile().mkdir(); if(TRACE_FILE)Trace.println1(">
java.io.IOException: The system cannot find the path specified at java.io.WinNTFileSystem.createFileExclusively(Native Method) at java.io.File.createNewFile(Unknown Source) [. ]
1 ответ
Проблема в том, что файл не может быть создан, если весь содержащийся путь уже существует — его ближайший родительский каталог и все родители над ним. Если у вас есть путь c:\Temp и поддиректории ниже него, и вы пытаетесь создать файл c:\Temp\SubDir\myfile.txt, это не сработает, потому что C:\Temp\SubDir не существовать. До
(Я не уверен, что mkdirs() требует только путь в объекте, а если это так, то измените эту новую строку на
В противном случае вместо этого вы создадите свое имя файла как подкаталог! Вы можете проверить, что правильно, проверив проводник Windows, чтобы узнать, какие каталоги он создал.)