BookmarkSubscribeRSS Feed
Obsidian | Level 7



I am trying to use SasPy, I have configured it correctly (as far as i can tell) by modifying, but when I run the following code I get a Java error. 

Here are the machine specs:

- OS: Windows Server 2012R2

- Java version : "1.6.0_45"

- SAS: 9.4_M2

- Python 3.6, Anaconda distribution


Is this java related - i.e. does SasPy have some minimum Java requirements ? Or is there some other issue that I'm missing?


import saspy
sas = saspy.SASsession(cfgname='winlocal')

Java Error:
java.lang.NoClassDefFoundError: com/sas/services/connection/ConnectionFactoryException
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(
at java.lang.Class.getMethod0(
at java.lang.Class.getMethod(
at sun.launcher.LauncherHelper.getMainMethod(
at sun.launcher.LauncherHelper.checkAndLoadMain(
Caused by: java.lang.ClassNotFoundException:
at Method)
at java.lang.ClassLoader.loadClass(
at sun.misc.Launcher$AppClassLoader.loadClass(
at java.lang.ClassLoader.loadClass(
6 more
Exception in thread "main"


SAS Employee

The type of error returned for an unsupported Java version would be something like this:

>>> sas = saspy.SASsession(cfg='winlocal')
Using SAS Config named: winlocal
Java Error:
java.lang.UnsupportedClassVersionError: pyiom/saspy2j : Unsupported major.minor version 51.0


The type of error you're getting:

Java Error:
java.lang.NoClassDefFoundError: com/sas/services/connection/ConnectionFactoryException

indicates an issue with the class paths to the jars rather than the version of Java.


Verify that the class paths in the file are correct. The default paths to the jars under the SASDeploymentManager install directory included in the file almost certainly need to be updated for the maintenance release of SAS running at your site. For example, I had to update mine to reference the correct deploywiz__<version>__ for my SAS release as follows:

# build out a local classpath variable to use below for Windows clients
cpW  =  "C:\\Program Files\\SASHome\\SASDeploymentManager\\9.4\\products\\deploywiz__94502__prt__xx__sp0__1\\deploywiz\\sas.svc.connection.jar"
cpW += ";C:\\Program Files\\SASHome\\SASDeploymentManager\\9.4\\products\\deploywiz__94502__prt__xx__sp0__1\\deploywiz\\log4j.jar"
cpW += ";C:\\Program Files\\SASHome\\SASDeploymentManager\\9.4\\products\\deploywiz__94502__prt__xx__sp0__1\\deploywiz\\"
cpW += ";C:\\Program Files\\SASHome\\SASDeploymentManager\\9.4\\products\\deploywiz__94502__prt__xx__sp0__1\\deploywiz\\sas.core.jar" 
Obsidian | Level 7

I think is configured correctly, this is then entire contents of the file:


SAS_config_options = {'lock_down': False,
'verbose' : True

SAS_output_options = {'output' : 'html5'}

cpW = "D:\\Program Files\\SASHome\\SASDeploymentManager\\9.4\\products\\deploywiz__94472__prt__xx__sp0__1\\deploywiz\\sas.svc.connection.jar"
cpW += ";D:\\Program Files\\SASHome\\SASDeploymentManager\\9.4\\products\\deploywiz__94472__prt__xx__sp0__1\\deploywiz\\log4j.jar"
cpW += ";D:\\Program Files\\SASHome\\SASDeploymentManager\\9.4\\products\\deploywiz__94472__prt__xx__sp0__1\\deploywiz\\"
cpW += ";D:\\Program Files\\SASHome\\SASDeploymentManager\\9.4\\products\\deploywiz__94472__prt__xx__sp0__1\\deploywiz\\sas.core.jar"
cpW += ";D:\\Anaconda3\\envs\\prod1\\Lib\\site-packages\\saspy\\java\\saspyiom.jar"

winlocal = {'java' : 'D:\\Program Files\\SASHOME\\SASPrivateJavaRuntimeEnvironment\\9.4\\jre\\bin\\java',
'encoding' : 'windows-1252',
'classpath' : cpW


All files in the cpW dictionary exist at that path. The path in winlocal points to the folder where java.exe and java.dll are located (they are actually in the "bin" folder, but it seems adding "java" at the end is necessary). I tried adding ".exe." and I received the same error. 

SAS Employee

Hi there. I have only just started looking at these posts on Communities. I've only gotten Issues through my saspy Github site till now.

As it turns out, Java 6 (1.6) is too old to work with saspy. I've hit this issue a few times with other customers and getting a more current version of Java (Java 8  is the 'Current' one if you go to to download) has resolved the problem each time.

And, yes, your config appears perfectly reasonable. I think it is just the old Java.





Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Get the $99 certification deal.jpg



Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 3 in conversation