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
367 stars 149 forks source link

SASIOConnectionError: Failure establishing SASsession. #455

Closed j4ffle closed 2 years ago

j4ffle commented 2 years ago

Trying to connect to a local SAS session but keep receiving the same error. I added the directory of sspiauth.dll to my PATH environment variable.

I run this code:

import saspy, os
os.environ["PATH"] += "C:\\Program Files\\SASHome\\SASFoundation\\9.4\\core\\sasext"
java_path = 'C:\\Program Files\\Java\\jdk1.8.0_231\\bin\\Java.exe'
sas = saspy.SASsession(cfgname='winlocal', java=java_path)

and receive the below error

Java Error:
ERROR StatusLogger No Log4j 2 configuration file found. Using default configuration (logging only errors to the console), or user programmatically provided configurations. Set system property 'log4j2.debug' to show Log4j 2 internal initialization logging. See https://logging.apache.org/log4j/2.x/manual/configuration.html for instructions on how to configure Log4j 2
com.sas.services.connection.FatalConnectionFactoryException: The native implementation module for the security package could not be found in the path.
    at com.sas.services.connection.ClusterEnvelope.getConnection(ClusterEnvelope.java:248)
    at com.sas.services.connection.AggregationKernel.doGetConnection(AggregationKernel.java:242)
    at com.sas.services.connection.ConnectionFactoryKernel.getConnection(ConnectionFactoryKernel.java:325)
    at com.sas.services.connection.ConnectionFactoryShell.getConnection(ConnectionFactoryShell.java:69)
    at com.sas.services.connection.ConnectionFactoryShell.getConnection(ConnectionFactoryShell.java:51)
    at pyiom.saspy2j.main(saspy2j.java:201)
Caused by: org.omg.CORBA.INITIALIZE: The native implementation module for the security package could not be found in the path.  vmcid: 0x0  minor code: 0  completed: No
    at com.sas.iom.orb.brg.SecurityPackageBase.initClient(SecurityPackageBase.java:70)
    at com.sas.iom.orb.brg.Engine.createSecurityPackage(Engine.java:5530)
    at com.sas.iom.orb.brg.Engine.flowSendAuth(Engine.java:4312)
    at com.sas.iom.orb.brg.Engine.flow(Engine.java:717)
    at com.sas.iom.orb.brg.Engine.initClient(Engine.java:676)
    at com.sas.iom.orb.brg.ORBImpl.uri_to_object(ORBImpl.java:114)
    at com.sas.services.connection.ClusterEnvelope.createObject(ClusterEnvelope.java:394)
    at com.sas.services.connection.ClusterEnvelope.getConnection(ClusterEnvelope.java:86)
    ... 5 more
Caused by: java.lang.UnsatisfiedLinkError: no sspiauth in java.library.path
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1860)
    at java.lang.Runtime.loadLibrary0(Runtime.java:870)
    at java.lang.System.loadLibrary(System.java:1122)
    at com.sas.security.sspi.SSPIAuth.loadNativeLibrary(SSPIAuth.java:499)
    at com.sas.security.sspi.SSPIAuth.<init>(SSPIAuth.java:163)
    at com.sas.iom.orb.brg.SecurityPackageBase.initClient(SecurityPackageBase.java:62)
    ... 12 more

We failed in getConnection
The native implementation module for the security package could not be found in the path.
Subprocess failed to start. Double check your settings in sascfg_personal.py file.
Attempted to run program C:\Program Files\Java\jdk1.8.0_231\bin\Java.exe with the following parameters:['C:\\Program Files\\Java\\jdk1.8.0_231\\bin\\Java.exe', '-classpath', 'C:\\Users\\flakej\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\saspy\\java\\saspyiom.jar;C:\\Users\\flakej\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\saspy\\java\\iomclient\\log4j-1.2-api-2.12.4.jar;C:\\Users\\flakej\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\saspy\\java\\iomclient\\log4j-api-2.12.4.jar;C:\\Users\\flakej\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\saspy\\java\\iomclient\\log4j-core-2.12.4.jar;C:\\Users\\flakej\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\saspy\\java\\iomclient\\sas.security.sspi.jar;C:\\Users\\flakej\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\saspy\\java\\iomclient\\sas.core.jar;C:\\Users\\flakej\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\saspy\\java\\iomclient\\sas.svc.connection.jar;C:\\Users\\flakej\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\saspy\\java\\iomclient\\sas.rutil.jar;C:\\Users\\flakej\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\saspy\\java\\iomclient\\sas.rutil.nls.jar;C:\\Users\\flakej\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\saspy\\java\\iomclient\\sastpj.rutil.jar;C:\\Users\\flakej\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\saspy\\java\\thirdparty\\glassfish-corba-internal-api.jar;C:\\Users\\flakej\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\saspy\\java\\thirdparty\\glassfish-corba-omgapi.jar;C:\\Users\\flakej\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\saspy\\java\\thirdparty\\glassfish-corba-orb.jar;C:\\Users\\flakej\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\saspy\\java\\thirdparty\\pfl-basic.jar;C:\\Users\\flakej\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\saspy\\java\\thirdparty\\pfl-tf.jar', 'pyiom.saspy2j', '-host', 'localhost', '-stdinport', '59326', '-stdoutport', '59327', '-stderrport', '59328', '-zero', '-lrecl', '1048576', '']
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\Java\jdk1.8.0_231\bin\Java.exe -classpath "C:\Users\flakej\AppData\Local\Continuum\anaconda3\lib\site-packages\saspy\java\saspyiom.jar;C:\Users\flakej\AppData\Local\Continuum\anaconda3\lib\site-packages\saspy\java\iomclient\log4j-1.2-api-2.12.4.jar;C:\Users\flakej\AppData\Local\Continuum\anaconda3\lib\site-packages\saspy\java\iomclient\log4j-api-2.12.4.jar;C:\Users\flakej\AppData\Local\Continuum\anaconda3\lib\site-packages\saspy\java\iomclient\log4j-core-2.12.4.jar;C:\Users\flakej\AppData\Local\Continuum\anaconda3\lib\site-packages\saspy\java\iomclient\sas.security.sspi.jar;C:\Users\flakej\AppData\Local\Continuum\anaconda3\lib\site-packages\saspy\java\iomclient\sas.core.jar;C:\Users\flakej\AppData\Local\Continuum\anaconda3\lib\site-packages\saspy\java\iomclient\sas.svc.connection.jar;C:\Users\flakej\AppData\Local\Continuum\anaconda3\lib\site-packages\saspy\java\iomclient\sas.rutil.jar;C:\Users\flakej\AppData\Local\Continuum\anaconda3\lib\site-packages\saspy\java\iomclient\sas.rutil.nls.jar;C:\Users\flakej\AppData\Local\Continuum\anaconda3\lib\site-packages\saspy\java\iomclient\sastpj.rutil.jar;C:\Users\flakej\AppData\Local\Continuum\anaconda3\lib\site-packages\saspy\java\thirdparty\glassfish-corba-internal-api.jar;C:\Users\flakej\AppData\Local\Continuum\anaconda3\lib\site-packages\saspy\java\thirdparty\glassfish-corba-omgapi.jar;C:\Users\flakej\AppData\Local\Continuum\anaconda3\lib\site-packages\saspy\java\thirdparty\glassfish-corba-orb.jar;C:\Users\flakej\AppData\Local\Continuum\anaconda3\lib\site-packages\saspy\java\thirdparty\pfl-basic.jar;C:\Users\flakej\AppData\Local\Continuum\anaconda3\lib\site-packages\saspy\java\thirdparty\pfl-tf.jar" pyiom.saspy2j -host localhost -stdinport 59326 -stdoutport 59327 -stderrport 59328 -zero -lrecl 1048576  

No SAS process attached. SAS process has terminated unexpectedly.
Invalid response from SAS on inital submission. printing the SASLOG as diagnostic

I then ran the code in the command line and receive the error below:

java.net.ConnectException: Connection refused: connect
        at java.net.DualStackPlainSocketImpl.connect0(Native Method)
        at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:79)
        at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)     
        at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
        at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)       
        at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
        at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
        at java.net.Socket.connect(Socket.java:606)
        at java.net.Socket.connect(Socket.java:555)
        at java.net.Socket.<init>(Socket.java:451)
        at java.net.Socket.<init>(Socket.java:228)
        at pyiom.saspy2j.main(saspy2j.java:175)
Exception in thread "main" java.lang.NullPointerException
        at pyiom.saspy2j.main(saspy2j.java:184)

Desktop:

tomweber-sas commented 2 years ago

Well, that all looks like it ought to work. Can you show me what your config is (for winlocal)? And that path for the sspiauth.dll file is correct; the file's there and you have permission to it? Can you add the path to the system path variable and see if that helps? You may need to restart at least whatever python you're running after adding it, so it gets picked up. The rest seems right and the error when running the command directly is correct (expected). The error is that java can't load the sspiauth.dll, so let's try putting it into the real system path variable and see if that get's it found.

j4ffle commented 2 years ago

It looks like I may not have permissions to change the system path variable - or at least not that directory. I confirmed that after adding the directory to the PATH in python that it is included in the variable, but when I tried to add it to the system path variable through the control panel, I didn't seem to have the proper access to change it. I copied sspiauth.dll to another path that was already in the system path variable (C:\Program Files (x86)\Common Files\Oracle\Java\javapath) and it seems to have connected.

import saspy
java_path = 'C:\\Program Files\\Java\\jdk1.8.0_231\\bin\\Java.exe'
sas = saspy.SASsession(cfgname='winlocal', java=java_path)

now produces:

SAS Connection established. Subprocess id is 52748

Thanks for the quick response! I think that should do the trick.

tomweber-sas commented 2 years ago

Well that's great! It's had to diagnose windows issues like this, especially when you don't have full permissions on the system. Great job figuring to just copy the file to another location that was already in the path!

Let me know if you need anything else. Feel free to close this if you're good to go. Tom