Getting a CryptoException class not found error when connecting with JDBC

Accepted Solution Solved
Reply
New Contributor
Posts: 3
Accepted Solution

Getting a CryptoException class not found error when connecting with JDBC

Hello,

I posted a question on StackOverflow regarding this, and someone referred me to this site, so I'll post here as well.

StackOverflow: r - Java exception error during RJDBC::dbConnect: how to silently ignore? - Stack Overflow

So as you can read there, I am doing a dbConnect using a JDBC driver (specifically the 94M2 version), within the R environment using RJDBC. However, at the first connect, I get a class not found error for com.sas.net.crypto.CryptoException. My classpath contains sas.core.jar and sas.intrnet.javatools.jar. I can see the CryptoException class in the sas.core.jar though. A second attempt to connect works fine though.

I was wondering two things:

- why would it try to throw a CryptoException? Am I missing some cryptographic libraries?

- why does it not see it in sas.core.jar?,

Thanks!


Accepted Solutions
Solution
‎07-06-2015 11:55 AM
Trusted Advisor
Posts: 1,300

Re: Getting a CryptoException class not found error when connecting with JDBC

I believe you are not getting the results you want from .jaddClassPath() because a JVM has not yet been initiated.  So, the sas.core.jar is not in the classpath for RJDBC.  Try call .jinit() before .jaddClassPath and check what you have by using print(.jclassPath()) if you receive the error again.

View solution in original post


All Replies
Grand Advisor
Posts: 9,593

Re: Getting a CryptoException class not found error when connecting with JDBC

As far as I can see , such question should be submitted to sas support.

Technical Support Form

Trusted Advisor
Posts: 1,300

Re: Getting a CryptoException class not found error when connecting with JDBC

Are you trying to perform a SAS/Share or SAS/IOM connection?  Share you connection string and any set properties.

New Contributor
Posts: 3

Re: Getting a CryptoException class not found error when connecting with JDBC

Thanks for your replies. I am using a jdbc:sharenet:// URL to the WRDS cloud.

The code can be found on my GitHub: wrds/wrds.R at 7edfbfe89ddc329618be72e591cc0bd50e294ea4 · wthielen/wrds · GitHub

Community Manager
Posts: 2,697

Re: Getting a CryptoException class not found error when connecting with JDBC

You might need to add additional jars into your classpath.  Also, SAS may require a specific version of the JRE.  I agree that you might want to track this with SAS Tech Support for the best advice, and anything you can do to create a standalone example might be helpful.

Chris

Solution
‎07-06-2015 11:55 AM
Trusted Advisor
Posts: 1,300

Re: Getting a CryptoException class not found error when connecting with JDBC

I believe you are not getting the results you want from .jaddClassPath() because a JVM has not yet been initiated.  So, the sas.core.jar is not in the classpath for RJDBC.  Try call .jinit() before .jaddClassPath and check what you have by using print(.jclassPath()) if you receive the error again.

New Contributor
Posts: 3

Re: Getting a CryptoException class not found error when connecting with JDBC

Thanks, FriedEgg! Adding the .jinit() fixed the issue. If you have a StackOverflow account, please add the same answer there, and I'll accept it as the answer. Otherwise, I'll do it. Please let me know.

Regular Learner
Posts: 1

Re: Getting a CryptoException class not found error when connecting with JDBC

Hi,

Is it please possible to describe the steps you used to resolve this problem in more detail.

Specifically, what lines of code should one add in RStudio to resolve this problem? 

Thanks

Regular Learner
Posts: 1

Re: Getting a CryptoException class not found error when connecting with JDBC

Hello --

 

 

Sorry I'm late to the party. This error message can mean one of a few things in the context of an R + RJDBC + rJava --> JDBC --> SAS/SHARE connection, but each centers around an inabiity for the stack to properly find the component drivers.

 

1. Be sure you have downloaded BOTH required SAS JDBC drivers ( sas.core.jar and sas.intrnet.javatools.jar ) to the same directory on your machine.

 

2. Be sure you have an .Renviron file that explictly lists both of these files, in appropriate syntax for your platform. Example:

 

Mac:

  CLASSPATH="/Users/my_user/Documents/JDBC_Drivers/sas.core.jar:/Users/my_user/Documents/JDBC_Drivers/sas.intrnet.javatools.jar"

 

Windows:

  CLASSPATH="C:/Users/my_user/Documents/JDBC_Drivers/sas.core.jar;C:/Users/my_user/Documents/JDBC_Drivers/sas.intrnet.javatools.jar"

 

Note the semicolon delimiter for the Windows version!

 

3. If you are connecting to WRDS, the .Rprofile code you were given (search the WRDS website for "Using R with WRDS") includes a path to sas.intrnet.javatools.jar. Make sure you update this path to reflect where you have actually placed this driver! It should be the same as in your .Renviron file.

 

4. If you are using RStudio, be sure that you have placed your .Renviron and .Rprofile files in a location that RStudio knows to look. This directory is controlled by the preference setting General > Default working directory (when not in a project).

 

 

Bonus Info! Be sure you are using RJDBC version 0.2-5 or later! Version previous to 0.2-5 experienced a major bug that caused queries resulting in more than 32767 observations to return zero observations instead!

 

Hope this helps someone!

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 8 replies
  • 1135 views
  • 1 like
  • 6 in conversation