nunomaia / NwRfcNet

An easy way of making SAP RFC calls from .NET Core
Apache License 2.0
96 stars 28 forks source link

Cannot load SAP NetWeaver RFC into container #46

Open InsonusK opened 4 years ago

InsonusK commented 4 years ago

I try to build .net core container (mcr.microsoft.com/dotnet/core/sdk:3.0-alpine + mcr.microsoft.com/dotnet/core/aspnet:3.0-alpine).

On loading sapnwrfc.dll, I get an error "Unable to load shared library '/app/libs/nwrfcnet/sapnwrfc.dll' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: Error loading shared library /app/libs/nwrfcnet/sapnwrfc.dll: Exec format error"

In issue #32 author has got .so libs, but in SAP Note 2573790 I could not find these such libs.

By the way, I load NwRfcNet lib not from Nuget, but directly from DLL. Because the last pull request has not been uploaded to NuGet yet.

InsonusK commented 4 years ago

Update: 1) I have found *.so at https://launchpad.support.sap.com/#/softwarecenter/search/SAP%2520NetWeaver%2520RFC%2520SDK%25207.50 2) I use code for registration libs like in https://github.com/nunomaia/NwRfcNet/issues/32#issuecomment-547212192

Result: System.DllNotFoundException: Unable to load shared library 'sapnwrfc' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: libsapnwrfc: cannot open shared object file: No such file or directory at NwRfcNet.Interop.RfcInterop.RfcOpenConnection(RFC_CONNECTION_PARAMETER[] connectionParams, UInt32 paramCount, RFC_ERROR_INFO& errorInfo) at NwRfcNet.RfcConnection.Open()

InsonusK commented 4 years ago

I have found solution: 1) Download *.so from launchpad.support.sap.com 2) In docker file, when create runtime container add:

RUN cp /app/libs/nw-sap-sdk/linux64/* /lib
RUN ldconfig -v -n /lib

this code is from this guide

/app/libs/nw-sap-sdk/linux64/ it is path where I store: libicudata.so.50, libicudecnumber.so, libicuuc.so.50, libicui18n.so.50, libsapnwrfc.so, libsapucum.so

P.S. I still use code from https://github.com/nunomaia/NwRfcNet/issues/32#issuecomment-547212192

nunomaia commented 4 years ago

Thanks for your comments. I tested in a Redhat distribution and I didn't had to force file extension, it just loaded fine. You are still having issues without the #32 patch ?

Did you tried to copy SAP libraries to folder where program is running ?

InsonusK commented 4 years ago

Thanks for your comments. I tested in a Redhat distribution and I didn't had to force file extension, it just loaded fine. You are still having issues without the #32 patch ?

I have tested code without code from https://github.com/nunomaia/NwRfcNet/issues/46#issuecomment-600109369: it work in container but it does not work in windows.

Did you tried to copy SAP libraries to folder where program is running ?

No I have not tried from App folder but I have tried to copy NwRfcNet and other libs into one folder, it does not work.

nunomaia commented 4 years ago

I have made a small test with Microsoft Docker image

source FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build

And it executed properly with changing the code ( I have tested with the latest version of code)

1)I have made a copy of Netweaver lib files to bin folder of running application.

Note : you must install uuuid in docker https://www.itsfullofstars.de/2016/02/netweaver-abap-sick-and-uuid-on-linux/

Capture