Access to an EJB from an EJB-CLient without using the runclient-script.
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Stefan_Marx
Posted On:   Tuesday, October 30, 2001 03:19 AM

Hi everybody,


Is it possible to access an deployed EJB without the use of the runclient-script from a Java-application.


I use JBoss3.0 and it is possible.


With Jdk2ee 1.3 my code failed while resolving the beans-name.


My Architecture is a distributed Server with one EJB-Server and 3 Web-App Server. I like to use Jrun for the Web-Server/Servlets and J2EE Reference for the EJbPart (mainly for development) but If I cant find a solution for accessing a EJB from an basic java application then I won't be able to access the EJB from my Servlets either.

Re: Access to an EJB from an EJB-CLient without using the runclient-script.

Posted By:   Bozidar_Dangubic  
Posted On:   Tuesday, October 30, 2001 05:15 AM

you can access EJBs from any java client. Here is a code snippet. Properties object used to create InitialContext is proprietary to your app server so you will need to get the information on that and change it in the code. this code access stateless session EJB running on orion app server.

Properties prop = new Properties() ;
prop.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY,
"com.evermind.server.rmi.RMIInitialContextFactory") ;
prop.put(javax.naming.Context.PROVIDER_URL,"ormi://localhost/app-name") ;
prop.put(javax.naming.Context.SECURITY_PRINCIPAL,"administrator") ;
prop.put(javax.naming.Context.SECURITY_CREDENTIALS,"123456789") ;
javax.naming.Context ctx = new javax.naming.InitialContext(prop) ;

// get the cache
Object ref = ctx.lookup("InquiryBean") ;
InquiryHome home = (InquiryHome) PortableRemoteObject.narrow(ref,InquiryHome.class) ;
InquiryRemote inq = home.create() ;
....
inq.executeBusinessMethod(....) ;
....
About | Sitemap | Contact