sassoftware / saspy

A Python interface module to the SAS System. It works with Linux, Windows, and Mainframe SAS as well as with SAS in Viya.
https://sassoftware.github.io/saspy
Other
375 stars 149 forks source link

can't connect SAS when using "winlocal" method #135

Closed edcba123 closed 6 years ago

edcba123 commented 6 years ago

HI,i have some problem in the first step when using saspy.when i run the following line,there is no reaction,and it seems like a dead end. sas=saspy.SASsession(cfgname="winlocal") I hope you can help me solve the problem,thanks.

tomweber-sas commented 6 years ago

I can do that. But I need a little more information. Are you trying to run on windows? Is SAS installed on it? Did you configure your classpath? Where/how are you running this? did you import saspy?

Thanks, Tom

PistonIntJack commented 6 years ago

Hi, Tom, ,I have the same question. I trying to run on windows. I have installed on SAS. I think I finished my configuration(I have modify 94400 to 94250). when I write the code sas=saspy.SASsession(cfgname="winlocal") . the result: Using SAS Config named: winlocal The native implementation module for the security package could not be found in the path. SAS process has terminated unexpectedly. RC from wait was: 4294967290 SAS Connection failed. No connection established. Double check you settings in sascfg.py file.

thank you

tomweber-sas commented 6 years ago

Hey, that one I can tell you. That's the error you get when you don't have the spiauth.dll path in your PATH. See https://sassoftware.github.io/saspy/install.html#local (it's in the second paragraph).

The native implementation module for the security package could not be found in the path.

This is in the troubleshooting guide too (just for reference). https://sassoftware.github.io/saspy/troubleshooting.html#iom

PistonIntJack commented 6 years ago

Tom, Thank you for your answer. I can run now. sas = saspy.SASsession() Using SAS Config named: winlocal SAS Connection established. Subprocess id is 8776

lyncodes commented 6 years ago

@PistonIntJack do you run SAS on windows or linux? my error looks like this:

Java Error: java.lang.NoClassDefFoundError: com/sas/services/connection/ConnectionFactoryException at java.lang.Class.getDeclaredMethods0(Native Method) at java.lang.Class.privateGetDeclaredMethods(Unknown Source) at java.lang.Class.privateGetMethodRecursive(Unknown Source) at java.lang.Class.getMethod0(Unknown Source) at java.lang.Class.getMethod(Unknown Source) at sun.launcher.LauncherHelper.validateMainClass(Unknown Source) at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source) Caused by: java.lang.ClassNotFoundException: com.sas.services.connection.ConnectionFactoryException at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) ... 7 more Error: A JNI error has occurred, please check your installation and try again Exception in thread "main" Subprocess failed to start. Double check you settings in sascfg.py file.

and my cpW path is already right, java path is rigth too. please!!!!

tomweber-sas commented 6 years ago

@lyncodes the error:

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

implies that you don't have the right jars in your classpath or the classpath isn't quite right, as it can't find the correct java classes. Can you show me the classpath? Where did the jars come from? I've see a couple of occasions where the jars from a client only install (like EG), didn't have all of the necessary classes in them. Did you get them from a full SAS install (MVA, Foundation SAS), or from a client only install like EG?

Thanks, Tom

lyncodes commented 6 years ago

@tomweber-sas

thank you first!

operation system:win 10

  1. I didn't install the sas on disk C,so there is a folder named MYSAS,which can be seen as the SAShome folder,and I used miniconda instead of anaconda.
  2. Actually I know nothing about the JAVA,so the java on my machine was installed by the exe file itself ,so I don't know the path C:\\Program Files\\Java\\jre1.8.0_161\\bin\\java specified is rigth or not? thank you.
  3. I googled the com/sas/services/connection/ConnectionFactoryException,found that SAS SUPPORT provide a few sites about that,but no files for download ? is that plausible to add some files to somewhere in my machine?
  4. YES ! ! I installed all the products from the setup file before,cause I know oneday I could meet problems like this ,so I checked all the options to install all the products!
  5. this is part of my configration about winlocal and its classpath below.
    
    # build out a local classpath variable to use below for Windows clients
    cpW  =  "‪D:\\MYSAS\\SASDeploymentManager\\9.4\\products\\deploywiz__94250__prt__xx__sp0__1\\deploywiz\\sas.svc.connection.jar"
    cpW += ";D:\\MYSAS\\SASDeploymentManager\\9.4\\products\\deploywiz__94250__prt__xx__sp0__1\\deploywiz\\log4j.jar"
    cpW += ";D:\\MYSAS\\SASDeploymentManager\\9.4\\products\\deploywiz__94250__prt__xx__sp0__1\\deploywiz\\sas.security.sspi.jar"
    cpW += ";D:\\MYSAS\\SASDeploymentManager\\9.4\\products\\deploywiz__94250__prt__xx__sp0__1\\deploywiz\\sas.core.jar"
    cpW += ";C:\\Users\\lynme\\Miniconda3\\Lib\\site-packages\\saspy\\java\\saspyiom.jar"

And, if you've configured IOM to use Encryption, you need these client side jars.

cpW += ";C:\Program Files\SASHome\SASVersionedJarRepository\eclipse\plugins\sas.rutil_904300.0.0.20150204190000_v940m3\sas.rutil.jar"

cpW += ";C:\Program Files\SASHome\SASVersionedJarRepository\eclipse\plugins\sas.rutil.nls_904300.0.0.20150204190000_v940m3\sas.rutil.nls.jar"

cpW += ";C:\Program Files\SASHome\SASVersionedJarRepository\eclipse\plugins\sastpj.rutil_6.1.0.0_SAS_20121211183517\sastpj.rutil.jar"

winlocal = {'java' : 'C:\Program Files\Java\jre1.8.0_161\bin\java', 'encoding' : 'utf-8', 'classpath' : cpW }


# thank you tom !
tomweber-sas commented 6 years ago

@lyncodes Ok, so you do have SAS installed in D:\MYSAS? IF so that should be good. And the paths to the jars are correct? Can you go to D:\MYSAS\SASDeploymentManager\9.4\products\deploywiz94250prtxxsp0__1\deploywiz\ and see those jars? Since you're getting a Java error, it would appear that your path to java is valid. I wouldn't know where you have it installed, but that seems to work. For 3, there's nothing for you to download. If you have actual SAS installed, then the jars are the correct ones. Is 4 about installing SAS? You installed all of the product you had licensed; is that what you're describing? That's all good.

Can I see the entire output from sumitting

import saspy
saspy
saspy.SAScfg
sas = saspy.SASsession()

If you run that in jupyter, put the lines in different cells so we see all of the output. If you run from python command line, it will all show up, so you can just submit it all.

Thanks, Tom

lyncodes commented 6 years ago

@tomweber-sas

yes,i installed sas to D:\MYSAS\ ,and the four jar files are there.

i install the java in C:\Program Files (x86)\Java ,to solve the problem it may need to install the java again i thought.

this is the log for SASmodules information.

System birthday:   02NOV2017.
Operating System:   WX64_WKS.
Product expiration dates:
---Base SAS Software                                                                                    30NOV2018
---SAS/STAT                                                                                             30NOV2018
---SAS/GRAPH                                                                                            30NOV2018
---SAS/ETS                                                                                              30NOV2018
---SAS/FSP                                                                                              30NOV2018
---SAS/OR                                                                                               30NOV2018
---SAS/AF                                                                                               30NOV2018
---SAS/IML                                                                                              30NOV2018
---SAS/QC                                                                                               30NOV2018
---SAS/SHARE                                                                                            30NOV2018
---SAS/ASSIST                                                                                           30NOV2018
---SAS/CONNECT                                                                                          30NOV2018
---SAS/EIS                                                                                              30NOV2018
---SAS/SHARE*NET                                                                                        30NOV2018
---SAS Enterprise Miner                                                                                 30NOV2018
---MDDB Server common products                                                                          30NOV2018
---SAS Integration Technologies                                                                         30NOV2018
---SAS/Secure 168-bit                                                                                   30NOV2018
---SAS/Secure Windows                                                                                   30NOV2018
---SAS Text Miner                                                                                       30NOV2018
---SAS/Genetics                                                                                         30NOV2018
---SAS Enterprise Guide                                                                                 30NOV2018
---SAS Bridge for ESRI                                                                                  30NOV2018
---OR OPT                                                                                               30NOV2018
---OR PRS                                                                                               30NOV2018
---OR IVS                                                                                               30NOV2018
---OR LSO                                                                                               30NOV2018
---SAS/ACCESS Interface to DB2                                                                          30NOV2018
---SAS/ACCESS Interface to Oracle                                                                       30NOV2018
---SAS/ACCESS Interface to Sybase                                                                       30NOV2018
---SAS/ACCESS Interface to PC Files                                                                     30NOV2018
---SAS/ACCESS Interface to ODBC                                                                         30NOV2018
---SAS/ACCESS Interface to OLE DB                                                                       30NOV2018
---SAS/ACCESS Interface to Teradata                                                                     30NOV2018
---SAS/ACCESS Interface to MySQL                                                                        30NOV2018
---SAS Enterprise Miner for Desktop                                                                     30NOV2018
---SAS/IML Studio                                                                                       30NOV2018
---SAS Workspace Server for Local Access                                                                30NOV2018
---SAS/ACCESS Interface to Netezza                                                                      30NOV2018
---SAS/ACCESS Interface to Aster nCluster                                                               30NOV2018
---SAS/ACCESS Interface to Greenplum                                                                    30NOV2018
---SAS/ACCESS Interface to Sybase IQ                                                                    30NOV2018
---High Performance Suite                                                                               30NOV2018
---SAS Add-in for Microsoft Excel                                                                       30NOV2018

if i edit the configname to 'default'

import saspy
saspy
saspy.SAScfg
sas = saspy.SASsession()

output looks like this:

Using SAS Config named: default
Cannot use STDIO I/O module on Windows. No SASsession established. Choose an IOM SASconfig definition

if i edit the configname to 'winlocal'

with the same python codes above,error looks like this:

Using SAS Config named: winlocal
Java Error:
java.lang.NoClassDefFoundError: com/sas/services/connection/ConnectionFactoryException
    at java.lang.Class.getDeclaredMethods0(Native Method)
    at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
    at java.lang.Class.privateGetMethodRecursive(Unknown Source)
    at java.lang.Class.getMethod0(Unknown Source)
    at java.lang.Class.getMethod(Unknown Source)
    at sun.launcher.LauncherHelper.validateMainClass(Unknown Source)
    at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
Caused by: java.lang.ClassNotFoundException: com.sas.services.connection.ConnectionFactoryException
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    ... 7 more
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" 

Subprocess failed to start. Double check you settings in sascfg.py file.

Attempted to run program C:\Program Files (x86)\Java\jre1.8.0_171\bin\java with the following parameters:['C:\\Program Files (x86)\\Java\\jre1.8.0_171\\bin\\java', '-classpath', 'D:\\mysas9.4\\SASDeploymentManager\\9.4\\products\\deploywiz__94472__prt__xx__sp0__1\\deploywiz\\sas.svc.connection.jar;D:\\mysas9.4\\SASDeploymentManager\\9.4\\products\\deploywiz__94472__prt__xx__sp0__1\\deploywiz\\log4j.jar;D:\\mysas9.4\\SASHome\\SASDeploymentManager\\9.4\\products\\deploywiz__94472__prt__xx__sp0__1\\deploywiz\\sas.security.sspi.jar;D:\\mysas9.4\\SASHome\\SASDeploymentManager\\9.4\\products\\deploywiz__94472__prt__xx__sp0__1\\deploywiz\\sas.core.jar;C:\\ProgramData\\Anaconda3\\Lib\\site-packages\\saspy\\java\\saspyiom.jar', 'pyiom.saspy2j', '-host', 'localhost', '-stdinport', '62301', '-stdoutport', '62302', '-stderrport', '62303', '-zero', '']

If no Java Error above, try running the following command (where saspy is running) manually to see if it's a problem starting Java:
C:\Program Files (x86)\Java\jre1.8.0_171\bin\java -classpath "D:\mysas9.4\SASDeploymentManager\9.4\products\deploywiz__94472__prt__xx__sp0__1\deploywiz\sas.svc.connection.jar;D:\mysas9.4\SASDeploymentManager\9.4\products\deploywiz__94472__prt__xx__sp0__1\deploywiz\log4j.jar;D:\mysas9.4\SASHome\SASDeploymentManager\9.4\products\deploywiz__94472__prt__xx__sp0__1\deploywiz\sas.security.sspi.jar;D:\mysas9.4\SASHome\SASDeploymentManager\9.4\products\deploywiz__94472__prt__xx__sp0__1\deploywiz\sas.core.jar;C:\ProgramData\Anaconda3\Lib\site-packages\saspy\java\saspyiom.jar" pyiom.saspy2j -host localhost -stdinport 62301 -stdoutport 62302 -stderrport 62303 -zero  

No SAS process attached. SAS process has terminated unexpectedly.
No SAS process attached. SAS process has terminated unexpectedly.
No SAS process attached. SAS process has terminated unexpectedly.

i think the problem must be the java?

tomweber-sas commented 6 years ago

I'm not that suspicious of java itself. It appears to be trying to run as I would expect. I still suspect it's your classpath or jars. What version of SAS is this? Also, I see that the paths to your jars has the exact same \deploywiz94472prtxxsp0__1\ directory as in the sample sascfg.py. Although this is possible, it's a little unlikely, as the exact path (those nubers in the directory name), change with every release. My best guess from what I see is that the exact path to those jars isn't correct. Did you verify the full path and edit the sascfg classpath to be sure it's correct? If the path is right, and it's finding the jars, but the classes are not in them, then I would be suspicious of what version of SAS this is. Those are the only two reasons I would think you would get this error. I guess the other thing, if the path and jar versions are correct, could be java, if it's the wrong architecture (32bit instead of 64bit)? I'm not sure, without investigating, if that matters on windows or not. First I would verify the full paths to the jars, and your SAS version. Thanks! Tom

lyncodes commented 6 years ago

@tomweber-sas the porblem i have fixed. cause i specified a wrong path for java;

winlocal = {'java'      : 'C:\\Program Files\\Java\\jre1.8.0_161\\bin\\java',
            'encoding'  : 'utf-8',
            'classpath' : cpW
            }

after the java,there should be follwed a .exe Thanks for you help!

tomweber-sas commented 6 years ago

That's great! Glad that fixed it. I'll go ahead and close this one.

Thanks! Tom