cancel
Showing results for 
Search instead for 
Did you mean: 

Web Programming JCo

Former Member
0 Kudos

Hi, thanks in advanced for all your answers

I'm trying to test the connection from a servlet to sap. I have made a an index.jsp where I type the data to open the connection (client,user,password,language,server,system). I checked that I recieved correctly the data in the servlet.

I deploy the application without problem but I got the following error when using the method connect():

java.lang.ExceptionInInitializerError: JCO.classInitialize(): Could not load middleware layer 'com.sap.mw.jco.rfc.MiddlewareRFC'

JCO.nativeInit(): Could not initialize dynamic link library sapjcorfc [C:\WINDOWS\system32\sapjcorfc.dll: Can't find dependent libraries]. java.library.path [C:\j2sdk1.4.2_11\jre\bin\server;C:\j2sdk1.4.2_11\jre\bin;C:\j2sdk1.4.2_11\bin;D:\usr\sap\DEV\DVEBMGS00\j2ee\os_libs;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\Dell\SysMgt\oma\bin;C:\Program Files\Microsoft SQL Server\90\Tools\binn\;C:\Program Files\Microsoft SQL Server\90\DTS\Binn\;C:\Program Files\Microsoft SQL Server\90\Tools\Binn\VSShell\Common7\IDE\;D:\usr\sap\DEV\SYS\exe\uc\NTI386]

I have copied the necesary dlls (librfc32u and sapjcorfc) are into the folder c:\windows\system32\ in the server.

Also I have done the Jco's tutorial from help.sap.com I could read a table and show it on the console, so I don't know why I failed when using a servlet.

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

Place the libraries in D:\usr\sap\DEV\DVEBMGS00\j2ee\os_libs, so the class loader of the JVM will find it (don't forget J2EE VM and J2SE VM are not the same, J2EE Vm runs in it own container and so it doesn't check what lies in the os system directories; ATTENTION SUN J2VM and SUN J2EE VM are not the same!!!). Vladimir Pavlov has written an great blog on how the Class Loader System of the SAP J2EE works, can't find it at the moment but search through the blogs and you will find it (Vladimir correct me if I'm wrong, and if I'm so sorry!).

But an other question, why work with native JCO access?

There are other possibilities (sorted in my preference):

- Use Web Services to call SAP Functions (my favourite!!!, create WS in ABAP backend, get the WSDL, and call it in JAVA)

- Use SAP Enterprise Connector (wraps native JCO calls to backend into (proxy classes for you, works only with NWDS)

- Use JCA (a hard way, you've to write a connector and so on, ... refer to SAP help and SUN Help, wou will find a mass of examples how to write such an connector)

Regards,

Daniel

Former Member
0 Kudos

Thanks for your answers guys. All of your answers were helpful.

Looking around the forums in order to solve my problem, I found a topic where they mentioned that you had to reference the library in the EAR Project too. This is what I did:

Open developer studio:

1. Open the EAR project and look for the archive "application-j2ee-engine.xml".

2. In the "general" tab you will see a treebrowser "References", select it.

3. Then click the "Add" button and a list of the libraries.

4. A dialog box appears, and choose the middle button ("Select Library/Interface/Select Application")

5. Then a list of all the libraries sap.com appears.

6. Select " com.sap.mw.jco".

7. Save the changes.

8. Go to the WebModule and build it again, the same with the EAR project.

9. Deploy it and run it.

Former Member
0 Kudos

hi i am currently working on mb5b and mm60 transactions. i need to bring the list through jsp.. can u give me the source code for jsp and jco..

thanks in Advance

Former Member
0 Kudos

Hi,

You need to register this dll

To register a dll you can use the following

Syntax

regsvr32 </u> [/s] [/n] [/i[:cmdline]] dllname

Parameters

/u

Unregisters server.

/s

Specifies regsvr32 to run silently and to not display any message boxes.

/n

Specifies not to call DllRegisterServer. You must use this option with /i.

/i:cmdline

Calls DllInstall passing it an optional [cmdline]. When used with /u, it calls dll uninstall.

dllname

Specifies the name of the dll file that will be registered.

/?

Displays help at the command prompt.

Ex: regsvr32 sapjcorfc.dll

Regards

Ayyapparaj