Hello Freind
i am expain all the process and i think it will help all those freind which are beginer for ejb that you will not get any problem that i you r beginer..you can deploy programme as below 1) write all java programme like Remote interface home interface Bean class in case entity primary key class etc
2)Make Deployment descriptor which is inside META-INF for this u can use
ant command which i have explain below
3)Make jar file & corresponding skeleton for this use command on command prompt
4)After that start Application server and upload skeleton
5) Now your application completed
6)For checking write client code and compile it If you try as i have explain then sure your application will success
Suppose you have deploye a countBean
first copy setEnv and paste in
C:\rajesh <p>all file of ejb in that add rajesh folder in classpath inside setEnv
First CountRemote will be as below <p>
import javax.ejb.*;
import java.rmi.*;
public interface CountRemote extends EJBObject
{public int abc() throws RemoteException;
}<p>
After that write CountHome which is Home interface
import javax.ejb.*;
import java.rmi.*;
public interface CountHome extends EJBHome
{CountRemote create(int p) throws RemoteException,CreateException;
}
After that Bean
import javax.ejb.*;
public class CountBean implements SessionBean
{private SessionContext ctx;
private int p;
public int abc()
{System.out.println("abc(int p)");
return ++p;
}
public void ejbCreate(int p) throws CreateException
{System.out.println("ejbCreate()");
this.p=p;
}
public void ejbRemove()
{System.out.println("ejbRemove()");}
public void ejbActivate()
{System.out.println("ejbActivate()");}
public void ejbPassivate()
{System.out.println("ejbPassivate()");}
public void setSessionContext(SessionContext ctx)
{}
}
After that Client code
import javax.ejb.*;
import javax.naming.*;
import java.rmi.*;
import java.util.*;
public class Count
{public static void main(String args[])
{
try
{Properties p=new Properties();p.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
p.put(Context.PROVIDER_URL,"t3://localhost:7001");
Context ctx=new InitialContext(p);
CountHome CH=(CountHome) ctx.lookup("xyz");
CountRemote A[]=new CountRemote[3];
int abcp=0;
System.out.println("Initializing Bean ........");
for(int i=0;i<3;i++)
{A[i]=CH.create(abcp);
abcp=A[i].abc();
System.out.println(abcp);
Thread.sleep(500);
}
// Calling abc() on each EJB Object
System.out.println("Calling abc() on bean ");
for(int i=0;i<3;i++)
{abcp=A[i].abc();
System.out.println(abcp);
Thread.sleep(500);
}
// Removing object
for(int i=0;i<3;i++)
{
A[i].remove();
}
}catch(Exception e){}
}
}
<p> compile all as <p>
C:\rajesh>javac countRemote.java
C:\rajesh>javac countHome.java
C:\rajesh>javac countBean.java
C:\rajesh>javac count.java
After compile all file
go command prompt suppose all java file in rajesh folder<p>
write ant command as below :--
c\rajesh >java weblogic.ant.taskdefs.ejb.DDInit it create META_INF inside you will get xml equivalent deployment descriptor
c:\rajesh>jar cvf cc.jar *.*
which make jar file as compress file
c:\rajesh>java weblogic.ejbc cc.jar ccc.jar <p> you will get a jar file which you have to upload. and finally
c:\rajesh>java Count
which give result Finnaly i think this example help lot of freind
Regards
Rajesh Pandey
Mob :- +919811903737
email :-
rajesh-pandey@hotmail.com