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

Cannot resolve driver when loaded through a deployed war #26

Open
devportilla opened this issue Oct 25, 2019 · 11 comments
Open

Cannot resolve driver when loaded through a deployed war #26

devportilla opened this issue Oct 25, 2019 · 11 comments

Comments

@devportilla
Copy link
Contributor

devportilla commented Oct 25, 2019

Hello,

Im having issues while trying to use the connector on a regular spring-boot war deployed artifact on tomcat. So far i have seen the following:

  • With the regular jdbc connector, the jdbc driver gets registered on the driver manager when attempting the connection. This works.
  • When using the secrets manager connector, the first connection attempt registers AWSSecretsManagerDriver as expected but when it tries to get the underlying driver (in this case the jdbc real driver) the driver isnt registered in the drivermanager, thus failing with "No Driver has been registered with name".

Setup is:
-Packaging type: war
-Spring boot version: 1.3.5.RELEASE with the following starters:
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-jdbc</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency>
-Aws secretsmanager jdbc version: 1.0.2

This is happening only when the artifact is a war file and not jar launched application, with the embedded tomcat instead of the external one.

Some guidance would be appreciated.

@jefferyk
Copy link

jefferyk commented Nov 5, 2019

We had the similar experience when we set this up using a war and tomcat back in December. We just made sure there was a bean defined for the native jdbc driver, so that this error wouldn't occur. It wasn't used directly by our app, but it just needed to be called/defined, then the secret manager jdbc driver was able to find it and it worked successfully.

@devportilla
Copy link
Contributor Author

Our current solution passed by setting the drivermanagerprotection to false on the jre memory leak prevention listener on our server.xml, but this doesnt seem too clean. For more information: https://tomcat.apache.org/tomcat-8.0-doc/config/listeners.html#JRE_Memory_Leak_Prevention_Listener_-_org.apache.catalina.core.JreMemoryLeakPreventionListener

@gregory-viale-cbp
Copy link

Hi, I have the same behaviour, the workaround to set driverManagerProtection to false worked for me as well.

@raghusujju
Copy link

I encountered this issue. Since, i have access to the code, I loaded the driver using class loader. The issue is gone. But this is still a workaround as it does not solve the real issue. I was using the postgresql driver. I have overwritten one of the posgresql classes similar to MySql classes.

@indrayanivaze
Copy link

I encountered this issue. Since, i have access to the code, I loaded the driver using class loader. The issue is gone. But this is still a workaround as it does not solve the real issue. I was using the postgresql driver. I have overwritten one of the posgresql classes similar to MySql classes.

I am getting exact same error. Can you please let me know how you used class loader to load postgresql driver ?

@raghusujju
Copy link

I overritten getDefaultDriverClass method inside AWSSecretsManagerPostgreSQLDriver.java ( as I was using postgres) to load the postgresql driver. JUst do a Class.forName("org.postgresql.Driver", false, this.getClass().getClassLoader());. AFter this the issue with driver load was gone.

@llama95
Copy link

llama95 commented Oct 20, 2020

Can one elaborate exactly what the line is that needs to get inserted into the server.xml file? @gregory-viale-cbp @devportilla

would it look like this?? -->
image
or is that second line there just an example and it should instead look like this -->
image

@devportilla
Copy link
Contributor Author

@nehamallama Your server xml should have the following line :
<Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" driverManagerProtection="false"/>

@llama95
Copy link

llama95 commented Oct 21, 2020

@devportilla thanks it works. Can confirm that this issue is still active/this solution will temporarily mitigate the error. ~best

@willtong1234
Copy link
Contributor

Thank you for opening this issue - we are looking into it.

@sthangavel
Copy link

This issue will be resolved by adding driver jar in tomcat lib (in case of externalized tomcat).

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

No branches or pull requests

9 participants