Wildfly Server is supporting the Eclipse Microprofile Metric API since version 14.0.0 . Within the Imixs-Workflow Project we started since version 5.0.0 to support Microprofile 2.0.Continue reading “Wildfly 16.0.0 with Microprofile Metrics 2.0.0”
If you have long running transactions, in Wildfly it can happen that you run into a timeout durinng your processing EJB method. In this case you can change the default timeout from 5 minutes via the standalone.xml file:
<subsystem xmlns="urn:jboss:domain:transactions:4.0"> <core-environment> <process-id> <uuid/> </process-id> </core-environment> <recovery-environment socket-binding="txn-recovery-environment" status-socket-binding="txn-status-manager"/> <coordinator-environment default-timeout="1200"/> <object-store path="tx-object-store" relative-to="jboss.server.data.dir"/> </subsystem>
In this example I changed the coordinator-environment default-timeout to 20 minutes
In the last few days, I struggled to implement my first JCA adapter. My goal was a solution for a transactional access to external Systems like Hadoop or Lucene from my Java EE application. As I finally succeed, I try here to answer some my own questions: Continue reading “JCA and Wildfly 10”
This is a short tutorial how to setup a Keycloak server and configure a wildfly web application to use keycloak to authenticate users. Continue reading “Using Keycloak for Wildfly Applications”
Instead of deploying a JDBC driver with the wildfly auto-deploy feature, the driver can be alternatively installed as an module. This is also necessary to be used with XA-Datasources. So it is a recommended way to install the driver as a module. The following section shows how to a jdbc driver module is created. Continue reading “Wildfly – Install PostgreSQL JDBC Driver as a Module”
It takes me some time to figure out the right way to deploy an artifact with Jenkins. After a successful build, I wanted to deploy the generated EAR file into a custom directory of my server. After trying several plugins the Artifact Deployer Plugin seems to me the best solution.
With this plugin installed you can add a ‘Post-Build-Action’ to your project. The Artefact location can be specified using the wildcards “**/*.war” or “**/*.ear”. In case of a Maven Project it’s not necessary to add a Base Dir location like it was in earlier releases. The ‘Remote File Location’ is just your target directory. You have also an option to disable the deployment in case the build failed.
So that’s it. If you know other solutions (especially for Wilfly) let me know.
It take me some time to figure out how to debug the JPA / EclipseLink implementation running on Wildfly. My goal was to log the SQL statements generated by EclipseLink.
It’s not necessary to modify the persistance.xml file. Just add into the standalone.xml file the following additional logger categories:
<logger category="org.eclipse.persistence.sql"> <level name="DEBUG"/> </logger> <logger category="org.jboss.as.jpa"> <level name="DEBUG"/> </logger>
And change the log level from the console-handler from ‘INFO’ to ‘DEBUG’
<console-handler name="CONSOLE"> <level name="INFO"/> <formatter> <named-formatter name="COLOR-PATTERN"/> </formatter> </console-handler>
Restart wildfly which is now logging all JPA information.
In many web architectures it is common to access a Java EE Application through a reverse proxy server. A reverse proxy can be used for example as a dispatcher to redirect users to different servers or switch to a standby server in a failover scenario. Another typical use case is to run a dispatcher as the SSL Endpoint for a Java EE application. Squid for example is a common tool to provide such a functionality. If you are running Wildfly behind such a reverse proxy server for SSL Endpoints you need to take care about some configuration issues.
Enable HTTPS on WildFly
To access an application running on Wildfly through a reverse proxy per SSL it is necessary to enable also HTTPS connections in Wildfly. Per default the WildFly server is only allowing HTTP connections. To enable HTTPS you need first to create a certificate and add this into the standalone.xml. Here are the steps to go:
(1) Create a Certificate
(1.1) Self-signed Certificate:
Using the linux keytool you can easily create your own private certificate and store it into the / configuration/ directory in Wildfly:
cd /opt/wildfly/standalone/configuration/ keytool -genkey -alias local-wildfly-cert -keyalg RSA -sigalg MD5withRSA -keystore local-wildfly-cert.jks -storepass adminadmin -keypass adminadmin -validity 9999 -dname "CN=Server Administrator,O=MyOrg,OU=com,C=DE"
Replace the password and organisation name with appropriate values.
Only in case that you already have an existing CA-Certificate and you want to use it for wildfly directly you can create the keystore file for wildfly with the openssl command line tool:
openssl pkcs12 -export -in yourdomain.com.crt -inkey yourdomain.com.key -out yourdomain.com.p12 -name local-wildfly-cert -CAfile your_provider_bundle.crt -caname root -chain
You need to define a password for the generated cert file. The pk12 file can now be imported into the keystore with the following command
keytool -importkeystore -deststorepass <secret password> -destkeypass <secret password> -destkeystore yourdomain.com.jks -srckeystore yourdomain.com.p12 -srcstoretype PKCS12 -srcstorepass <secret password used in csr> -alias local-wildfly-cert
The password again is needed for the configuration in wildfly.
(2) Configure a security realm
After you have generated the .jks file you can now add a new SecurityRealm with the name “UndertowRealm” in the standalone.xml file. This security realm is used to established https connections for wildfly/undertow later. Add the following entry into the section “security-realms” of the standalone.xml file:
..... <security-realm name="UndertowRealm"> <server-identities> <ssl> <keystore path="local-wildfly-cert.jks" relative-to="jboss.server.config.dir" keystore-password="adminadmin" alias="local-wildfly-cert" key-password="adminadmin"/> </ssl> </server-identities> </security-realm> </security-realms>
The new realm is using the local SSL certificate created before.
Note: Take care about the location of your key files.
(3) Setup the HTTPS Listener
Finally you need to update the http and https-listeners for undertow in the standalone.xml. Edit the server section ‘default-server’ in the following way:
....... <server name="default-server"> <http-listener name="default" socket-binding="http" proxy-address-forwarding="true"/> <https-listener name="https" socket-binding="https" security-realm="UndertowRealm"/> .... .....
Note: Be careful about changing both listener settings – http and https! The default setting redirect-socket=https from the http-listener must be changed in proxy-address-forwarding=true.
The default port for https in wildfly/undertow is 8443. So you can test your https setup now with a direct https request:
Finally you need to do some configuration on the dispatcher side. This is because Wildfly is not aware of the proxy and so in cases when your application sends a HTTP redirect (302) an already established SSL connection will be lost. This redirect scenario is typical for JSF applications where a navigation rule can issue such a situation. To avoid the loss of SSL connections inside your WildFly application you need to add the HTTP header parameter into the HTTP listener of your dispatcher. Sending an X-Forwarded-Proto https header along with your proxy will do the trick:
For squid you can add the corresponding config option:
request_header_add X-Forwarded-Proto https
For WildFly 10 another option is to use the new added option “secure=true|false” for http-listener. This option tells wildfly that all requests that come in are “secure” even when they come over http. See also the discussion here.
To activate logging for a specific category (path/class) from a deployed application follow these steps:
- Open the Wildfly Admin Console
- Switch to “Configuration -> Subsystem :Logging”
- Change the Console Loglevel to ‘FINE’ (or higher in case you need finer log levels) – default is ‘INFO’
- Add a new Log Category (Tab: Log Categories) with the following settings:
- Category = package or class
- Level = FINE (or higher in case you need finer log levels)
- Use parent handler=true
If you need to debug the request headers send to Wildfly application server you can configure a Request-Dumper. There for change the standalone.xml file and add a filter-ref and filter configuration into the subsystem section of undertow. See the following example:
... <subsystem xmlns="urn:jboss:domain:undertow:2.0"> .... <server name="default-server"> ... <host name="default-host" alias="localhost"> ..... <filter-ref name="request-dumper"/> </host> </server> .... <filters> ..... <filter name="request-dumper" class-name="io.undertow.server.handlers.RequestDumpingHandler" module="io.undertow.core" /> </filters
This will print out all the request information send by a browser.