Wildfly-config file

All

Intro

During the process of discovery a client requires access to its configuration, the classpath is scanned for and the first thing is to look at Wildfly file or can be set with a system-configuration as well – which will load several properties.

In  EJB replaces jboss-ejb-client.properties file which is configured for EJB standalone client applications.

Wildfly-config file

There are several usages for wildfly-config but authentication is one of them:

<?xml version="1.0" encoding="UTF-8"?>

<configuration>
    <authentication-client xmlns="urn:elytron:1.0">
       ...
    </authentication-client>
</configuration>

More information can find here

Replacing: jboss-ejb-client.properties::

Using this can be helpful to set several properties, invocation-timeouts and can be used to add connections, which is used to specify an EJB client connection but also can add an interceptors element – I will post about interceptors on this year.

Demo

Basically, getting the EJB-security you will see the following architecture after the compilation:

[ejb-security]$ tree
 .
 ├── src
 │   └── main
 │       ├── java
 │       │   └── org
 │       │       └── jboss
 │       │           └── as
 │       │               └── quickstarts
 │       │                   └── ejb_security
 │       │                       ├── RemoteClient.java <----- the client
 │       │                       ├── SecuredEJB.java <--- EJB
 │       │                       └── SecuredEJBRemote.java <--- EJB
 │       └── resources
 │           └── wildfly-config.xml <---- wildlfly-config.xml
 └── target <--- yes, mvn clean install has passed here
     ├── checkstyle-cachefile
     ├── checkstyle-checker.xml
     ├── checkstyle-header.txt
     ├── checkstyle-result.xml
     ├── classes
     │   ├── META-INF
     │   │   └── build.metadata
     │   ├── org
     │   │   └── jboss
     │   │       └── as
     │   │           └── quickstarts
     │   │               └── ejb_security
     │   │                   ├── RemoteClient.class
     │   │                   ├── SecuredEJB.class
     │   │                   └── SecuredEJBRemote.class
     │   └── wildfly-config.xml <---- on the target you will see the wildfly-config.xml file
 28 directories, 28 files

Running the example should be trivial (after adding the quickstartUser in the application-users.properties), and the result should be:

$ mvn exec:exec -X
  Successfully called secured bean, caller principal quickstartUser
  Principal has admin permission: true #if quickstartUser=guest, admin
OR
  Principal has admin permission: false #if quickstartUser=guest

Issues

1. EJBCLIENT000409: No more destinations are available

Exception in thread "main" org.jboss.ejb.client.RequestSendFailedException: EJBCLIENT000409: No more destinations are available
     at org.jboss.ejb.client.EJBClientInvocationContext.getResult(EJBClientInvocationContext.java:592) <--- EJB client invocation context, which will call the EJB invocation
     ....
     at org.jboss.as.quickstarts.ejb_security.RemoteClient.main(RemoteClient.java:45)
     Suppressed: org.jboss.ejb.client.RequestSendFailedException
         at org.jboss.ejb.protocol.remote.RemoteEJBReceiver$1.handleFailed(RemoteEJBReceiver.java:101)
         at org.jboss.ejb.protocol.remote.RemoteEJBReceiver$1.handleFailed(RemoteEJBReceiver.java:74)
         at org.xnio.IoFuture$HandlingNotifier.notify(IoFuture.java:215)
         at org.xnio.AbstractIoFuture$NotifierRunnable.run(AbstractIoFuture.java:720)
         at org.jboss.remoting3.EndpointImpl$TrackingExecutor.lambda$execute$0(EndpointImpl.java:949)
         at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
         at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1985)
         at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1487)
         at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1378)
         at java.lang.Thread.run(Thread.java:748)
     Caused by: javax.security.sasl.SaslException: Authentication failed: all available authentication mechanisms failed:
    DIGEST-MD5: javax.security.sasl.SaslException: DIGEST-MD5: Server rejected authentication   <---- Rejected Authentication

2. Port is wrong:

Start jboss with port offset: $ ./bin/standalone.sh -Djboss.socket.binding.port-offset=100:

00:19:50,385 INFO [org.wildfly.extension.undertow] (MSC service thread 1-7) WFLYUT0006: Undertow HTTP listener default listening on 127.0.0.1:8180 <-- 8180

Using a wildfly-config.xml:

<jboss-ejb-client xmlns="urn:jboss:wildfly-client-ejb:3.0"> 
  <connections>     
   <connection uri="remote+http://localhost:8080"/> 
  </connections> 
</jboss-ejb-client>

So then since the ports are different, a NoSuchEJBException appears:

Exception in thread "main" javax.ejb.NoSuchEJBException: EJBCLIENT000079: Unable to discover destination for request for EJB StatelessEJBLocator for "/ejb-security/SecuredEJB", view is interface org.jboss.as.quickstarts.ejb_security.SecuredEJBRemote, affinity is None
     at org.jboss.ejb.client.EJBClientInvocationContext.getResult(EJBClientInvocationContext.java:592)
     at org.jboss.ejb.client.EJBClientInvocationContext.getResult(EJBClientInvocationContext.java:528)
     ....
     at com.sun.proxy.$Proxy0.getSecurityInfo(Unknown Source)
     at org.jboss.as.quickstarts.ejb_security.RemoteClient.main(RemoteClient.java:45)
     Suppressed: java.net.ConnectException: Connection refused <----- expected 
         at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)

Fixing 8180 on the wildfly-config.xml, so then we have:

 Nov 07, 2019 12:23:40 AM org.jboss.remoting3.EndpointImpl 
 INFO: JBoss Remoting version 5.0.8.Final-redhat-1
 Successfully called secured bean, caller principal quickstartUser

REFs

inline.
I wrote this post listening to Harry Styles (British singer), and it one of the best songs of the album Fine Line (2019), his second album. Yes, same HS that was in One Direction. That’s the only thing I’ll ever do.

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