1 Reply Latest reply on Dec 28, 2001 12:34 AM by sk4567

    Root class for applets in codebase of html??

    sk4567

      Hi all,
      I have a Applet class being called in a html page.
      I have compiled my applet in C:/Iab/Intab.having package intab.My classpath is set to c:/Iab.
      In the intab directory also I have my EJB classes etc..
      I then make a jar file called iab.jar and deply it etc..
      Now,while calling my applet in my html , i have given the iab.jar in my "archive=iab.jar" which i also have in the root directory of tomcat(same as where i have my html file).
      when i run my html page...i ge a file not found exception for one of my other classes(EventLogger class) which i have imported in my applet class(in my iab.jar and same package as my applet class).
      I also get a name mismatch for my applet class which i presume it is becausee it lies in a package.
      my html code is as below:






      My applet code is as below:,
      package intab;

      /*


      */




      import java.applet.*;
      import java.awt.*;
      import java.awt.event.*;
      import java.io.PrintStream;
      import javax.rmi.PortableRemoteObject;
      import java.util.*;
      import javax.ejb.*;
      import javax.naming.InitialContext;
      import javax.sql.DataSource;

      import intab.EventLogger;
      import intab.TestAppletHome;
      import intab.TestApplet;


      public class AppletEjbCaller extends Applet
      {
      Panel buttonPanel = new Panel();
      Button callEjbButton = new Button("Get serversss message");
      Panel labelPanel = new Panel();
      Label ejbMessageLabel = new Label();
      EventLogger elogger= new EventLogger();

      // Construct the Applet
      //
      public AppletEjbCaller () {}

      // Initialize the applet
      //
      public void init()
      {
      try
      {
      this.setSize(new Dimension(400, 65));

      callEjbButton.addActionListener(new java.awt.event.ActionListener()
      {
      public void actionPerformed(java.awt.event.ActionEvent e)
      {
      callEjbButton_actionPerformed(e);
      }
      });
      ejbMessageLabel.setText("no call performed yet.");
      this.add(buttonPanel, BorderLayout.CENTER);
      buttonPanel.add(callEjbButton, null);
      this.add(labelPanel, BorderLayout.SOUTH);
      labelPanel.add(ejbMessageLabel, null);
      elogger.reportToFile("Got contedt in applet3");
      }
      catch(Exception e)
      {
      e.printStackTrace();
      }
      }

      /**Get Applet information*/
      public String getAppletInfo()
      {
      return "JBoss EJB client Applet demo";
      }

      void callEjbButton_actionPerformed(java.awt.event.ActionEvent e)
      {

      try

      {
      Properties jndiProps = new Properties() ;
      String myServer = this.getCodeBase().getHost ();
      elogger.reportToFile("Got contedt in applet3");

      jndiProps.setProperty("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory" ) ;
      jndiProps.setProperty("java.naming.provider.url", myServer ) ;
      jndiProps.setProperty("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces" ) ;
      InitialContext context = new InitialContext(jndiProps);
      Object objRef = context.lookup("TestAppletBean/TestAppletBean");


      TestAppletHome home = (TestAppletHome)PortableRemoteObject.narrow(objRef,TestAppletHome.class) ;

      TestApplet remote = home.create() ;
      ejbMessageLabel.setText( remote.getMessage() ) ;
      }
      catch ( SecurityException se )
      {
      se.printStackTrace ();
      ejbMessageLabel.setText (se.toString ());
      }
      catch( Exception ex )
      {
      System.err.println( "APPLET" );
      ex.printStackTrace();
      }

      }
      }

      My query is that where should i place my aplet and other classes for it to be accessed.One way would be to place all of the classes in the root dir itself.
      But that would be very messy.I wish to maintain a package heirarchy .But eventually have acess problems for my applet.
      Also a way would be mention the Codebase in the html file..Iiw ant to know what to right inthe codebase.Kindly advise how to tackle the problem.Im using 2.4.3

      Thanks,
      Saurabh