How to add custom filter of undertow by using jboss.cli - jboss

Server : WindFly 15, Undertow 8
I've created a custom filter "MyFilter" by following the article http://www.mastertheboss.com/jboss-web/jbosswebserver/configuring-undertow-filters-on-wildfly. But i didn't find the way to use jboss.cli to add it in the configuration.
I've tried /subsystem=undertow/configuration=filter/filter=myFilter/:add(module=com.xxx.myfilter,class-name=com.xxx.MyFilter), and got the following error:
ERROR [org.jboss.as.cli.CommandContext] Failed to get the list of the operationproperties: "WFLYCTL0030: No resource definition is registered for address [
("subsystem" => "undertow"),
("configuration" => "filter"),
("filter" => "myFilter")
So whether we can only add filter by manually editing the configuration file?

you can add using the cli with the following command:
/subsystem=undertow/configuration=filter/custom-filter
The original answer can be found here.
This is related to the custom filter creation explained on the Guide Configuring The Web Server ~ Undertow - Chapter 17.6
/subsystem=undertow/configuration=filter/response-header=new-response-header:add(header-name=new-response-header,header-value="My Value")
Tip
The main tip is to use the Tab so then the auto complete comes to you.

Related

Deploying custom Keycloak theme with Operator (v15.1.1 & v16.0.0)

I have a theme with a size >1MB (which precludes the configmap-solution provided as an answer to this question).
This theme has been been packaged according to the Server Development Guide - its folder structure is
META-INF/keycloak-themes.json
themes/[themeName]/login/login.ftl
themes/[themeName]/login/login-reset-password.ftl
themes/[themeName]/login/template.ftl
themes/[themeName]/login/template.html
themes/[themeName]/login/theme.properties
themes/[themeName]/login/messages/messages_de.properties
themes/[themeName]/login/messages/messages_en.properties
themes/[themeName]/login/resources/[...]
The contents of keycloak-themes.json are
{
"themes": [{
"name" : "[themeName]",
"types": [ "login" ]
}]
}
where [themeName] is my theme name.
Keycloak is running with 3 instances, its resource spec includes:
extensions:
- [URL-to-jar]
Deployment was successful according to the logs of each pod - each log contains a message containing
Deployed "[jar-name].jar" (runtime-name : "[jar-name].jar")
However, in the admin console, I cannot select the theme from the extension for the login-theme. Creating a new realm via crd with a preconfigured login-theme via spec-entry
loginTheme: [themeName]
also does not work - in the admin-console, the selected entry for the login-theme is empty.
I may be missing something basic, but it seems like this ought to work according to this answer if I am not mistaken.
As is so often the case, an uncaught typo was the source of the error.
The directory-structure must not be
META-INF/keycloak-themes.json
themes/[theme-name]/[theme-role]/theme.properties
[...]
But instead
META-INF/keycloak-themes.json
theme/[theme-name]/[theme-role]/theme.properties
[...]
Given a correct structure, keycloak-operator can successfully deploy and load custom-themes as jar-extensions.

Can not create jms-queue in wildfly using jboss-cli

I started wildfly 24 server with standalone-full.xml profile, when i run following command in jboss-cli to create jms-queue i get following error
[standalone#localhost:9990 /] jms-queue --profile=full add --queue-address=foo --entries=["java:/jms/queue/foo"]
WFLYCTL0175: Resource [
("subsystem" => "messaging-activemq"),
("server" => "default")
] does not exist; a resource at address [
("subsystem" => "messaging-activemq"),
("server" => "default"),
("jms-queue" => "foo")
] cannot be created until all ancestor resources have been added
What am i missing here? Any reference docs to create the jms server, queues?
Update:
I tried to create the server using web console first
And it filed with the required capabilities are not available, any documentation refernece that indicates what are the required capabilities i need to added prior configuring JMS
Yes don't use the profile parameter which is used in domain mode.
jms-queue add --queue-address=foo --entries=["java:/jms/queue/foo"]
works properly.
The issue is i was using wildfly "WildFly Preview EE 9.1 Distribution" the correct verirsion is "Jakarta EE 8 Full & Web Distribution"

JPAM Configuration for Apache Drill

I'm trying to configure PLAIN authentification based on JPAM 1.1 and am going crazy since it doesnt work after x times checking my syntax and settings. When I start drill with cluster-id and zk-connect only, it works, but with both options of PLAIN authentification it fails. Since I started with pam4j and tried JPAM later on, I kept JPAM for this post. In general I don't have any preferences. I just want to get it done. I'm running Drill on CentOS in embedded mode.
I've done anything required due to the official documentation:
I downloaded JPAM 1.1, uncompressed it and put libjpam.so into a specific folder (/opt/pamfile/)
I've edited drill-env.sh with:
export DRILLBIT_JAVA_OPTS="-Djava.library.path=/opt/pamfile/"
I edited drill-override.conf with:
drill.exec: {
cluster-id: "drillbits1",
zk.connect: "local",
impersonation: {
enabled: true,
max_chained_user_hops: 3
},
security: {
auth.mechanisms: ["PLAIN"],
},
security.user.auth: {
enabled: true,
packages += "org.apache.drill.exec.rpc.user.security",
impl: "pam",
pam_profiles: [ "sudo", "login" ]
}
}
It throws the subsequent error:
Error: Failure in starting embedded Drillbit: org.apache.drill.exec.exception.DrillbitStartupException: Problem in finding the native library of JPAM (Pluggable Authenticator Module API). Make sure to set Drillbit JVM option 'java.library.path' to point to the directory where the native JPAM exists.:no jpam in java.library.path (state=,code=0)
I've run that *.sh file by hand to make sure that the necessary path is exported since I don't know if Drill is expecting that. The path to libjpam should be know known. I've started Sqlline with sudo et cetera. No chance. Documentation doesn't help. I don't get it why it's so bad and imo incomplete. Sadly there is 0 explanation how to troubleshoot or configure basic user authentification in detail.
Or do I have to do something which is not told but expected? Are there any Prerequsites concerning PLAIN authentification which aren't mentioned by Apache Drill itself?
Try change:
export DRILLBIT_JAVA_OPTS="-Djava.library.path=/opt/pamfile/"
to:
export DRILL_JAVA_OPTS="$DRILL_JAVA_OPTS -Djava.library.path=/opt/pamfile/"
It works for me.

Using logstash for email alert

I installed logstash 5.5.2 in our windows server and I would like to send an email alert when I identify some sentences.
My output section is the following:
output {
tcp {
host => "host.com"
port => 1234
codec => "json_lines"
}
if "The message was Server with id " in [log_message] {
email {
to => "<myName#company.com>"
from => "<otherName#company.com>"
subject => "Issue appearance"
body => "The input is: %{incident}"
domain => "smtp.intra.company.com"
port => 25
#via => "smtp"
}
}
}
During my debug I got the following messages:
[2017-09-11T13:19:39,181][ERROR][logstash.plugins.registry] Problems loading a plugin with {:type=>"output", :name=>"email", :path=>"logstash/outputs/email", :error_message=>"NameError", :error_class=>NameError
[2017-09-11T13:19:39,186][DEBUG][logstash.plugins.registry] Problems loading the plugin with {:type=>"output", :name=>"email"}
[2017-09-11T13:19:39,195][ERROR][logstash.agent ] Cannot create pipeline {:reason=>"Couldn't find any output plugin named 'email'. Are you sure this is correct? Trying to load the email output plugin resulted in this error: Problems loading the requested plugin named email of type output.
Which I guess says that I don't have the email plugin installed.
Can someone suggest a way to fix this?
Using another solution is not an option, just in case that someone suggests it.
Thanks and regards,
Fotis
I tried to follow the instructions in the official documentation
But the option of creating an offline plugin pack didn't work.
So what I did, was to create a running logstash instance on my client, run the command to install the output-email plugin logstash-plugin install logstash-output-email and afterwards I copied this instance on my server(which had no internet access).

Setup MariaDB XA on WildFly through UI

Similar to How to setup MariaDB JNDI on Wildfly 10? but specifically done through the Web UI.
I can create the non-XA data source with no issues but I am having issues creating the XA version.
I did the deployment of the mariadb-client.jar using the WildFly deploy UI with no issues. I can verify that the non-XA datasource works well.
However, when I do the same approach with the XA driver, when testing the connection I get the following error on the logs (not visible on the error dialog
Caused by: javax.resource.ResourceException: IJ031101: XADataSourceClass is undefined
at org.jboss.jca.adapters.jdbc.xa.XAManagedConnectionFactory.getXADataSource(XAManagedConnectionFactory.java:621))
When I try to configure the driver configuration manually I just get Unknown Error and the datasource does not even get created
"failure-description" => {"WFLYCTL0062: Composite operation failed and was rolled back. Steps that failed:" => {"Operation step-1" => {
"WFLYCTL0412: Required services that are not installed:" => ["jboss.jdbc-driver.MariaDBXA"],
"WFLYCTL0180: Services with missing/unavailable dependencies" => [
"org.wildfly.data-source.PacXA is missing [jboss.jdbc-driver.MariaDBXA]",
"jboss.driver-demander.java:/PacXA is missing [jboss.jdbc-driver.MariaDBXA]"
]
The driver classes I am using are as noted in https://issues.jboss.org/browse/JBEAP-2405 where I put it in the screen that accepts them.
driver-class: org.mariadb.jdbc.Driver
xa-datasource-class: org.mariadb.jdbc.MariaDbDataSource (NOT org.mariadb.jdbc.MySQLDataSource)
Also when looking at the XML when selecting from JAR vs entering the configuration on screen, nothing gets populated on xa-datasource-class. I know I can edit the XML but like I said I wanted to do it through the administration console.
Refer https://issues.jboss.org/browse/JBEAP-2405 for sample configuration. Make sure you are providing correct driver name.