Are there any configuration changes required in the latest Wildfly 27 to be able to invoke Remote EJB over http.
In Wildfly 26.x, we could use any of the following url:
- http-remotting://<host>:port
- remote+http://<host>:port
- http://<host>:port/wildfly-services
Using the following test application:
public static void main(String[] args)
{
TestRemoteEJB testRemoteEJB = new TestRemoteEJB();
testRemoteEJB.callRemoteEjb();
testRemoteEJB.callRemoteEjbOverHttp();
}
public void callRemoteEjb()
{
try {
String url = "remote+http://%s:%d";
PropertyManager propMgr = (PropertyManager)getInitialContext(url, host, port, user, pass).lookup(remoteEjb);
System.out.println(propMgr);
propMgr.getProperties();
}
catch (NamingException e) {
e.printStackTrace();
}
}
public void callRemoteEjbOverHttp()
{
try {
String url = "http://%s:%d/wildfly-services";
PropertyManager propMgr = (PropertyManager)getInitialContext(url, host, port, user, pass).lookup(remoteEjb);
System.out.println(propMgr);
propMgr.getProperties();
}
catch (NamingException e) {
e.printStackTrace();
}
}
public static Context getInitialContext(String url, String host, Integer port, String username, String password) throws NamingException
{
Properties props = new Properties();
props.put(Context.INITIAL_CONTEXT_FACTORY, "org.wildfly.naming.client.WildFlyInitialContextFactory");
props.put(Context.PROVIDER_URL, String.format(url, host, port));
if (username != null && password != null) {
props.put(Context.SECURITY_PRINCIPAL, username);
props.put(Context.SECURITY_CREDENTIALS, password);
}
return new InitialContext(props);
}
In Wildfly 26, we are able to get the lookup the Remote EJB and invoke one of the methods:
Proxy for remote EJB StatelessEJBLocator for "efp/efprocess/PropertyManager", view is interface com.banctec.caseware.server.propertymanager.PropertyManagerRemote, affinity is URI<remote+
http://localhost:8080>
Proxy for remote EJB StatelessEJBLocator for "efp/efprocess/PropertyManager", view is interface com.banctec.caseware.server.propertymanager.PropertyManagerRemote, affinity is URI<
http://localhost:8080/wildfly-services>
In Wildfly 27, the same code fails using http when invoking the EJB method. I can see that the affinity is different:
Proxy for remote EJB StatelessEJBLocator for "efp/efprocess/PropertyManager", view is interface com.banctec.caseware.server.propertymanager.PropertyManagerRemote, affinity is URI<remote+
http://localhost:8080>
Proxy for remote EJB StatelessEJBLocator for "efp/efprocess/PropertyManager", view is interface com.banctec.caseware.server.propertymanager.PropertyManagerRemote,
affinity is LocalException in thread "main" jakarta.ejb.NoSuchEJBException: EJBCLIENT000024: No EJB receiver available for handling destination "local:-"
at org.jboss.ejb.client.EJBClientInvocationContext.getResult(EJBClientInvocationContext.java:620)
at org.jboss.ejb.client.EJBClientInvocationContext.getResult(EJBClientInvocationContext.java:551)
at org.jboss.ejb.protocol.remote.RemotingEJBClientInterceptor.handleInvocationResult(RemotingEJBClientInterceptor.java:57)
at org.jboss.ejb.client.EJBClientInvocationContext.getResult(EJBClientInvocationContext.java:622)
at org.jboss.ejb.client.EJBClientInvocationContext.getResult(EJBClientInvocationContext.java:551)
at org.jboss.ejb.client.TransactionPostDiscoveryInterceptor.handleInvocationResult(TransactionPostDiscoveryInterceptor.java:148)
at org.jboss.ejb.client.EJBClientInvocationContext.getResult(EJBClientInvocationContext.java:622)
at org.jboss.ejb.client.EJBClientInvocationContext.getResult(EJBClientInvocationContext.java:551)
at org.jboss.ejb.client.DiscoveryEJBClientInterceptor.handleInvocationResult(DiscoveryEJBClientInterceptor.java:130)
at org.jboss.ejb.client.EJBClientInvocationContext.getResult(EJBClientInvocationContext.java:622)
at org.jboss.ejb.client.EJBClientInvocationContext.getResult(EJBClientInvocationContext.java:551)
at org.jboss.ejb.client.NamingEJBClientInterceptor.handleInvocationResult(NamingEJBClientInterceptor.java:87)
at org.jboss.ejb.client.EJBClientInvocationContext.getResult(EJBClientInvocationContext.java:622)
at org.jboss.ejb.client.EJBClientInvocationContext.getResult(EJBClientInvocationContext.java:551)
at org.jboss.ejb.client.AuthenticationContextEJBClientInterceptor.call(AuthenticationContextEJBClientInterceptor.java:59)
at org.jboss.ejb.client.AuthenticationContextEJBClientInterceptor.handleInvocationResult(AuthenticationContextEJBClientInterceptor.java:52)
at org.jboss.ejb.client.EJBClientInvocationContext.getResult(EJBClientInvocationContext.java:622)
at org.jboss.ejb.client.EJBClientInvocationContext.getResult(EJBClientInvocationContext.java:551)
at org.jboss.ejb.client.TransactionInterceptor.handleInvocationResult(TransactionInterceptor.java:212)
at org.jboss.ejb.client.EJBClientInvocationContext.getResult(EJBClientInvocationContext.java:622)
at org.jboss.ejb.client.EJBClientInvocationContext.getResult(EJBClientInvocationContext.java:551)
at org.jboss.ejb.client.EJBClientInvocationContext.awaitResponse(EJBClientInvocationContext.java:1003)
at org.jboss.ejb.client.EJBInvocationHandler.invoke(EJBInvocationHandler.java:182)
at org.jboss.ejb.client.EJBInvocationHandler.invoke(EJBInvocationHandler.java:116)
at com.sun.proxy.$Proxy2.getProperties(Unknown Source)
Could anybody shade sone lights on why this is no longer working?
We will most likely use a LoadBalancer in front of our Wildfly servers, so we might need to use the http to connect to the server.
Many Thanks,
Alban