EJB Context

All

Intro

Reviewing some EJBs I started to play with some attributes of the Context.

//this returns java.naming.factory.initial:
System.out.println(Context.INITIAL_CONTEXT_FACTORY.toString());
//this returns java.naming.provider.url:
System.out.println(Context.PROVIDER_URL.toString());

 

EJB Port

The default http port is 8080, given in .

So if you use an offset <port-offset=”${jboss.socket.binding.port-offset:100}”> change Context.PROVIDER_URL,”remote+http://localhost:8180″);  the otherwise, you will get a connection refused:

javax.naming.CommunicationException: WFNAM00018: Failed to connect to remote host [Root exception is java.net.ConnectException: Connection refused]
at (…)

org.wildfly.naming.client.WildFlyRootContext.listBindings(WildFlyRootContext.java:300)
at javax.naming.InitialContext.listBindings(InitialContext.java:472)
at StandaloneJNDI.main(StandaloneJNDI.java:27)
Caused by: java.net.ConnectException: Connection refused

EJB context

Listing

GettingProperties

Unbinding

context.unbiding will return:

21:26:16,717 INFO [org.wildfly.naming] (default task-1) WildFly Naming version 1.0.11.Final-redhat-00001
21:26:16,746 WARN [org.wildfly.naming] (default task-2) WFNAM00036: Unexpected internal error: java.lang.UnsupportedOperationException:  : Naming context is read-only
at org.jboss.as.naming.WritableServiceBasedNamingStore.requireOwner(WritableServiceBasedNamingStore.java:160)
at org.jboss.as.naming.WritableServiceBasedNamingStore.unbind(WritableServiceBasedNamingStore.java:131)
at org.jboss.as.naming.NamingContext.unbind(NamingContext.java:318)

The code is on Github

 

Tag distributable/

All

Intro

HTTP Session Replication, during a session in case a node fails a way to avoid a client to close it is through replication to the other nodes. This is explained on the tutorial Distributable and that’s pretty much how mod_cluster makes its way.

JBoss EAP

In JBoss, this can be modified/tuned with the usage of the jboss-web.xml that contains several attributes. Although very very outdated, this reference can be used to get some idea of the attributes.

One example of what can be used for is to set the context-root of the project:

   <module>
        <web>
            <web-uri>web-client.war</web-uri>
            <context-root>bank</context-root>
        </web>
    </module>

Demo

[standalone@embedded /] /subsystem=distributable-web/infinispan-session-management=default:read-resource

 

Listing all names in JNDI in EJB

All

Intro

Based on here and here created a program that lists all Bindings (using context.Bindings) and JDNI names from the context.list:

Code

System.out.println(“Listing all names”);
NamingEnumeration namingenumeration = context.listBindings(“”);
while (namingenumeration.hasMore()) {
Binding binding = (Binding)namingenumeration.next();
System.out.println(binding.getName() + ” XXX ” + binding.getObject()
);
}

The core part is the NameClassPair

Result on Client

INFO: JBoss Remoting version 5.0.16.Final-redhat-00001
EjbRemote XXX org.wildfly.naming.client.store.RelativeFederatingContext@32eebfca
javax.naming.Context: true:EjbRemote

org.wildfly.naming.client.store.RelativeFederatingContext@7dc222ae

This is the binding name for JBoss EAP 7.1: org.wildfly.naming.client.WildFlyInitialContextFactory

javax.naming.Context: true:EjbSum

This is the EjbSum from the EJB pt1 – post.

Result on Server side

03:01:46,984 INFO [org.wildfly.naming] (default task-1) WildFly Naming version 1.0.11.Final-redhat-00001