JOGL applet integration with jnlp parameter

Hi,

I’ve tried the following code which uses jnlp file to launch the jogl applet.

Panel MainPanel = new Panel(“Login”);
MainPanel .setWidth(“550px”);
MainPanel .setHeight(“550px”);

//Applet creation
AppletIntegration applet = new AppletIntegration() {
private static final long serialVersionUID = 1L;
@Override
public void attach() {

        		setCodebase("http://localhost:8080/ReportSystem");
        		setAppletParams("java_arguments", "-Dsun.java2d.noddraw=true");
        		setAppletParams("stlFile", "Rocker_bar_hollow.stl");
        		setAppletParams("jnlp_href", "applet-viewer.jnlp");
        		setAppletParams("page", "partviewer");
        		setWidth("500px");                
        		setHeight("500px");            
        	}        
        };  

MainPanel .addComponent(applet);


applet-viewer.jnlp code:

<?xml version="1.0" encoding="utf-8"?> Viewer DEP

no sign of applet just blank page with the mainpanel. am i missing something?

Note: the applet works fine with the tag in HTML form.

Hi all,

I’ve made some updates now applet starts to load and throws OutOfMemoryError.

Exception in thread “thread applet-com.viewer.stl.STLApplet-1” java.lang.OutOfMemoryError: Java heap space
at com.viewer.stl.STL.ReadSTLBinary(STL.java:81)
at com.viewer.stl.STLView.initSTL(STLView.java:535)
at com.viewer.stl.STLView.(STLView.java:146)
at com.viewer.stl.STLApplet.init(STLApplet.java:47)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

New
Appletintegration class
:

AppletIntegration applet = new AppletIntegration() {
private static final long serialVersionUID = 1L;
@Override
public void attach() {

        		setAppletClass("org.jdesktop.applet.util.JNLPAppletLauncher");
        		setAppletArchives(Arrays.asList(new String[]{"http://jogamp.org/deployment/util/applet-launcher.jar",
        													                               "http://jogamp.org/deployment/webstart/nativewindow.all.jar",
        													                                "http://jogamp.org/deployment/webstart/jogl.all.jar",
        													                                "http://jogamp.org/deployment/webstart/gluegen-rt.jar",
        													                                 "appletintegration-1.1.4.jar","applet.jar"}));
        		setAppletParams("codebase_lookup", "false");
        		setAppletParams("subapplet.classname", "com.viewer.stl.STLApplet");
        		setAppletParams("subapplet.displayname", "JOGL Applet");
        		setAppletParams("noddraw.check", "true");
        		setAppletParams("progressbar", "true");
        		setAppletParams("jnlpNumExtensions", "1");
        		setAppletParams("jnlpExtension1", "http://jogamp.org/deployment/webstart/jogl-core.jnlp");
        		setAppletParams("java_arguments", "-Xmx512m -Dsun.java2d.noddraw=true");
        		setAppletParams("stlFile", "Rocker_bar_hollow.stl");
        		setAppletParams("jnlp_href", "applet-viewer.jnlp");
        		setAppletParams("page", "partviewer");
        		setWidth("500px");                
        		setHeight("450px");            
        	}        
        }; 

New
applet-viewer.jnlp
code:

<?xml version="1.0" encoding="utf-8"?> STLViewer DEP

I can see all the required extension jars are downloaded and the applets init() function is called . In the init() function we are reading a file passed as applet parameter ‘stlFile’ with value ‘Rocker_bar_hollow.stl’.
1.‘Rocker_bar_hollow.stl’ is in the GWT public directory.
2.The file size is 800kb.

I tried setting ‘java_arguments’ to “-Xmx512m” then to “-Xmx1024m” but still Exception is thrown.

NOTE: in the normal html tag implementation we are able to read 20MB file with default heap size.

Hi all,

I've narrow down to the problem, AppletIntegration instance & applet-viewer.jnlp are perfectly fine. On applet init() function we are reading a binary file stream using java.io.DataInputStream.DataInputStream.


Applets’ reading code
:

System.out.println("Binary File Path : " + binaryfile);
InputStream instream = (new URL(binaryfile)).openConnection().getInputStream();
DataInputStream input = new DataInputStream(instream);
input.read(new byte[80]
);
int i = input.readInt();
System.out.println("EndianValue : "+ i );
int facecount = ((i & 0xff) << 24) + ((i & 0xff00) << 8) + ((i & 0xff0000) >> 8) + (i >> 24 & 0xff); //converting back to little endian format
System.out.println("FaceCount: "+ facecount );


Output at java console
:
a) Run using vaadin application:

Binary File Path : http://localhost:8080/ReportSystem/VAADIN/widgetsets/com.reportsystem.widgetset.ReportsystemWidgetset/Rocker_bar_hollow.stl
EndianValue : 541945714
FaceCount: 1919896864

b) Run using normal servlet application ( with .jsp page having tag)

Binary File Path : http://localhost:8080/servletApp/Rocker_bar_hollow.stl
EndianValue : 960823296
FaceCount: 17721

Since we are initializing an array based on FaceCount , it throwed OutOfMemoryError: Not sure which is creating the problem (Vaadin \ Java I/O).:blink:

Going further to verifiy the correctness of binary file stream reaching the applet init() method (when deployed using vaadin) by exporting the stream to the localfile system. Then using the exported file I tried with the Servlet application (i.e., jsp page with tag) were it got read perfectly fine!.:cold:

I’m out of ideas to dig in further.:what: Somebody should help me to move further.

I’m trying to do something similar to this and having trouble figuring out where to place my JNLP file such that the applet instantiation can find it by relative path. Where did you place your JNLP file(s) in your project structure?