Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

IS EJB CALL THROUGH SIMPLE JAVA CLASS ?  RSS feed

 
charmy jain
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi ,


i used a staterless session bean and in that bean include a 2 methods..
1) is get all records from database
2) update that all records to database
now , i want to call that both method from simple javaclass means that class is include a public static void method() ...

i decided to create a simple java class for execute a bean method because
i want to execute that method daliy eventing time so i put that java class into linux server where cronjob... facilty is available and it is excute that java class and update those records....

my question is :
1) is it possible to put a java class int cronJobs into linux server and also call a ejb methods..
2)how call a stateless session bean methods from simple javaclass....... ? is it possible?
3) whoe is really become a ejb clint.... like servlets, jsp............

pls, reply me...

thanks,
 
Rajesh Pandey Rajesh Pandey
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Freind <p>
First thing i have some confusion that you r saying that you are interact through database but it is not possible that you interact through database through session bean.This task possible if you call a entity bean in session,Second thing that you have ask client of ejb can be a class,jsp,servlet,applet and you want to know how ejb called through class so i am giving a example.Here RajHome is home interface RajRemote is remote Interface method name is pandey which return a String.I think that this eample can help your<p>
import java.rmi.*;
import javax.ejb.*;
import javax.naming.*;
import java.util.*;
public class Rajesh
{public static void main(String args[])
{try
{
Properties ptr=new Properties();
ptr.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
ptr.put(Context.PROVIDER_URL,"t3://localhost:7001");
Context ct=new InitialContext(ptr);
RajHome rh=(RajHome)ct.lookup("pandey");
RajRemote rr=rh.create();
String snp=rr.pandey();
System.out.print("Result"+snp);
rr.remove();

}catch(Exception e)
{System.out.println("Error : " +e);}

}

}
<p>
Best Regards<p>
Rajesh Pandey <p>
email :--rajesh-pandey@hotmail.com<p>
mobile :--+919811903737<p>
india ,Delhi
 
charmy jain
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi rajesh,

thnaks for reply me


i got soluction..
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!