Configure nginx as a keycloak proxy

I haven’t found a propitiate configuration of nginx for Keycloak configuration, that’s why I am going to publish mine here. If you have a problem with keycloak “invalid_url”, please go ahead and try that configuration ;)

I assume that you run nginx on same server as keycloak (localhost) and listens on port 8443. Content of file is located in my case in /etc/nginx/default.d/keycloak.conf.


How to invoke broadcast EJB at all JBoss cluster members

According to a title, if have to invoke all ejb beans of a given type at once on all cluster members, below is a quiet simple way how to do it.

1. Import into your project required modules/dependencies

Maven dependencies

Runtime JBoss modules depencies

Defined  jboss-deployment-strucutre.xml file:

Dependencies might be alternatively defined in MANIFEST.MF as entry:

2.  Implement service that will invoke method on all cluster members

 Important notes on implementation:

  • JmsAdapter is an @Stateless EJB
  • Broadcast method is invoked synchronously on all cluster members, but there is an async equivalent : callAsynchMethodOnCluster
  • Implementation of broadcast requires private JBoss modules which are not supported by Red Hat


Managing HornetQ queues via JMS API

HornetQ offers a lot of resource management operations, but unfortunately it is not well covered by documentation ;(
In following tutorial I will try to show you how to manage HornetQ queue via JMS API.

1. Add hornetQ dependencies:

  • As library is available at JBoss AS, I personally prefer to add dependency at scope provided and include module dependency in MANIFEST.MF file
  • In case of debugging, consider adding also artifacts hornetq-server, hornetq-jms-server
2. Add class that will handle invocation of management operations:

3. Invoke adapter from previous point:

  • pay attention at queue address, because jms queues  should starts with prefix jms.queue.*
  • in case of operations parameters, add them as varargs

In the next post I have explained how to find out which management operations are available.


Mod_cluster on RHEL7

Yesterday I had to configure mod_cluster on Red Hat Enterprise Linux 7. As I’ve found out, it is not as simple, as it sounds. After hours of struggling with different approaches, I came up with following solution:

1. Download Apache with modcluster

wget downloads.jboss.org/mod_cluster//1.3.1.Final/linux-x86_64/mod_cluster-1.3.1.Final-linux2-x64-ssl.tar.gz

2. Untar archive and move to appropriate directory

tar -xvf mod_cluster-1.3.1.Final-linux2-x64-ssl.tar.gz mv opt/jboss /opt

3. Check if httpd deamon works correctly:

/opt/jboss/httpd/sbin/httpd -k start

if daemon works correctly, on http://localhost:6666 should be displayed famous “It works!”.

4. Make a system service from httpd

nano /etc/init.d/apache2.sh

and paste following content:

5. Add execute permissions for newly created script:

chmod +x /etc/init.d/apache2

6. Check if service is working correctly by invoking:

service apache2 start

7. If you would like to start service automatically at system startup, invoke:

chkconfig --add apache2




How to add custom logging handler in JBoss 7 via CLI

Yesterday I was facing problem of adding in JBoss  6.2 EAP custom-handler in loggging submodule via command line interface, all because of not documented syntax of creation of properties part.

All I wanted to add was:

And finally the solution is:


How to run JRockit Mission Controll with JBoss 7

Due to [AS7-1859] issue it is not possible to connect to JBoss7 via java agent. But fortunately there is other way.

1. Start JRMC:

Start JRMC as you usually do, but this time add following parameters:

where {JBOSS_HOME} points to JBoss 7 home directory, and {JROCKIT_HOME} points to JRockit JDK instalation folder. Also double check if libraries are present, as they vary from JB version (those above are valid for JBoss 7.1.1)

2. Create new JRockit connector:

In JRMC go to “connectors -> add connection”, and use following properties:

  • Host JDK version: Custom JMX service URL 
  • JMX service URL: service:jmx:remoting-jmx://{JBOSS_SERVER_HOST}:{JBOSS_MANAGEMENT_NATIVE_PORT} 



How to inject mock into CDI context with Arquillian behind the scenes


My goal was to mock database, so every component in CDI based application would use mock instead of original implementation. I also had to have possibility to control my mock in JUnit test runtime. I struggle with this problem almost whole day and finally found satisfying solution :)

Not all steps are necessary, but I strongly encourage You to follow all of them.

1. Create stereotype for your mocked objects

2. Register newly created stereotype

3. Create mock factory

4. Write unit test


How to access remotely EJB on JBoss 7.1

Here is a code snippet that I use successfully:


How to create mysql xa-datasource on JBoss 7.1

To create datasource with distributed transactions support, you should follow those steps:

1. Create mysql connector module on server

Add following structure in folder ’{JBOSS_HOME}\modules:

  • /com
    • /mysql
      • /main
        • module.xml
        • mysql-connector-java-5.1.25-bin.jar

Where module.xml contains:

 2. Create xa-datasource

Add datasource definitions to server config file, where by default is used ‘standalone.xml’ from ‘{JBOSS_HOME}\standalone\configuration’