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

SNOW-1851439: Snowflake JDBC Thin driver showing runtime errors in AWS Lambda function #1992

Open
debasis094 opened this issue Dec 9, 2024 · 2 comments
Assignees
Labels
question Issue is a usage/other question rather than a bug status-triage_done Initial triage done, will be further handled by the driver team

Comments

@debasis094
Copy link

Please answer these questions before submitting your issue.
In order to accurately debug the issue this information is required. Thanks!

  1. What version of JDBC driver are you using ? - 3.20.0

    net.snowflake snowflake-jdbc-thin 3.20.0
  2. What operating system and processor architecture are you using? AWS Lambda , Linux

  3. What version of Java are you using? java 11

  4. What did you do?

    Added below dependency to my POM.xml

    net.snowflake snowflake-jdbc-thin 3.20.0
  5. What did you expect to see? Expected to see successful connection with Snowflake database

    What should have happened and what happened instead?

  6. Can you set logging to DEBUG and collect the logs?

    https://community.snowflake.com/s/article/How-to-generate-log-file-on-Snowflake-connectors

    Before sharing any information, please be sure to review the log and remove any sensitive
    information.

@debasis094 debasis094 added the bug label Dec 9, 2024
@github-actions github-actions bot changed the title Snowflake JDBC Thin driver showing runtime errors in AWS Lambda function SNOW-1851439: Snowflake JDBC Thin driver showing runtime errors in AWS Lambda function Dec 9, 2024
@debasis094
Copy link
Author

debasis094 commented Dec 9, 2024

below is the exact runtime error

SEVERE: Failed to load org.bouncycastle.jce.provider.BouncyCastleProvider, err=org.bouncycastle.jce.provider.BouncyCastleProvider. Current classpath: file:/var/task/. If you use Snowflake JDBC for FIPS jar, import BouncyCastleFipsProvider in the application.

java.lang.ExceptionInInitializerError: java.lang.ExceptionInInitializerError
java.lang.ExceptionInInitializerError
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.base/java.lang.reflect.Constructor.newInstance(Unknown Source)
at com.zaxxer.hikari.HikariConfig.setDriverClassName(HikariConfig.java:492)
at org.nmdp.haplogic.drs.producer.config.SnowflakeJdbcContext.snowflakeHikariDataSource(SnowflakeJdbcContext.java:22)
at org.nmdp.haplogic.drs.producer.config.DrsProducerContext.(DrsProducerContext.java:18)
at org.nmdp.haplogic.drs.producer.handler.DrsProducerHandler.(DrsProducerHandler.java:35)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.base/java.lang.reflect.Constructor.newInstance(Unknown Source)
Caused by: java.lang.RuntimeException: Failed to load org.bouncycastle.jce.provider.BouncyCastleProvider, err=org.bouncycastle.jce.provider.BouncyCastleProvider. Current classpath: file:/var/task/. If you use Snowflake JDBC for FIPS jar, import BouncyCastleFipsProvider in the application.
at net.snowflake.client.core.SecurityUtil.instantiateSecurityProvider(SecurityUtil.java:55)
at net.snowflake.client.core.SecurityUtil.addBouncyCastleProvider(SecurityUtil.java:32)
at net.snowflake.client.jdbc.SnowflakeDriver.(SnowflakeDriver.java:67)
... 12 more
Caused by: java.lang.ClassNotFoundException: org.bouncycastle.jce.provider.BouncyCastleProvider. Current classpath: file:/var/task/

@sfc-gh-sghosh sfc-gh-sghosh self-assigned this Dec 11, 2024
@sfc-gh-sghosh
Copy link
Contributor

sfc-gh-sghosh commented Dec 11, 2024

Hello @debasis094 ,

Thanks for raising the issue. Could you provide the following information.

  1. Was it working fine before with JDBC thin driver ?
  2. Did you try with fat-jar driver ?
  3. The error you are encountering indicates that the BouncyCastleProvider class required by the Snowflake JDBC driver for FIPS compliance is not available in the classpath. Specifically, the BouncyCastle FIPS provider JAR is missing.

The fat jdbc jar contains all dependencies and in thin you have to provide all dependencies from your side.
5. Please download the BouncyCastle jar files, include the following JARs in your AWS Lambda deployment package:
bcpkix-fips-.jar
bc-fips-.jar
snowflake-jdbc-fips.jar
6. When deploying to AWS Lambda, ensure all required dependencies are included in the .zip or container image used to run the function.
7. Modify your Lambda code to explicitly register the BouncyCastleProvider
Example: `import org.bouncycastle.jce.provider.BouncyCastleProvider;
import java.security.Security;

public class YourLambdaHandler {
static {
Security.addProvider(new BouncyCastleProvider());
}

public void handleRequest(...) {
    // Your Lambda function logic
}

}`
8. Test the packaged JAR locally using a similar Java runtime environment before deploying to AWS Lambda.

Regards,
Sujan

@sfc-gh-sghosh sfc-gh-sghosh added status-triage_done Initial triage done, will be further handled by the driver team question Issue is a usage/other question rather than a bug and removed bug labels Dec 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Issue is a usage/other question rather than a bug status-triage_done Initial triage done, will be further handled by the driver team
Projects
None yet
Development

No branches or pull requests

2 participants