The form and characteristics of the EJB client program under WebLogic

Source: Internet
Author: User
Tags client
Web| Program | Clients can be jsp/servlet or application for WebLogic client programs. 1 Jsp/servlet with the EJB on the same application server, its typical code can be as follows: (no need to establish the T3 protocol under the connection, directly by the client)                     context Ctx=new InitialContext ();                  Object obj =ctx.lookup ("ejb/com/j2ee/ First/ejb/hellohome ");                Hellohome trh= (hellohome) portableremoteobject.narrow (obj,hellohome.class);            Hello tr=trh.create ();           out.println ( Tr.hello ());  Note: The jndi-name can be placed in Web.xml and string Jndiname=getservletconfig (). Getinitparameter ("Para-name") To get JNDI.2) for general application, it's not the same application server as the EJB, even on the same machine.   Note: (1) on the client's system variable to have: ... \weblogic81 Erver\lib\weblogic.jar; Otherwise it cannot be run.        (2) In the file configuration must have: remote class, Remote home class (generally does not contain bean class, that is, business classes) to ensure that the customer class running.         usually organize these files in the form of packages, and make sure that the correct configuration is pressed package, or else an error occurs.   Its typical code can be as follows:             String url= "t3:// localhost:7001 ";     Properties Prop=new properties ();     Prop.put ( Context.provider_url,url);            Prop.put ( Context.initial_context_factory, "Weblogic.jndi.WLInitialContextFactory");             prop.put (Context.security_principal, "name");          Prop.put (context.security_credentials, "code");     context ctx=new InitialContext (prop) ;   object obj=ctx.lookup ("Ejb/com/j2ee/first/ejb/hellohome");   hellohome trH= (HelloHome) Portableremoteobject.narrow (Obj,hellohome.class);   hello tr=trh.create ();   System.out. println (Tr.hello ());      Note: Context.security_principal and Context.security_ Credentials is optional and involves the right to operate on the EJB.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.