EJB pt-2

All

Comparing JBoss EAP for EJB in several versions

JBoss  EAP 4x/5x:

  1. For JBoss EAP  you will need dist/lib/jbossall-client-4.2.2.GA.jar

2. This initial context factory when trying to call a different JVM

public class EJBTester {

jndiProperties.put(Context.INITIAL_CONTEXT_FACTORY,”org.jnp.interfaces.NamingContextFactory”);
jndiProperties.put(Context.URL_PKG_PREFIXES, “org.jboss.ejb.client.naming”);
ctx = new InitialContext(jndiProperties);

3. JBoss EAP 4 /5  – the initial context is like:

public static Context getInitialContext( String host ) throws Exception {
if ( host == null ) host = “localhost”;
Properties properties = new Properties();
properties.put(Context.INITIAL_CONTEXT_FACTORY, “org.jnp.interfaces.NamingContextFactory”);
properties.put(Context.URL_PKG_PREFIXES, “org.jboss.naming:org.jnp.interfaces”);
properties.put(“jnp.socket.Factory”, “org.jnp.interfaces.TimedSocketFactory”);
properties.setProperty(“java.naming.provider.url”, “jnp://”+ host +”:1099″);
return new InitialContext(properties);
}
    4. The EJB lookup would be :

LibrarySessionBeanRemote remoteEJB = (LibrarySessionBeanRemote) getInitialContext(“localhost”).lookup(“LibrarySessionBean/remote”);

18:21:35,100 INFO  [JndiSessionRegistrarBase] Binding the following Entries in Global JNDI:

LibrarySessionBean/remote – EJB3.x Default Remote Business Interface
LibrarySessionBean/remote-com.tutorialspoint.stateless.LibrarySessionBeanRemote – EJB3.x Remote Business Interface

   5. Deployment

18:21:35,100 INFO  [JndiSessionRegistrarBase] Binding the following Entries in Global JNDI:

LibrarySessionBean/remote – EJB3.x Default Remote Business Interface
LibrarySessionBean/remote-com.tutorialspoint.stateless.LibrarySessionBeanRemote – EJB3.x Remote Business Interface

For JBoss EAP 6x

properties.put(Context.URL_PKG_PREFIXES, “org.jboss.naming:org.jnp.interfaces”);

For JBoss 7x

The process is described with more details on the post <EJB pt1>

  1. Add $JBOSS_HOME/modules/system/layers/base/javax/ejb/api/main/jboss-ejb-api_3.2_spec-1.0.1.Final-redhat-1.jar to the classpath.

2. For the Client, the initial context changed for:

props.put(Context.INITIAL_CONTEXT_FACTORY, “org.wildfly.naming.client.WildFlyInitialContextFactory”);
props.put(Context.PROVIDER_URL,”remote+http://localhost:8080″);

3. Compile with $JBOSS_HOME/bin/client/jboss-client.jar

4. Lookup – when the client app is in the same JVM as the EJB

LibrarySessionBeanRemote libraryBean =
(LibrarySessionBeanRemote)this.ctx.lookup(“java:global/EjbComponent/LibrarySessionBean!com.tutorialspoint.stateless.LibrarySessionBeanRemote”);

    AdderImplRemote remote = (AdderImplRemote) getInitialContext().lookup(“ejb:/EjbRemote/AdderImpl!AdderImplRemote”);

   org.wildfly.naming.client.WildFlyInitialContextFactory

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s