Hello,

I'm trying to write an applet which accesses sessionbeans...
I first made some servlets to test all the beans I made and that works fine.
But i can't get it work with an applet...

Have done the following steps:
- i created an directory where all jar files are put
(JNDI,EJB,JONAS,JTA,JDBC,RMI,all beans)
- In the source code you see that I use Codebase tot determine the host
- in the html I set codebase="/classes" where all jar files are put:
<applet code="LoginApplet.class" codebase="/classes" width="400"
heigth="400"></applet>

First i started the rmiregistry en EJBserver
When i start the applet i don't get any errors it initialises the applet,
but it does not do any transaction...

Can someone tell me what is missing?

Thanks

Best Regards,

Jochen Vastmans

[EMAIL PROTECTED]


// CODE

import mansession.ManSession;
import mansession.ManSessionHome;
import shophistoryline.ShopHistoryLineHome;
import shophistoryline.ShopHistoryLine;

import java.applet.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.lang.*;
import java.net.*;

import java.rmi.RemoteException;
import javax.ejb.EJBObject;
import javax.ejb.SessionBean;
import javax.ejb.SessionContext;
import javax.ejb.SessionSynchronization;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Properties;
import java.util.Vector;
import javax.ejb.FinderException;
import javax.ejb.RemoveException;
import javax.ejb.CreateException;
import javax.transaction.UserTransaction;
import javax.transaction.HeuristicMixedException;
import javax.transaction.HeuristicRollbackException;
import javax.transaction.RollbackException;
import javax.transaction.SystemException;
import javax.transaction.NotSupportedException;
import javax.naming.Context;
import javax.naming.InitialContext;

public class LoginApplet extends Applet implements Runnable {

    Button submit,reset;
    TextField user,password;
    Font titleFont;

    InitialContext initialContext;
    UserTransaction utx;
    ManSession ms;
    ManSessionHome home;

    public synchronized void init() {

      submit = new Button("Submit");
      reset = new Button("Reset");
      user = new TextField(10);
      password = new TextField(10);

      // to  test I wrote a transaction to DB but nothing happens
      try{
       ShopHistoryLineHome shophome =
(ShopHistoryLineHome)initialContext.lookup("ShopHistoryLineBeanHome");
       utx.begin();
       ShopHistoryLine shop = shophome.create(1,2,3,0,15,3);
       utx.commit();
      }
      catch(Exception e){}


      add(user);
      add(password);
      add(submit);
      add(reset);

      titleFont = new Font("Courier", Font.BOLD, 14);
    }

    public void stop() {
     initialContext=null;
     utx=null;
     home=null;
     ms=null;
    }

    public void start() {
  connectToSessionBean();
    }

    public void run() {}

    public void connectToSessionBean() {

     try{
            Properties env = new Properties();

     env.put("java.naming.factory.initial",
              "com.sun.jndi.rmi.registry.RegistryContextFactory");
     env.put("java.naming.provider.url",
"rmi://"+getCodeBase().getHost()+":1098");

     // get JNDI initial context
     initialContext = new InitialContext(env);
     // Lookup UserTransaction Service
     utx = (UserTransaction)
initialContext.lookup("javax.transaction.UserTransaction");

     //Connecting to ManSessionHome thru JNDI
     home = null;
     home = (ManSessionHome) initialContext.lookup("ManSessionBeanHome");

     // Create Session Instance
     ms = null;
     ms = home.create();
 }
 catch(Exception e){
  System.out.println("Cannot create ManSessionBean: "+e);
 }
    }

    public void destroy() {
         initialContext=null;
     utx=null;
     home=null;
     ms=null;
    }

    public String getAppletInfo() {
      return "Title: Login \nAuthor: Jochen Vastmans  \nManagement.";
    }
}









----
To unsubscribe, send email to [EMAIL PROTECTED] and
include in the body of the message "unsubscribe jonas-users".
For general help, send email to [EMAIL PROTECTED] and
include in the body of the message "help".

Reply via email to