-
Notifications
You must be signed in to change notification settings - Fork 70
IllegalArgumentException: client must be specified when trying to call setContent with Azure Blob Storage #648
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
Comments
Hmmm...two possibilities.
I am not a kotlin person so I have no idea if you can do this but if you can, can you put a breakpoint on the line highlighted in possibility 2 to see if you hit it and if you do what it returns? |
I've tried debugging it, it seems to use the empty constructor, it never stops at a breakpoint in the other constructor. Can it be that for some reason the s3StorePlacementService dependency is not defined? We had problems before with Kotlin, because classes and functions are final by default, maybe this results in some dependencies not being created for some reason? |
Ok, I know a little more know. Kotlin is definitely not the problem. I tried to reproduce this error in a minimal test project, and it worked first try. Also, I tested if all beans required for the AzureStorageFactoryBean constructor are present and all of them were. I found this issue in the Spring Boot project, which sounds like it could have something to do with this: spring-projects/spring-boot#1315 I've tried to import spring-content-azure-storage as a module into my projects to test some things (Remove empty constructor, replace @Autowired constructor with setters), but I had no luck so far. Do You have some tips on including only the azure module into my Project? |
- it causes incorrect construction of the default azure storage implementation fixes #648
I think you hit the nail on the head. I repro'ed the issue and it was the default constructor. Spring was using that to create the contentstore bean, not the autowired constructor and hence I didn't yet investigate why the azurite testcontainer test didnt expose this. A little worrying! I will investigate when I get some more time. But, in the meantime, I tested against the real azure object storage and I think the fix looks good. |
I do have a sample project as well. Would you like me to commit that for you? |
No, thanks, I use the Azure Storage SDK directly for now. I'm sure, ill come back to your library later. One more thing to mention, maybe it's helpful. As I said the current version worked for me in a separate project just fine with the empty constructor. One thing I found out is that in my project where it didn't work, I had a dependency conflict for Jackson. (The Azure SDK using a newer version than my project). I've got a NoClassDefFoundError because of that. Maybe this is the root of the problem? |
- it causes incorrect construction of the default azure storage implementation fixes #648
Thanks for the info. @afLennart . Its possible that was the issue but difficult to say. I also repro'ed the issue and removing the constructor fixed it for me. Anyway, there is now a sample project that shows the simple case working, if needed at some point in the future. |
First, I would like to say that I really like this library. We already used it for 2 years, and it worked great. Thanks for that!
Describe the bug
java.lang.IllegalArgumentException: client must be specified
when trying to call setContent with Azure Blob Storage in a Kotlin project.To Reproduce
I followed the guide for Azure Blob Storage and had a look at the Example Code.
The config (@EnableAzureStorage is present, the bean gets created):
The JPA repo:
The ContentStore:
The save function calling setContent:
The application config:
Expected behavior
Use BlobServiceClientBuilder to call buildClient.
Additional context
As I have already stated, we used this library before but only for the file system and MongoDB. We had no Problems. We are now trying to switch to Azure Storage, because we have a lot of problems with using CosmosDB. The Spring Boot version is 2.4.11. We currently don't use Azure Storage directly. We use Azurite in a Docker Container for local testing, we quickly tested it with the NodeJS SDK, and it worked fine. Here is the full stacktrace:
The text was updated successfully, but these errors were encountered: