cancel
Showing results for 
Search instead for 
Did you mean: 

java.lang.RuntimePermission loadLibrary.sapjcorfc

Former Member
0 Kudos

Hi all

I've installed jco on my laptop in order to develop applets connecting to SAP R/3 and calling BAPIs

I've also put sapjco.jar into <JAVA_HOME>\lib\ext folder and sapjcorfc.dll into C:\WINDOWS\system32 folder. The dll librfc32.dll is that of my SAP Gui 6.4 (path level 14).

My jre is 1.5.0_05.

When I test a sample applet code from within Eclipse environment it works well (I created a package called kedrionDemo).

Instead, when I try to run it from an html page, the applet is started but when I try to start the connection I get the following:

Exception in thread "AWT-EventQueue-2" java.lang.ExceptionInInitializerError: JCO.classInitialize(): Could not load middleware layer 'com.sap.mw.jco.rfc.MiddlewareRFC'

access denied (java.lang.RuntimePermission loadLibrary.sapjcorfc)

at com.sap.mw.jco.JCO.<clinit>(JCO.java:566)

at kedrionDemo.TestRFCApplet.connectDirectToSAP(TestRFCApplet.java:146)

at kedrionDemo.TestRFCApplet.actionPerformed(TestRFCApplet.java:134)

at java.awt.Button.processActionEvent(Unknown Source)

at java.awt.Button.processEvent(Unknown Source)

at java.awt.Component.dispatchEventImpl(Unknown Source)

at java.awt.Component.dispatchEvent(Unknown Source)

at java.awt.EventQueue.dispatchEvent(Unknown Source)

at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)

at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)

at java.awt.EventDispatchThread.pumpEvents(Unknown Source)

at java.awt.EventDispatchThread.pumpEvents(Unknown Source)

at java.awt.EventDispatchThread.run(Unknown Source)

Could anyone suggest a solution ?

Many thanks

Alessandro

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Either write a application instead of a applet or write a jsp that connects to a BAPI and have it return the results.

Former Member
0 Kudos

I think that's all with my problem. I think I have misinterpreted the posssible application scenarios of the object APPLET.

Thank you very much for your help

Alessandro

Answers (3)

Answers (3)

Former Member
0 Kudos

I do have a solution though. Why do you need the JCO connection in the applet? Since you are deploying the applet from an aplication server, hopefully from a java application server, you can create a servlet that does the JCO communication and then applet would make a URL connection to the servlet and pass parameters (or an object) and the servlet would send back the response that the applet would then parse.

We do this communication with applets, as sometimes it is nice to the additional objects that applets allow for. We make a Object output stream and send an object request and then receive an object response from a servlet.

applet code would look like this:

-


URL url = new URL("url of servlet");

URLConnection conn = url.openConnection();

conn.setDoOutput(true);

conn.setDoInput(true);

ObjectOutputStream output = new ObjectOutputStream(conn.getOutputStream());

output.writeObject(requestobject);

ObjectInputStream input = new ObjectInputStream(conn.getInputStream());

Object responseobj = input.readObject();

-


The servlet code would have in its "service" method:

-


ObjectInputStream input = new ObjectInputStream(request.getInputStream());

Connection conn = null;

ObjectOutputStream output = new ObjectOutputStream(response.getOutputStream());

Object objFromClient=input.readObject();

output.writeObject(o);

-


Former Member
0 Kudos

Hi Nathan

I just tried to understand how JCO works and followed the tutorial to build up same samples. Here you are the history of my work:

- At first I created a very simple class within Eclipse and run it with some BAPIs calls inside. Since it worked well, I said "why don't we try with an applet ?".

- Then, I created a suitable class in Eclipse, that is, I enclosed the Java code of the first test within an applet. I tested it within Eclipse and it works. The applet viewer loads the applet and the connection works returning expected data

- Finally, I created a very simple HTML page on my laptop loading the applet from my laptop (i.e., the applet.class file from Eclipse workspace) and got the error.

Since I am a beginner with Java world, may be I am not on the rigth way...

Thanks you for your suggestions

Alessandro

Former Member
0 Kudos

Again, Applets work in a specific Virtual Machine (VM). When you run the applet within Eclipse, it uses the Eclipse VM, which has the libraries and the OS specific libraries.

This is a totally different VM that you run the applet from when downloaded from the web. The VM that runs the applets from the web are very tight. You can contact the server in which it is downloaded from, but you can not touch the client in which it is running on. The OS specific libraries are on the client are therefore not reachable from a downloaded applet.

Of course there are other things you can do, like signing the applet and then requesting resources on the client, but I wouldn't get into that.

Former Member
0 Kudos

Here you are the scenario I tested on my laptop...

This is the html page whose file is stored on my laptop:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>

<head>

<title>Test RFC Kedrion - Applet JAVA e JCO</title>

</head>

<body>

<applet code="kedrionDemo/TestRFCApplet.class" width=600 height=600 >

</body>

</html>

The html page is stored in <my folder>, while the TestRFCApplet.class file is stored in <my folder>\kedrionDemo

When I double click on my html page on my laptop, tha applet appears with all input fields and when I start the connection if fails

So, do you mean that, even if the apple is downloaded locally, it behaves like if it were downloaded from a web server while running within Eclipse in my laptop is different ?

If yes, I think now I have understood what I am wrong on...

Many thanks

Former Member
0 Kudos

Yes, when an applet runs within a browser, it works like it was downloaded from a server.

I don't know what your final goal is, if you explained that, I could give you a direction.

Former Member
0 Kudos

My final goal is to write down an simple demo application written in Java that runs outside SAP but connects to it calling some BAPIs to retrieve some data.

I think it could be nice to have a demo application doing that and running from a browser, like a 'normal' web page.

Anyway, all other directions are welcome !

Thanks

Alessandro

Former Member
0 Kudos

I don't think this is going to work. Those two files that were mentioned above, are required to run the JCO. These are not java centric drivers, but instead require OS libraries.

When you run an applet, it is working on the client in a very tight VM. I doubt even if you put the DLL on the client, that it would have a chance to get to them. If that were the case, any java programmer could write applets to access all the other DLLs on the client. This would be hacker heaven.

Former Member
0 Kudos

Hi Alessandro

Cause: These exceptions typically occur when different versions of sapjcorfc.dll and sapjco.jar have been installed. Anytime the JCo connector is upgraded to a new version, you need to ensure that all three libraries are updated (librfc32.dll, sapjcorfc.dll, and sapjco.jar). If any are left at the older version, one of the above exceptions is likely to occur.

Resolution: Extract sapjcorfc.dll and sapjco.jar from the original JCo archive. Copy these files to the appropriate locations, overwriting the originally installed versions. Ensure that the PATH statement is updated to reflect the directory location of the DLL files and the Java CLASSPATH points to sapjco.jar.

regards

Sameer

Former Member
0 Kudos

Hi Sameer

I did not upgraded my JCo, it is the first installation. Anyway I ensured all libraries are up to date but the problem still comes. I can run and test my applet from within Eclipse IDE but not with the browser

Thank you

Alessandro