I'm trying to create a Spring Boot Application that is able to reach out to Azure Storage.
Here are some of the Dependencies I've attempted to declare in build.gradle
thus far...
implementation 'com.azure:azure-storage-blob: ' // Current Dependency
implementation 'com.azure.spring:azure-spring-boot-starter-storage: ' // Previous Dependency
Both give me access to the BlobServiceClient
class which I'm using to access my Azure Blob Container.
In my application.properties
file, I have the following properties:
#Storage settings
# Current Attempt
azure.connection=${STORAGE_ACCOUNT_CONNECTION}
# Previous Attempt
azure.storage.account-name=${STORAGE_ACCOUNT_NAME}
azure.storage.account-key=${STORAGE_ACCOUNT_KEY}
azure.storage.blob-endpoint=${STORAGE_ACCOUNT_ENDPOINT}
I then use these properties in a Spring Service Class called StorageService
to manage the BlobServiceClient
. Here are my two attempts to set it up:
1 (Current).
@Autowired
StorageService(@Value("${azure.connection}") String connection)
{
client = new BlobServiceClientBuilder().connectionString(connection).buildClient();
objectMapper = new ObjectMapper();
}
- (Previous).
@Autowired
StorageService(@Value("${azure.storage.account-name}") String name,
@Value("${azure.storage.account-key}") String key,
@Value("${azure.storage.blob-endpoint}") String endpoint)
{
AzureNamedKeyCredential credential = new AzureNamedKeyCredential(name, key);
client = new BlobServiceClientBuilder().credential(credential).endpoint(endpoint).buildClient();
objectMapper = new ObjectMapper();
}
I even tried using both Java 11 and Java 17. However, each time I manage to run it in Intelli-J, I get this error.
Caused by: java.lang.NoSuchFieldError: NOOP_CONFIGURER
at reactor.netty.ChannelPipelineConfigurer.emptyConfigurer(ChannelPipelineConfigurer.java:40)
at reactor.netty.transport.TransportConfig.<init>(TransportConfig.java:207)
at reactor.netty.transport.ClientTransportConfig.<init>(ClientTransportConfig.java:164)
at reactor.netty.http.client.HttpClientConfig.<init>(HttpClientConfig.java:327)
at reactor.netty.http.client.HttpClientConnect.<init>(HttpClientConnect.java:85)
at reactor.netty.http.client.HttpClient.create(HttpClient.java:393)
at com.azure.core.http.netty.NettyAsyncHttpClientBuilder.build(NettyAsyncHttpClientBuilder.java:141)
at com.azure.core.http.netty.NettyAsyncHttpClientProvider.createInstance(NettyAsyncHttpClientProvider.java:19)
at com.azure.core.implementation.http.HttpClientProviders.createInstance(HttpClientProviders.java:67)
at com.azure.core.http.HttpClient.createDefault(HttpClient.java:50)
at com.azure.core.http.HttpClient.createDefault(HttpClient.java:40)
at com.azure.core.http.HttpPipelineBuilder.build(HttpPipelineBuilder.java:73)
at com.azure.storage.blob.implementation.util.BuilderHelper.buildPipeline(BuilderHelper.java:138)
at com.azure.storage.blob.BlobServiceClientBuilder.buildAsyncClient(BlobServiceClientBuilder.java:135)
at com.azure.storage.blob.BlobServiceClientBuilder.buildClient(BlobServiceClientBuilder.java:114)
at com.trecapps.users.services.StorageService.<init>(StorageService.java:40)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480)
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:211)
... 49 common frames omitted
And when I googled "NOOP_CONFIGURER"
(with the quotes), I get 2 results, so this error does not seem to be well documented. Any suggestions on how to get my app to launch?
CodePudding user response:
Please check below points.
NoSuchField
, usually means that when linking the target class, the field is not there. But when compiling, the class should have that field, otherwise the code cann't compile.
i.e; it indicates that an application tries to access or modify an object’s field, but that field no longer exists.
- This error can occur during runtime, if the definition of a class has incompatibly changed.
The exception as shown is occurring at ChannelPipelineConfigurer in empty configure method which returns NOOP_configurer which is present in
reactor netty core
under the package reactor.nettyThis seems to be caused by version mismatch in reactor-netty jar
ChannelPipelineConfigurer.java
package reactor.netty;
import io.netty.channel.Channel;
import reactor.util.annotation.Nullable;
import java.net.SocketAddress;
import static reactor.netty.ReactorNetty.CompositeChannelPipelineConfigurer.compositeChannelPipelineConfigurer;
@FunctionalInterface
public interface ChannelPipelineConfigurer {
static ChannelPipelineConfigurer emptyConfigurer() {
return ReactorNetty.NOOP_CONFIGURER;
}
So please check if reactor netty core release version incompatibility is the reason or one or more version conflicts occuring & try to upgrade to latest version of the release jar and also check if any incompatible dependencies are present.
To handle/deal with NoSuchFieldError error, try to clean all existing .class files and compile everything from the scratch.so that verify that each referenced class is compiled to its latest version.
However, if the error is still thrown during runtime, then one may have to compile using one version of a library, but use another version at runtime. You must verify that your classpath contains the proper version of the specified library.
- Reactive Spring Boot - java.lang.NoSuchFieldError: DEFAULT_SHUTDOWN_QUIET_PERIOD - Stack Overflow
- spring-security-{noop}
CodePudding user response:
Added
implementation "io.projectreactor.netty:reactor-netty-core: "
implementation "io.projectreactor.netty:reactor-netty-http: "
to my build.gradle
file.