Contents
 Contents

Developing and deploying Applets using FioranoMQ

Question 1: How do we develop Applets using FioranoMQ?

FioranoMQ applets are written in exactly the same way as normal applications are written except for a minor change during the initialization of a connection with the server.
Browser security restrictions allow uncertified Applets to establish connections only with the machine from which the applet is downloaded, i.e. the web server machine. This requires that unlike normal applications (which can connect to a FioranoMQ server running on any machine), uncertified applets are allowed to connect only to the machine from which the applet is downloaded.

Icon

Certified applets are allowed to connect to any host to which the web client has authorized access by the certificate provider. Different levels of permissions can be set for certificates from different certificate venders by the web client. An Applet carrying a certificate automatically invokes a window on web clients which do not allow it requisite permissions, asking if the user is interested in granting the permissions. Security parameter for all certificate holders can be explicitly set by using the advanced security options of popular browsers such as Netscape and Internet Explorer.

To use FioranoMQ services within an applet, the following steps need to be taken:

  1. The FioranoMQ Server must be installed on the same machine as the web-server.
  2. The IP address of the web-server machine needs to be provided by the Applet to create an instance of the class FioranoInitialContext. This IP address can be statically coded within the applet, or obtained dynamically using the generic method Applet.getCodeBase() from the java.awt.applet package. The rest of the code remains exactly the same as that for normal FioranoMQ applications.
Question 2: How do we deploy Applets using FioranoMQ?

Deployment of FioranoMQ applets is same as deployment of any other applet on a web server. The applet is developed as specified in the section above.
Once the applet has been developed, it is compiled and class files are created for the same. Once this is done, an HTML file using the applet tag is created. For example, consider an applet "MyApplet.java", which is compiled into the class file "MyApplet.class".
Presented below is a sample HTML file (MyApplet.html) that runs the Applet - "MyApplet.class".
//////////// Source listing – "MyApplet.html" /////////////////////////<html><head><title>Title of Applet Page</title></head><body><hr><applet code="MyApplet.class" width=400 height=310 archive="..\..\..\..\extlib\jms\jms.jar", "..\..\..\lib\client\fmq-client.jar"></applet><hr></body></html>

The important section is the one with the 'Applet' tag. This has the following sections:

  1. code=<name of the class which extends the Applet class>
  2. width=<width of applet window, in pixels>
  3. height=<height of applet window>
  4. archive="jms.jar and fmq-client.jar <-- Relative path of the FioranoMQ  JMS jar and runtime library jar files"

Out of these the mandatory attributes are code, width and height.
A complete multi-user chat applet developed using JMS APIs can be found in the samples\applets directory of the FioranoMQ distribution. This directory contains the files MultiChat.java and Login.java.

Applet Support

Question 3: Can I use JMS from within Web based applets?

The Fiorano runtime library can be used within web-based applets on popular browsers, namely, Netscape Communicator (4.0 and above) and Internet Explorer
(4.0 and above). This allows developers to take advantage of the location independent communication APIs implemented in JMS.

Question 4: I am building an applet to communicate with FioranoMQ's messaging server. Does the applet need to make fmq-rtl.jar available? Does the applet need all the classes?

You would need to bundle fmq-rtl.jar and fmq-common.jar with your applets.

Question 5: When I resize a page in Netscape, the entire page gets reloaded and if there is an applet on the page the Applet's stop and start methods are called, respectively. Does this action break the JMS connection?

Resizing the Applet does not break the connection. While coding your Applet, ensure that the connection is not created every time start() is called and the connection does not get deleted when stop() is called.

Question 6: I ran the sample applet using AppletViewer and it worked properly, but when I run it in Internet Explorer I get an error. Could it occur due to inability to find the localhost?

Internet Explorer's SecurityManager does not allow socket connections to the local machine. You can try connecting the Applet to MQServer running on different machine.

Question 7: When I run the applet using AppletViewer, I get a SecurityException. Do I need to change any environment settings?

It is possible that Fiorano library and its dependencies have not been assigned permission to make a socket connection with FioranoMQ. Check the security policy of your webserver.

The following policy, grants permission,for any application to use the applet:
grant { permission java.security.AllPermission "", ""; };

Other Applet Issues

Question 8: What causes the exception :IllegalAccesserror:could not create TopicConnectionFactory?

The illegal Access Error is a java.lang error, thrown when an application attempts to access or modify a field, or to call a method that it does not have access to. Typically, this error is captured by the compiler. This error can occur only at run time if the definition of a class has incompatibly changed. This is not a FioranoMQ Error. For example, this error can occur while trying to create a TopicConnection-Factory, which is an Administered Object (such Administered objects can only be created/destroyed by the Administrator). For this, you need to use the Administration APIs (for details, refer to the Administering FioranoMQ Server Using APIs section.

Question 9: What causes the exception :"could not calculate least loaded server"

This issue is due to mismatch of client side libraries with FioranoMQ. Hence you need to use the latest libraries.

Question 10: Why does the MQ applet not work in Internet Explorer 5.0?

Internet Explorer 5.0 has issues while using JNDI (specifically the call - "new InitialContext (env)" which fails with a security Exception due to a bug in JNDI). The solution is to directly use Fiorano's JNDI context factory i.e. the code in Applet which was originally as follows:
Hashtable env =...InitialContext ic = new InitialContext (env);
needs to be changed to :
Hashtable env =...Context ic = (new fiorano.jms.runtime.naming.FioranoInitialContextFac-tory ()). getInitialContext(env);
An alternative approach is to use the latest JRE 1.3 plug in technology that results in IE using the Sun's VM, rather than the embedded one.

Question 11: Does downloading the applet from Netscape Browser require SSL certification?

SSL is not necessary for downloading from Netscape Communicator.

Question 12: Is the only way to package the zip file with our applet jar, is to unzip them into the same folder that we use to build our applet jar file? What about applet signing?

You do not have to unzip the archives. You can use multiple archives in the archive tag of html file. If you are using jre 1.3 plug in, you can use an HTML converter toolkit that generates an html that works well with all the browsers.
To sign jar files and modify security permission, please refer to the following links:
http://java.sun.com/j2se/1.3/docs/tooldocs/win32/jarsigner.html http://java.sun.com/j2se/1.3/docs/guide/security/permissions.html

Question 13: I tried to run a sample applet code on JRun web server on a particular machine, using IE5.0 as browser, publishing some text from the publisher.java sample (in %FMQ_DIR%/fmq/samples/pubsub/pubsub/Publisher.java) window. But, the applet does not receive any message, although they have same Topic names?

Although, both the samples are using same Topic name to send and receive information, the message formats are different. You may need to modify the publisher application to publish MapMessages with appropriate message properties for the MultiChat application to receive them.

Adaptavist ThemeBuilder EngineAtlassian Confluence