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


List of HornetQ management operations

In previous post I have written tutorial how to invoke management operation on HornetQ server via JMS queue. But what operations are available?

Managed resources:

First of all, to invoke operation, you have to specify managed resource name, which start from prefix defined in

If your resource has one of the prefix defined below, there is a big chance that it can be managed via management queue:

 List of management operations for Queue:

Managment operations are the methods that are defined in interface:

e.g. to move all messages to DLQ you should invoke


 List of management operations for HornetQServer:

Managment operations are the methods that are defined in interface:

 List of management operations for HornetQ cluster:

Managment operations are the methods that are defined in


Others management operations are also available, just check content of package

Pay special attention on parameters of the operation, as they must always match perfectly! If operations requires java.lang.String parameter and you dont’t provide it, operation will not be found.

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


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/

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 deploy arquillian EAR package to remote server with all required dependencies

If you want to test your enterprise package with arquillian, here is my way how to do it:

0. Prerequisites

  1. Maven multimodule project
  2. application server (I’ve used Weblogic 12c)

1. Add required maven dependencies to projects:


 2. Create base test class

Note that all required dependencies and test classes are included in the package, so  NoClassDefFoundException will not bother you anymore ;)

3. Add arquillian.xml descriptor to src/test/resources

  3. Write a test


How to find out which jar is used

To be sure that class is loaded from correct jar, paste following lines in your code: