cancel
Showing results for 
Search instead for 
Did you mean: 

Invoking Java Applet from SAP Netweaver Eportal using java webdynpro

Former Member
0 Kudos

Hi ,

We are using SAP Netweaver portal version 7.0.WE want to invoke java applet into webdynpro java application on button click.

The Applet should open in a new window when the particular parameter is selected and the button is clicked

The code is given below:

String html = "<HTML> <HEAD></HEAD> <BODY><APPLET code=\"org.faceless.pdf2.viewer2.PDFViewerApplet\" type=\"application/x-java-applet;version=1.4.2_05\" archive=\"bfopdf.jar\" width=800 height=600></APPLET></BODY></HTML>";

IWDCachedWebResource resource = WDWebResource.getWebResource(html.getBytes("UTF-8"), WDWebResourceType.HTML);

resource.setResourceName("HTML_inline.html");

IWDWindow window = wdComponentAPI.getWindowManager().createNonModalExternalWindow(resource.getAbsoluteURL(),"Image");

window.removeWindowFeature(WDWindowFeature.TOOL_BAR);

window.removeWindowFeature(WDWindowFeature.ADDRESS_BAR);

window.removeWindowFeature(WDWindowFeature.STATUS_BAR);

window.open();

But after clicking on button new html window is opening and the applet is not showing properly. The java console showing the error:

java.lang.ClassFormatError: Truncated class file

at java.lang.ClassLoader.defineClass1(Native Method)

at java.lang.ClassLoader.defineClassCond(Unknown Source)

at java.lang.ClassLoader.defineClass(Unknown Source)

at java.security.SecureClassLoader.defineClass(Unknown Source)

at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)

at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Unknown Source)

at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)

at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)

at java.lang.ClassLoader.loadClass(Unknown Source)

at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unknown Source)

at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source)

at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)

at java.lang.Thread.run(Unknown Source)

Exception: java.lang.ClassFormatError: Truncated class file

Please suggest how to solve this error.

Regards,

Dhruba

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi Robin,

Thank u for ur reply.

I ve downloaded the jar(which is embeded in html) file from the net.I ve tested jar file by using it in local html.The jar/applet works fine (i.e the local html properly shows the applet)with JDK 1.5 or later but does not work with jdk 1.4.(shows the "Bad magic Number error")

The SAP portal is hosted on HP-UX with java version 1.4. When we access the applet in sap portal from my pc having jdk 1.6 the applet shows the "truncated ..." error.

Can u please tell me the procedure to link applet in SAP eprtal(java webdynpro)

Regards,

Dhruba

Qualiture
Active Contributor
0 Kudos

Hi,

I'm afraid I don't have any conclusive answer to your solution...

To my knowledge, it should make no difference whether the applet is run from a local HTML file or is provided thru a web server; in the end, the applet is still running on the client browser and not on the server, and therefore relying in the client JVM.

From the <applet> tag, it seems the jar file is in the same folder as the HTML file containing the <applet> reference, is this correct?

Former Member
0 Kudos

In the beginning I ve not mentioned the <codebae> property of applet .But after seeing the "truncated .." error I ve mentioned the <codebase> in <applet>.

codebase ="Agreement/webdynpro/public/lib/"

where location of the jar file in server is " /usr/sap/EPD/JC00/j2ee/cluster/server0/apps/local/Agreement/webdynpro/public/lib/" and

ClassLoader name: "local/Agreement"

After mentioning the <codebase> value also the problem was not solved, showing the same error "truncated .." .

But When I used the localhtml, the jar file is in the same folder as the HTML file containing the <applet> reference.

Former Member
0 Kudos

Hi Robin,

I am getting the same error "truncated class file" during applet execution.Can u please provide me some fully functional applet code and procedure for integration with SAP eportal.

Qualiture
Active Contributor
0 Kudos

Hi,

I'm not sure, but I believe the 'code' argument should end with '.class'. However, your implementation of displaying a Java applet seems ok, the error is within the applet's Jar file

Anyway, have a look at http://download.oracle.com/javase/1,5.0/docs/guide/plugin/developer_guide/using_tags.html#applet and http://www.w3.org/TR/html401/struct/objects.html#h-13.4 on how to use the <applet> tag

As a test, you could try and create a local HTML document on your local desktop, including the applet. I would suspect you will receive the same error in your Java console

I believe the only option is to recompile your Java applet (if possible at all) against a newer JDK (1.4 and up)

Former Member
0 Kudos

Hi Robin,

Thank u for ur reply.

Can u please tell me the approach which I ve taken to view the java applet from Java Webdynpro is OK ?

Regards,

Dhruba

Qualiture
Active Contributor
0 Kudos

Hi Dhruba,

In essence, your code is fine. However, as a general recommendation, I would put any custom HTML, images, or other resources such as Java applets in your Web Dynpro's src/mimes/component directory.

This way, you don't have to modify your HTML inside java classes which eases future maintenance and you ensure your custom code and/or resources are deployed with your WD project.

Also, if you don't want to use a popup but you want to display your applet inline in your WD application, you could consider using an IWDIFrame

Best regards,

Robin

Qualiture
Active Contributor
0 Kudos

Hi,

If my memory serves me right, I believe the error originates from java code compiled using a really ancient Sun JVM

Recompiling the applet code should solve your problem

Best,

Robin

Qualiture
Active Contributor
0 Kudos

In addition, I just found some documentation [elaborating more on my previous post|http://download.oracle.com/javase/1.4.2/docs/guide/deployment/deployment-guide/upgrade-guide/article-01.html]

Hope this explains!

Robin