spring-cloud-connectors
                                
                                 spring-cloud-connectors copied to clipboard
                                
                                    spring-cloud-connectors copied to clipboard
                            
                            
                            
                        java.lang.IllegalAccessError: failed to access class com.mongodb.client.internal.MongoClientDelegate from class com.mongodb.Mongo
I am upgrading the spring boot version from 2.2.7.RELEASE to 2.6.7. In order to upgrade the spring boot i am using spring-data-mongodb version 2.2.12.RELEASE. With this dependency combination my code deployed successfully at my local but when i deploy the code at my SIT server it failed and throws the following error.
	java.lang.IllegalStateException: Error starting child
		at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:729)
		at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:698)
		at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:696)
		at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1024)
		at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1911)
		at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
		at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
		at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
		at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:118)
		at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:825)
		at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:475)
		at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1667)
		at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:315)
		at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:123)
		at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1162)
		at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1365)
		at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1369)
		at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1347)
		at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
		at java.base/java.util.concurrent.FutureTask.runAndReset(FutureTask.java:305)
		at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:305)
		at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
		at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
		at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
		at java.base/java.lang.Thread.run(Thread.java:834)
	Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/DOPE-OP-web]]
		at org.apache.catalina.util.LifecycleBase.handleSubClassException(LifecycleBase.java:440)
		at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:198)
		at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:726)
		... 24 more
	Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mongoFactory' defined in class path resource [eai-app-profile.xml]: Bean instantiation via constructor failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.data.mongodb.core.SimpleMongoDbFactory]: Constructor threw exception; nested exception is java.lang.IllegalAccessError: failed to access class com.mongodb.client.internal.MongoClientDelegate from class com.mongodb.Mongo (com.mongodb.client.internal.MongoClientDelegate and com.mongodb.Mongo are in unnamed module of loader org.apache.catalina.loader.ParallelWebappClassLoader @2c785774)
		at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:315)
		at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:296)
		at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1372)
		at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1222)
		at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582)
		at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)
		at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
		at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
		at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
		at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
		at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:953)
		at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918)
		at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583)
		at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145)
		at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:740)
		at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:415)
		at org.springframework.boot.SpringApplication.run(SpringApplication.java:303)
		at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.run(SpringBootServletInitializer.java:175)
		at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.createRootApplicationContext(SpringBootServletInitializer.java:155)
		at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.onStartup(SpringBootServletInitializer.java:97)
		at org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:174)
		at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5219)
		at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
		... 25 more
	Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.data.mongodb.core.SimpleMongoDbFactory]: Constructor threw exception; nested exception is java.lang.IllegalAccessError: failed to access class com.mongodb.client.internal.MongoClientDelegate from class com.mongodb.Mongo (com.mongodb.client.internal.MongoClientDelegate and com.mongodb.Mongo are in unnamed module of loader org.apache.catalina.loader.ParallelWebappClassLoader @2c785774)
		at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:224)
		at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:117)
		at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:311)
		... 47 more
	Caused by: java.lang.IllegalAccessError: failed to access class com.mongodb.client.internal.MongoClientDelegate from class com.mongodb.Mongo (com.mongodb.client.internal.MongoClientDelegate and com.mongodb.Mongo are in unnamed module of loader org.apache.catalina.loader.ParallelWebappClassLoader @2c785774)
		at com.mongodb.Mongo.<init>(Mongo.java:319)
		at com.mongodb.Mongo.<init>(Mongo.java:308)
		at com.mongodb.Mongo.<init>(Mongo.java:304)
		at com.mongodb.MongoClient.<init>(MongoClient.java:326)
		at org.springframework.data.mongodb.core.SimpleMongoDbFactory.<init>(SimpleMongoDbFactory.java:48)
		at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
		at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
		at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
		at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
		at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:211)
		... 49 more
following is the bean config.
    <bean id="mongoClientURI" class="com.web.config.MongoConfig"/>
    <bean id="mongoFactory"
          class="org.springframework.data.mongodb.core.SimpleMongoDbFactory">
        <constructor-arg name="uri" ref="mongoClientURI"/>
    <bean id="mappingContext"
          class="org.springframework.data.mongodb.core.mapping.MongoMappingContext"/>
    <bean id="defaultMongoTypeMapper"
          class="org.springframework.data.mongodb.core.convert.DefaultMongoTypeMapper">
        <constructor-arg name="typeKey">
            <null/>
        </constructor-arg>
    </bean>
    <bean id="mappingMongoConverter"
          class="org.springframework.data.mongodb.core.convert.MappingMongoConverter">
        <constructor-arg name="mongoDbFactory" ref="mongoFactory"/>
        <constructor-arg name="mappingContext" ref="mappingContext"/>
        <property name="typeMapper" ref="defaultMongoTypeMapper"/>
    </bean>
    <bean id="mongoTemplate" class="org.springframework.data.mongodb.core.MongoTemplate" lazy-init="true">
        <constructor-arg name="mongoDbFactory" ref="mongoFactory"/>
        <constructor-arg name="mongoConverter" ref="mappingMongoConverter"/>
    </bean>
Following is the mongoconfig
public class MongoConfig implements FactoryBean<MongoClientURI> {
  private String uri;
  @Value("${mongo_socketTimeout}")
  private int socketTimeout;
  @Value("${mongo_uri}")
  public void setUri(String uri) {
    this.uri = uri;
  }
  @Override
  public MongoClientURI getObject() throws Exception {
    return new MongoClientURI(uri, MongoClientOptions.builder().socketTimeout(socketTimeout));
  }
  @Override
  public Class<?> getObjectType() {
    return MongoClientURI.class;
  }
  @Override
  public boolean isSingleton() {
    return true;
  }
}
Your help will be really appreciated.
It's not clear to me what this problem has to do with Spring Cloud Connectors. Connectors is used when you want connection beans automatically configured based on credentials exposed by a cloud platform, but you are configuring the MongoDB connection explicitly.
i am using spring-data-mongodb version 2.2.12.RELEASE
I would strongly recommend that you use the version of spring-data-mongodb that is managed by Spring Boot. For Spring Boot  2.6.7, this is org.springframework.data:spring-data-mongodb:3.3.4.
Closing due to inactivity. If you can provide a sample that reproduces the problem after addressing the concern in my comment above, we can consider re-opening the issue.