Skip to content
New issue

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

STATUS_OBJECT_NAME_INVALID: SetInfo failed for SMB2FileId #283

Open
git-aleksey opened this issue Jan 19, 2018 · 24 comments
Open

STATUS_OBJECT_NAME_INVALID: SetInfo failed for SMB2FileId #283

git-aleksey opened this issue Jan 19, 2018 · 24 comments

Comments

@git-aleksey
Copy link

I'm trying to rename a file but getting the following: STATUS_OBJECT_NAME_INVALID(3221225523/3221225523): SetInfo failed for SMB2FileId{persistentHandle=53 e3 4d 02 1f 00 00 00}
If I rename leaving the path unchanged it works fine but when I change the path to move the file to a folder within the same location I'm getting the above. And to add to my confusion this works fine on my dev environment but fails on customer's network. Any idea what could cause such behavior.

Stack:
com.hierynomus.mssmb2.SMBApiException: STATUS_OBJECT_NAME_INVALID(3221225523/3221225523): SetInfo failed for SMB2FileId{persistentHandle=53 e3 4d 02 1f 00 00 00}
at com.hierynomus.smbj.share.Share.receive(Share.java:335)
at com.hierynomus.smbj.share.Share.sendReceive(Share.java:319)
at com.hierynomus.smbj.share.Share.setInfo(Share.java:171)
at com.hierynomus.smbj.share.DiskShare.setFileInformation(DiskShare.java:230)
at com.hierynomus.smbj.share.DiskEntry.setFileInformation(DiskEntry.java:64)
at com.hierynomus.smbj.share.DiskEntry.rename(DiskEntry.java:106)
at com.hierynomus.smbj.share.DiskEntry.rename(DiskEntry.java:101)
at com.hierynomus.smbj.share.DiskEntry.rename(DiskEntry.java:97)
...

Thank You!

@hierynomus
Copy link
Owner

Is the target directory maybe a DFS link?

@aleksejskolpakov
Copy link

It looks like a server share (\10.39.117.5\Securefiles$) but it might be a DFS. Asked the site to confirm. Would this not work with dfs?

@hierynomus
Copy link
Owner

hierynomus commented Jan 19, 2018 via email

@aleksejskolpakov
Copy link

I'm renaming within the same share:
\\10.39.117.5\Securefiles$\test.csv
renamed to
\\10.39.117.5\Securefiles$\SUCCESS\date_test.csv
Or the subfolder is a different share as far as SMBJ concerned?

@aleksejskolpakov
Copy link

The shares are on DFS. Any idea why would it return STATUS_OBJECT_NAME_INVALID for the subfolder?
Thanks

@pepijnve
Copy link
Contributor

pepijnve commented Jan 23, 2018

Could you share the exact code you're using to do this? Or create a packet capture of the interaction with the server? Without seeing the exact parameter values it's hard to comment on what might be wrong.
STATUS_OBJECT_NAME_INVALID is an error code being sent back from the server. It's not smbj itself that's throwing this. Most likely the path name you're using is not correct for some reason.

@aleksejskolpakov
Copy link

Here is the code:

DiskEntry entry = Share.open(SmbPath.getPath(), EnumSet.of(AccessMask.DELETE, AccessMask.GENERIC_WRITE), EnumSet.of(FileAttributes.FILE_ATTRIBUTE_NORMAL), SMB2ShareAccess.ALL, SMB2CreateDisposition.FILE_OPEN, null);
entry.rename(newSmbPath.getPath());

Where
SmbPath.getPath() = poll\test1.inprocess
newSmbPath.getPath() = poll\SUCCESS\test1.csv

I'm upgrading from JCIFS so in theory the paths (folder names and so on) should be correct. This works fine when renaming within the same directory.

@pepijnve
Copy link
Contributor

pepijnve commented Jan 23, 2018

Assuming poll and poll\SUCCESS are both plain directories and they both exist, I have no idea why the server is rejecting this. A packet capture of a successful execution using JCIFS and one of a failed execution using SMBJ would help a lot here.

I had a look at the code to see how things could go wrong. When you call DiskEntry#rename an SMB2_SET_INFO request is sent to the server with a FILE_RENAME_INFORMATION struct. The latter contains a field ReplaceIfExists. DiskEntry#rename(String) sets that to false. Perhaps you could try using the overload that allows you to set it to true?
Besides that there's nothing obvious on the client side that could be wrong.

@hierynomus
Copy link
Owner

Indeed, it should work, the only exception I could think of is if SUCCESS is a DFS share in itself.

@aleksejskolpakov
Copy link

I am bit limited to what I can access and check on site where the failure occurs so I'm playing guessing games. I couldn't replicate the problem on my environment but I gonna have to try harder. I'll try the ReplaceIfExists suggestion, sounds reasonable,
I suspect this might be down to their dodgy DFS setup. I'll keep you posted if I find anything interesting and helpful.
Thanks once again. You've been a great help.

@BansalPatel
Copy link

BansalPatel commented Sep 10, 2018

Hello @hierynomus, @pepijnve
Rename is not working for me on some server. its working on my local as well as internal servers. but not working on some server.

\directory\_mp4_123.mp4 to \directory\mp4_123.mp4

it gives below error message :
com.hierynomus.mssmb2.SMBApiException: STATUS_OBJECT_NAME_INVALID(3221225523/3221225523): SetInfo failed for SMB2FileId{persistentHandle=f8 41 e0 1e 12 00 00 00}
at com.hierynomus.smbj.share.Share.receive(Share.java:342)
at com.hierynomus.smbj.share.Share.sendReceive(Share.java:322)
at com.hierynomus.smbj.share.Share.setInfo(Share.java:174)
at com.hierynomus.smbj.share.DiskShare.setFileInformation(DiskShare.java:278)
at com.hierynomus.smbj.share.DiskEntry.setFileInformation(DiskEntry.java:65)
at com.hierynomus.smbj.share.DiskEntry.rename(DiskEntry.java:107)
at com.hierynomus.smbj.share.DiskEntry.rename(DiskEntry.java:102)
at com.os.modules.filerepository.service.SMBJFileRepositoryImpl.renameFile(SMBJFileRepositoryImpl.java:450)

@hierynomus
Copy link
Owner

@BansalPatel Can you post the code and a bit more logging than just the stacktrace?

@BansalPatel
Copy link

BansalPatel commented Sep 10, 2018

@hierynomus

the bolder line smbFile.rename(newFilePath,true) throw the exception
Here is the code :

String existingFilePath = "directory\_mp4_123.mp4";
String newFilePath = "directory\mp4_123.mp4";
try (Connection connection = FileRepositoryUtils.getSMBJVideoConnection(path);
DiskShare share = FileRepositoryUtils.getSMBJVideoShareConnection(connection,path);
File smbFile = share.openFile(existingFilePath, EnumSet.of(AccessMask.DELETE, AccessMask.GENERIC_WRITE), null, SMB2ShareAccess.ALL, SMB2CreateDisposition.FILE_OPEN, null)) {
if(share.fileExists(existingFilePath){
smbFile.rename(newFilePath, true);
}
}catch (SMBApiException e) {
LoggerUtils.printErrorLog(e);
throw e;
}

LOG :

ERROR [2018-09-07T07:50:27,538] - com.os.util.helper.LoggerUtils.printInfoError:Line 91 - For video library id :: 50 Found Exception in downloading file : com.hierynomus.mssmb2.SMBApiException: STATUS_OBJECT_NAME_INVALID(3221225523/3221225523): SetInfo failed for SMB2FileId{persistentHandle=f8 41 e0 1e 12 00 00 00}
at com.hierynomus.smbj.share.Share.receive(Share.java:342)
at com.hierynomus.smbj.share.Share.sendReceive(Share.java:322)
at com.hierynomus.smbj.share.Share.setInfo(Share.java:174)
at com.hierynomus.smbj.share.DiskShare.setFileInformation(DiskShare.java:278)
at com.hierynomus.smbj.share.DiskEntry.setFileInformation(DiskEntry.java:65)
at com.hierynomus.smbj.share.DiskEntry.rename(DiskEntry.java:107)
at com.hierynomus.smbj.share.DiskEntry.rename(DiskEntry.java:102)
at com.os.modules.filerepository.service.SMBJFileRepositoryImpl.renameFile(SMBJFileRepositoryImpl.java:450)
at com.os.util.helper.ReplicationUtil.renameMediaOnRepository(ReplicationUtil.java:1443)
at com.os.util.convertVideo.DownloadVideoServerSchedular.processMp4File(DownloadVideoServerSchedular.java:489)
at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573)

@pepijnve
Copy link
Contributor

pepijnve commented Sep 10, 2018

Could you try removing the leading \ characters in the paths? Those shouldn't be present. SMB requires that all paths are relative (i.e. do not start with a leading \) with respect to the root of the share.

@BansalPatel
Copy link

@pepijnve
I have verified path again. it is not starting with leading \ character.
My above code is working fine with my local and internal server but not working on live instances and throw above exception.

@pepijnve
Copy link
Contributor

pepijnve commented Sep 10, 2018

What are the exact file names that cause the problems? The error code STATUS_OBJECT_NAME_INVALID means the server is rejecting the new file name your trying to give the file for whatever reason. That's obviously dependent on the exact file name; there's not much we can say about an approximation.

A wireshark/tcpdump/... log also helps quite a lot in diagnosing this type of problem. There's no generic answer to why a server returns an error code; it's highly server implementation and parameter value dependent.

@BansalPatel
Copy link

BansalPatel commented Sep 18, 2018

@pepijnve , @hierynomus
Still facing same issue on client server. File name and path are not caused the issue because all logging details are proper which required to rename the SMB file.

Is there any dependancy on tomcat or windows specific in SMBJ??

Thanks

@f-de
Copy link

f-de commented Sep 7, 2021

I got the same error working with a share from Windows Server 2016. This happened when the new name (which includes the path) contains / and it has to be replaced with \in order to work. With escaping it looks like that in my code:
newName = newName.replaceAll("/", "\\\\");

@tangxuGoGoGo
Copy link

I got the same error working with a share from Win10. It only do well when I rename to the root dirctory.

@Gloryandel
Copy link

I got the same error working with a share from Windows Server 2022
Uploading Screenshot_2023-05-20-11-13-28-774_com.mixplorer-edit.jpg…

@Gloryandel
Copy link

STATUS_OBJECT_NAME _INVALID (Oxc0000033): Create
failed for | | 192.168.10.20\ NAS| ??\ D: \ Office
"??" ??

@1N0T
Copy link

1N0T commented Jul 31, 2023

I got this error using camel-smbj on windows 10. I solved the problem by replacing the relative path with the absolute path (from the shared folder)

<dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-core</artifactId>
    <version>2.25.0</version>
</dependency>
<dependency>
    <groupId>com.github.jborza</groupId>
    <artifactId>camel-smbj</artifactId>
    <version>0.2.22</version>
</dependency>
<dependency>
    <groupId>com.hierynomus</groupId>
    <artifactId>smbj</artifactId>
    <version>0.12.1</version>
</dependency>

relative path processed should be replaced by /directory/processed this poins to //server/shared/directory/processed

@StreletsA
Copy link

This is my solution

sharingRootName: app$
oldFilePath: /example/file.txt
newFilePath: /example/archive/file-archived.txt

And full paths are:

  1. \disk-share-host\app$\example\
  2. \disk-share-host\app$\example\archive\
private boolean moveFile(Connection connection,
                                          String oldFilePath,
                                          String newFilePath) {
        try (Session session = createSession(connection);
              DiskShare share = (DiskShare) session.connectShare(sharingRootName)) {
            DiskEntry diskEntry = share.open(oldFilePath,
                                                         EnumSet.of(AccessMask.DELETE,
                                                                            AccessMask.GENERIC_WRITE),
                                                         EnumSet.of(FileAttributes.FILE_ATTRIBUTE_NORMAL),
                                                         SMB2ShareAccess.ALL,
                                                         SMB2CreateDisposition.FILE_OPEN,
                                                         null);

            diskEntry.rename(newFilePath, true);

            return true;
        } catch (IOException e) {
            log.error("Cannot connect to share {} -> ", sharingRootName, e);
        }

        return false;
    }

@JanDornseifer
Copy link

FYI: we also faced this exception while renaming a file. Application servers running on Windows worked fine, but those on Linux failed while renaming a file. In the end, it was the same as @f-de mentioned. We used Path.toString(), so path seperators were resolved to backslashes on Windows and to slashes on Linux. After converting all path seperators to backslashes the renaming worked in application servers on Linux, too. Interesting is, that it only affected the renaming of the file. Previously, the file could be successfully transferred to the share using slashes in the path.

I do not have any further information on the fileshare used on customer side. SMBJ is used in v0.12.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests