A routine of client access WebLogic

xiaoxiao2021-03-06  46

Deploy a Stateless EJB on WebLogic, then create a Java Application to access this STATELESS EJB.

Very simple, first set a few parameters of INITIALCONTEXT, then create an initialContext, query the EJB JNDI. JNDI can see from WebLogic's console administrator page: Click on the Servers / MyServer, you can see there is a connection view jndi tree at the bottom of the page. You can see the structure of the entire JNDI. It is WebLogic. A convenient design.

The process of truly connecting WebLogic EJB is relatively simple, a few lines of code. Properties' settings should be placed in the configuration file, for simple, write directly to the code.

Properties Prop = New Properties ();

Prop.SetPropertyContext.Initial_context_factory, "WebLogic.jndi.wlinitialContextFactory";

Prop.SetProperty (Context.Provider_URL, "T3: //127.0.0.1: 7001");

Try {

InitialContext Context = New InitialContext (PROP);

Object ref = context.lookup ("ejbstateless1");

EjbStateless1Home Home = (EJBSTATELESS1HOME) PortableRemoteObject.narrow (Ref, EjbStateless1Home.Class);

EJBSTATELESS1 EJB = home.create ();

System.out.println (ejb.sayhello ());

}

After a period of learning, it is found that WebLogic configuration management is still simpler than Tomcat and JBoss, basically the graphical settings, wrong, know where it is wrong.

转载请注明原文地址:https://www.9cbs.com/read-91218.html

New Post(0)