Ejabberd tsung test limits to 1005 online users - ejabberd

I need test max online users supported by my ejabberd. I use tsung, but i faced issue, inly 1005 online users from 1 client computer.
I have run tsung -l tsung-logs -f chat-4k.xml start
chat-4k.xml file
<?xml version="1.0"?>
<!DOCTYPE tsung SYSTEM "/usr/local/share/tsung/tsung-1.0.dtd">
<tsung loglevel="info" version="1.0" dumptraffic="false">
<clients>
<client host="localhost" maxusers="200000"/>
</clients>
<servers>
<server host="jabberserver" port="5222" type="tcp"/>
</servers>
<load>
<arrivalphase phase="1" duration="14400" unit="minute">
<users arrivalrate="10" unit="second"></users>
</arrivalphase>
</load>
<options>
<option type="ts_jabber" name="global_number" value="100"></option>
<option type="ts_jabber" name="userid_max" value="100000"></option>
<option type="ts_jabber" name="domain" value="tst.pinkmess.xyz"></option>
<option name="file_server" id='userdb' value="/tmp/test/userlist4.csv"/>
<!-- <option type="ts_jabber" name="username" value="user"></option>
<option type="ts_jabber" name="passwd" value="pass"></option> -->
</options>
<sessions>
<session bidi="true" probability="100" name="xmpp" type="ts_jabber">
<setdynvars sourcetype="file" fileid="userdb" delimiter=";" order="iter">
<var name="username" />
<var name="password" />
</setdynvars>
<transaction name="initial_stream">
<request subst="true">
<jabber type="connect" ack="local">
<xmpp_authenticate username="%%_username%%" passwd="%%_password%%"/>
</jabber>
</request>
</transaction>
<thinktime value="2"/>
<transaction name="authenticate">
<request> <jabber type="auth_sasl" ack="local"/> </request>
<request> <jabber type="connect" ack="local"/> </request>
<request> <jabber type="auth_sasl_bind" ack="local"/> </request>
<request> <jabber type="auth_sasl_session" ack="local"/> </request>
</transaction>
<thinktime value="1"/>
<request subst="true">
<jabber type="presence:initial" ack="no_ack"/>
</request>
<for from="1" to="100" incr="1" var="j">
<request subst="true">
<jabber type="chat" ack="no_ack" size="500" destination="online"/>
</request>
<thinktime value="5"/>
</for>
<request subst="true">
<jabber type="presence:final" ack="no_ack"/>
</request>
</session>
</sessions>
</tsung>
Only 1005 online users from one client computer. I have run test on another client VM it also gives 1005 online users. From 2 client VM a generates only 2010 online users.
Tung log has error
stats: dump at 1571563726
stats: users 1006 1009
stats: {cpu,"tsung_controller#nb-ivanov"} 1 46.80573663624511 0.0 57.691309987029825 32.14969234558683 41.291614334365065 10
stats: {load,"tsung_controller#nb-ivanov"} 1 1.609375 0.0 2.01171875 1.609375 1.812890625 10
stats: {freemem,"tsung_controller#nb-ivanov"} 1 2144.73046875 0.0 2294.95703125 2135.203125 2183.86171875 10
stats: session 28 77.93410714285714 9.264334616224604 108.182 68.178 0 0
stats: users_count 91 1034
stats: finish_users_count 28 28
stats: request 445 47.600876404494386 21.31547418108496 140.158 0.03 48.23643842794759 4580
stats: connect 65 42.36301538461539 4.39096055547796 85.906 33.592 42.63856170212765 940
stats: page 2225 9.801699775280849 36.93811095526636 245.732 0.009 19.20556423001114 11669
stats: tr_authenticate 96 166.69216666666654 31.625195579983718 246.623 108.536 155.72595489548956 909
stats: request_noack 2064 11884
stats: tr_initial_stream 88 85.87685227272726 11.180942522617931 141.442 66.816 88.95005212765957 940
stats: size_rcv 1408228 8612676
stats: async_unknown_data_rcv 2135 12866
stats: error_connect_emfile 96 96
stats: size_sent 1206452 7012283
stats: connected 65 1005
stats: error_abort_max_conn_retries 23 23
How to increase connected online users form one client VM?

See step 1 in this tutorial, maybe your clients are limited, and you need to set ulimit or other system setting? https://www.ejabberd.im/benchmark/index.html

Related

Ejabberd Registering Users with Tsung

I've installed tsung and running the same on Centos.
No using is registered when trying to run jabber_register.xml tsung -f file.xml start. Where exactly is the problem?
I see Acceted connection in Ejabberd logs, but no user is registered.
<?xml version="1.0"?>
<!DOCTYPE tsung SYSTEM "/usr/local/share/tsung/tsung-1.0.dtd">
<tsung loglevel="notice" version="1.0">
<clients>
<client host="localhost" use_controller_vm="true"></client>
</clients>
<!-- Server side setup -->
<servers>
<server host="127.0.0.1" port="5222" type="tcp"></server>
</servers>
<load>
<arrivalphase phase="1" duration="1" unit="minute">
<users maxnumber="100" interarrival="1" unit="second"></users>
</arrivalphase>
<user session="xmpp-connection" start_time="1" unit="second"></user>
</load>
<!-- JABBER parameters -->
<!-- to synchronise users, use a global acknoledgement -->
<options>
<option type="ts_jabber" name="global_number" value="100"></option>
<option type="ts_jabber" name="userid_max" value="200000"></option>
<option type="ts_jabber" name="domain" value="example.com"></option>
<option type="ts_jabber" name="username" value="tsung_user"></option>
<option type="ts_jabber" name="passwd" value="tsung_pwd"></option>
</options>
<sessions>
<session probability="100" name="jabber-example" type="ts_jabber">
<request> <jabber type="connect" ack="local"></jabber> </request>
<thinktime value="2"></thinktime>
<transaction name="authenticate">
<request> <jabber type="auth_sasl" ack="local"></jabber> </request>
<request> <jabber type="connect" ack="local"></jabber> </request>
<request> <jabber type="auth_sasl_bind" ack="local" ></jabber></request>
<request> <jabber type="auth_sasl_session" ack="local" ></jabber></request>
<request> <jabber type="presence:initial" ack="no_ack"/> </request>
</transaction>
<thinktime value="30"></thinktime>
<transaction name="online">
<request> <jabber type="chat" ack="no_ack" size="4000" destination="online"/></request>
</transaction>
<transaction name="close">
<request> <jabber type="close" ack="local"></jabber> </request>
</transaction>
</session>
</sessions>
</tsung>
Following is tsung.log
# stats: dump at 1483683039
stats: users 1 4
stats: {freemem,"tsung_controller#centos"} 1 1456.01953125 0.0 1456.5390625 1455.87109375 1456.1263020833333 3
stats: {load,"tsung_controller#centos"} 1 0.01171875 0.0 0.01953125 0.01171875 0.014322916666666666 3
stats: {cpu,"tsung_controller#centos"} 1 2.3069207622868606 0.0 2.4975024975024978 1.1518372449915872 1.9846496536436529 3
stats: session 7 2042.459681919643 0.5394376539819091 2049.197998046875 2041.028076171875 2041.9925944010417 27
stats: users_count 8 35
stats: finish_users_count 7 34
stats: request 40 1.45291748046875 0.21618170915409465 4.088134765625 0.952880859375 1.3667364921278626 131
stats: connect 40 0.643145751953125 0.29426544797099324 2.958984375 0.256103515625 0.6991087935353053 131
stats: page 8 1.55010986328125 0.21899365581343963 4.088134765625 0.952880859375 1.4904966001157407 27
stats: tr_authenticate 8 38.19097900390625 0.8066643325794721 39.382080078125 37.134033203125 37.7615966796875 26
stats: size_rcv 11846 50623
stats: size_sent 4760 20286
stats: connected 0 0
stats: error_connection_closed 24 102
stats: error_abort_max_send_retries 8 34
tsung_controller.log
=INFO REPORT==== 6-Jan-2017::06:11:01 ===
ts_client:(5:<0.218.0>) connection close while sending message!
=INFO REPORT==== 6-Jan-2017::06:11:01 ===
ts_client:(5:<0.218.0>) Server must have closed connection upon us, waiting 10 msec
=INFO REPORT==== 6-Jan-2017::06:11:01 ===
ts_client:(5:<0.218.0>) connection close while sending message!
=INFO REPORT==== 6-Jan-2017::06:11:01 ===
ts_client:(5:<0.218.0>) Server must have closed connection upon us, waiting 10 msec
=INFO REPORT==== 6-Jan-2017::06:11:01 ===
ts_client:(5:<0.218.0>) connection close while sending message!
=INFO REPORT==== 6-Jan-2017::06:11:01 ===
ts_client:(5:<0.218.0>) Server must have closed connection upon us, waiting 10 msec
=INFO REPORT==== 6-Jan-2017::06:11:01 ===
ts_client:(3:<0.218.0>) EXIT Error: Unable to send data, max_retries reached; reason: {error,
closed}
=INFO REPORT==== 6-Jan-2017::06:11:01 ===
ts_client:(5:<0.218.0>) Pending transactions: [{tr_authenticate,
{1483,683061,
201737}}], compute transaction time
You are running chat script and also I think the username & password used in the script is not registered one.
Please refer the below script for registration and then run the chat script.
<tsung loglevel="notice" dumptraffic="false" version="1.0">
<clients>
<client host="localhost" use_controller_vm="true"> </client>
</clients>
<servers>
<server host="127.0.0.1" port="5222" type="tcp"/>
</servers>
<!-- register 200000 users in less than 15 minutes -->
<load>
<arrivalphase phase="1" duration="15" unit="minute">
<users maxnumber="200000" interarrival="0.0025" unit="second"/>
</arrivalphase>
</load>
<options>
<option type="ts_jabber" name="global_number" value="5"/>
<option type="ts_jabber" name="userid_max" value="200000"/>
<option type="ts_jabber" name="domain" value="erlang-projects.org"/>
<option type="ts_jabber" name="username" value="tsung"/>
<option type="ts_jabber" name="passwd" value="tsung"/>
</options>
<sessions>
<session probability="100" name="jabber-example" type="ts_jabber">
<request>
<jabber type="connect" ack="local"/>
</request>
<request>
<match do="abort" when="match">error</match>
<jabber type="register" ack="local" id="new"/>
</request>
<request>
<jabber type="close" ack="local"/>
</request>
</session>
</sessions>
</tsung>
Note: You mentioned like "No using is registered when trying to run jabber_register.xml tsung -f file.xml start".
I suggest you to run for less users first and then move on to more users. Because client machine memory need to be increased on running heavy load.
Please let me know if you have any doubts.

BizTalk JSON Deserialize

I have to connect a REST service via BizTalk. The service returns a JSON response as shown below. When the BizTalk response port tries to decode the JSON message I get an error about JSON to XML conversion. This error happen because of embedded HTML tags in the JSON Message.
Error:
(There was a failure executing the response(receive) pipeline: "Avansas.Paritus.Suggest.T.JSONReceive, Avansas.Paritus.Suggest.T, Version=1.0.0.0, Culture=neutral, PublicKeyToken=7b2984270a9ffd13" Source: "JSON decoder" Send Port: "Avansas.Ibrahim.Suggest.T.SendPort" URI: "api1.test.com/services/rest"; Reason: Unexpected character encountered while parsing value: <. Path '', line 0, position 0. )
For Example:
As below response message has a label element in JSON. Label element has a text with html tag (City) that's why when BizTalk tries to convert JSON to XML I get an error. I think BizTalk tries to convert JSON as figure 2 but I want to convert it as figure 3.
How can I solve this issue?
Is there any way to passthru transmit on orchestration without any schema?
Figure1
{
"suggestion": [
{
"id": "[31 31 31 30 30 39]",
"label": "Global <b>City</b> 2. Etap Global <b>Cıty</b> ",
"value": "Global <b>City</b> 2. Etap Villaları "
},
{
"id": "[39 33 36 32 35 36]",
"label": "<b>City</b> Aqua Villas Sk. Kuşadası Aydın",
"value": "<b>City</b> Aqua Villas Sk. Kuşadası Aydın"
}
]
}
Figure 2:
<root>
<suggestion>
<id>[31 31 31 30 30 39]</id>
<label>Global
<b>City</b> 2. Etap Global
<b>Cıty</b>
</label>
<value>Global
<b>City</b> 2. Etap Villaları
</value>
</suggestion>
<suggestion>
<id>[39 33 36 32 35 36]</id>
<label>
<b>City</b> Aqua Villas Sk. Kuşadası Aydın
</label>
<value>
<b>City</b> Aqua Villas Sk. Kuşadası Aydın
</value>
</suggestion>
</root>
Figure 3:
<root>
<suggestion>
<id>[31 31 31 30 30 39]</id>
<label>Global
<b>City</b> 2. Etap Global
<b>Cıty</b>
</label>
<value>Global
<>City</b> 2. Etap Villaları
</value>
</suggestion>
<suggestion>
<id>[39 33 36 32 35 36]</id>
<label>
<b>City</b> Aqua Villas Sk. Kuşadası Aydın
</label>
<value>
<b>City</b> Aqua Villas Sk. Kuşadası Aydın
</value>
</suggestion>
</root>
Also my service can be return xml response and when i try to handle xml response a get an below error.
XML Error
There was a failure executing the response(receive) pipeline: "Microsoft.BizTalk.DefaultPipelines.XMLReceive, Microsoft.BizTalk.DefaultPipelines, Version=3.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" Source: "XML disassembler" Send Port: "aaa.bbb.Suggest.T.SendPort" URI: "https://api1.test.com/services/rest" Reason: Finding the document specification by message type "html" failed. Verify the schema deployed properly
And response xml as shown below
<?xml version="1.0" encoding="UTF-8"?>
<suggestions>
<suggestion>
<id>111011</id>
<label>Global <b>Cıty</b> 1. Etap Vıllaları Sokak</label>
<value>Global Cıty 1. Etap Vıllaları Sokak</value>
</suggestion>
<suggestion>
<id>111009</id>
<label>Global <b>Cıty</b> 2. Etap Vıllaları Sokak</label>
<value>Global Cıty 2. Etap Vıllaları Sokak</value>
</suggestion>
</suggestions>
Using this schema:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="unqualified" targetNamespace="http://BizTalk_Server_Project1.JSONSchema1" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="Root">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="unbounded" name="suggestion">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="id" type="xs:string" />
<xs:element minOccurs="0" name="label" type="xs:string" />
<xs:element minOccurs="0" name="value" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
And this pipeline:
Produces this message:
<ns0:Root xmlns:ns0="http://BizTalk_Server_Project1.JSONSchema1">
<suggestion>
<id>[31 31 31 30 30 39]</id>
<label>Global <b>City</b> 2. Etap Global <b>Cıty</b> </label>
<value>Global <b>City</b> 2. Etap Villaları </value>
</suggestion>
<suggestion>
<id>[39 33 36 32 35 36]</id>
<label><b>City</b> Aqua Villas Sk. Kuşadası Aydın</label>
<value><b>City</b> Aqua Villas Sk. Kuşadası Aydın</value>
</suggestion>
</ns0:Root>

Mule JMS Max Redelivery Exceeded Sonic and WMQ

I have a mule flow which reads messages from a sonic topic and publish to a Websphere MQ Topic.
The flow is synchronous and transacted.
I have set maxRedelivery="10" in the inboud endpoint. but it keeps on trying to redeliver.
Here is the exception I get:
ERROR 2014-03-03 15:13:08,763 [JMS Session Delivery Thread - $TMPAPPID$544239$$SESSION$0:-3441129419112818566] org.mule.exception.DefaultMessagingExceptionStrategy:
********************************************************************************
Message : "Message with id "ID:1419c04f:da190005:1448992ACB1" has been redelivered 1,511 times on endpoint "jms://topic:testtopic", which exceeds the maxRedelivery setting of 10 on the connector "sonicMQConnectorSub". Message payload is of type: TextMessage
Code : MULE_ERROR--2
--------------------------------------------------------------------------------
Exception stack is:
1. "Message with id "ID:1419c04f:da190005:1448992ACB1" has been redelivered 1,511 times on endpoint "jms://topic:testtopic", which exceeds the maxRedelivery setting of 10 on the connector "sonicMQConnectorSub". Message payload is of type: TextMessage (org.mule.transport.jms.redelivery.MessageRedeliveredException)
org.mule.transport.jms.redelivery.JmsXRedeliveryHandler:91 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/transport/jms/redelivery/MessageRedeliveredException.html)
--------------------------------------------------------------------------------
Root Exception stack trace:
org.mule.transport.jms.redelivery.MessageRedeliveredException: "Message with id "ID:1419c04f:da190005:1448992ACB1" has been redelivered 1,511 times on endpoint "jms://topic:testtopic", which exceeds the maxRedelivery setting of 10 on the connector "sonicMQConnectorSub". Message payload is of type: TextMessage
at org.mule.transport.jms.redelivery.JmsXRedeliveryHandler.handleRedelivery(JmsXRedeliveryHandler.java:91)
at org.mule.transport.jms.MultiConsumerJmsMessageReceiver$JmsWorker.preProcessMessage(MultiConsumerJmsMessageReceiver.java:426)
at org.mule.transport.AbstractReceiverWorker$1$1.process(AbstractReceiverWorker.java:120)
+ 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
********************************************************************************
Here is the flow I use.
<jms:connector name="sonicMQConnectorSub" specification="1.1" validateConnections="true" maxRedelivery="10" connectionFactory-ref="soniqMQConnectionFactorySub" doc:name="JMS" clientId="${topic.sub.clientId}" durable="true"/>
<spring:beans>
<spring:bean id="soniqMQConnectionFactoryBeanSub" name="soniqMQConnectionFactorySub" class="progress.message.jclient.ConnectionFactory">
<spring:property name="connectionURLs" value="${topic.sub.providerUrls}" />
<spring:property name="defaultUser" value="${topic.sub.username}" />
<spring:property name="defaultPassword" value="${topic.sub.password}" />
</spring:bean>
</spring:beans>
<jms:connector name="wsMQConnector" specification="1.1" username="${topic.pub.username}" password="${topic.pub.password}" validateConnections="true" connectionFactory-ref="wsMQConnectionFactory" doc:name="JMS" clientId="${topic.pub.clientId}"/>
<spring:beans>
<spring:bean id="wsMQConnectionFactory" class="com.ibm.mq.jms.MQTopicConnectionFactory">
<spring:property name="transportType" value="1"/>
<spring:property name="hostName" value="${topic.pub.host}"/>
<spring:property name="port" value="${topic.pub.port}"/>
<spring:property name="channel" value="${topic.pub.channel}"/>
<spring:property name="queueManager" value="${topic.pub.queueManager}"/>
</spring:bean>
</spring:beans>
<flow name="Flow1" doc:name="Flow1" processingStrategy="synchronous">
<jms:inbound-endpoint doc:name="JMS" connector-ref="sonicMQConnectorSub" topic="${topic.sub.name}" >
<jms:transaction action="ALWAYS_BEGIN" />
</jms:inbound-endpoint>
<message-properties-transformer doc:name="Message Properties">
<add-message-property key="SENTTIMESTAMP" value="#[server.dateTime]"/>
</message-properties-transformer>
<logger message="Payload: #[message.payload]" level="INFO" doc:name="Logger"/>
<jms:outbound-endpoint doc:name="JMS" connector-ref="wsMQConnector" topic="${topic.pub.name}">
<jms:transaction action="ALWAYS_JOIN" />
</jms:outbound-endpoint>
</flow>
This is expected behavior, the above exception is raised when the maximum redelivery count defined in maxRedelivery has been exceeded by your JMS provider. See the answer by David Dossot here: jms Mule max redelivery exceeded

Tsung using xmpp authentication

<?xml version="1.0"?>
<!DOCTYPE tsung SYSTEM "/usr/share/tsung/tsung-1.0.dtd">
<tsung loglevel="notice" version="1.0">
<clients>
<client host="localhost" use_controller_vm="true"></client>
</clients>
<servers>
<server host="localhost" port="5222" type="tcp"></server>
</servers>
<load>
<arrivalphase phase="1" duration="1" unit="minute">
<users maxnumber="100" interarrival="5" unit="second"></users>
</arrivalphase>
</load>
<options>
<option type="ts_jabber" name="global_number" value="100"></option>
<option type="ts_jabber" name="userid_max" value="100"></option>
<option type="ts_jabber" name="domain" value="localhost"></option>
<option type="ts_jabber" name="username" value="ram"></option>
<option type="ts_jabber" name="passwd" value="ram123"></option>
</options>
<sessions>
<session probability="100" name="jabber-example" type="ts_jabber">
<request> <jabber type="connect" ack="no_ack"></jabber> </request>
<thinktime value="2"></thinktime>
<transaction name="authenticate">
<request> <jabber type="auth_get" ack="global"></jabber></request>
<request> <jabber type="auth_set_plain" ack="local"></jabber></request>
</transaction>
<request>
<jabber type="presence:initial" ack="no_ack"></jabber></request>
<thinktime value="100"></thinktime>
<transaction name="close">
<request> <jabber type="close" ack="local"></jabber></request>
</transaction>
</session>
</sessions>
</tsung>
</tsung>
This is my tsung.xml file code after start tsung i got the log file in ejabberd.log:
I(<0.425.0>:ejabberd_listener:281) : (#Port<0.4419>) Accepted connection {{192,168,1,583},47237} -> {{192,168,1,583},5222}
=INFO REPORT==== 2014-01-09 18:51:41 ===
I(<0.425.0>:ejabberd_listener:281) : (#Port<0.4421>) Accepted connection {{192,168,1,583},42575} -> {{192,168,1,583},5222}
=INFO REPORT==== 2014-01-09 18:51:50 ===
I(<0.425.0>:ejabberd_listener:281) : (#Port<0.4423>) Accepted connection {{192,168,1,583},50031} -> {{192,168,1,583},5222}
=INFO REPORT==== 2014-01-09 18:52:01 ===
I(<0.425.0>:ejabberd_listener:281) : (#Port<0.4425>) Accepted connection {{192,168,1,583},51034} -> {{192,168,1,583},5222}
but i dinnot get my external authentication username in log file.
I met the same situation with you, you should change the following code in your tsung.xml.
change auth_get to auth_sasl
<transaction name="authenticate">
<request> <jabber type="auth_get" ack="global"></jabber></request>
<request> <jabber type="auth_set_plain" ack="local"></jabber></request>
</transaction>
my config file is as followed. I got help from
Tsung connected users are not shown
and http://tsung.erlang-projects.org/user_manual/conf-sessions.html
6.6.3.3. SASL Plain . Good luck for you!
<!DOCTYPE tsung SYSTEM "/usr/local/tsung/share/tsung/tsung-1.0.dtd">
<tsung loglevel="notice" version="1.0">
<clients>
<client host="localhost" use_controller_vm="true"></client>
</clients>
<!-- Server side setup -->
<servers>
<server host="192.168.133.111" port="5222" type="tcp"></server>
</servers>
<load>
<arrivalphase phase="1" duration="2" unit="minute">
<users interarrival="2" unit="second"></users>
</arrivalphase>
</load>
<options>
<option type="ts_jabber" name="global_number" value="100"></option>
<option type="ts_jabber" name="userid_max" value="100"></option>
<option type="ts_jabber" name="domain" value="192.168.133.111"></option>
<option type="ts_jabber" name="username" value="user"></option>
<option type="ts_jabber" name="passwd" value="pass"></option>
</options>
<sessions>
<session probability="100" name="jabber-example" type="ts_jabber">
<request> <jabber type="connect" ack="local"></jabber> </request>
<thinktime value="2"></thinktime>
<transaction name="authenticate">
<request> <jabber type="auth_sasl" ack="local"></jabber> </request>
<request> <jabber type="connect" ack="local"></jabber> </request>
<request> <jabber type="auth_sasl_bind" ack="local" ></jabber></request>
<request> <jabber type="auth_sasl_session" ack="local" ></jabber></request>
</transaction>
<thinktime value="30"></thinktime>
<transaction name="close">
<request> <jabber type="close" ack="local"></jabber> </request>
</transaction>
</session>
</sessions>
</tsung>

Authentication failure: JDBC Realm in JBoss EAP 6.1

I've set up a JDBC realm in JBoss to handle user authentication/authorisation in a web app. I'm not receiving any error messages but authorisation fails with both of the test users and I'm struggling to understand why.
The project has been the result of pulling together forum posts on JDBC Security Realms on both JBoss and Tomcat so its entirely possible I've missed something but I can't see the wood for the trees anymore.
Relevant sections from Standalone.xml (JBoss management console shows DB connection & pool is OK so I know the driver is installed correctly):
<datasource jndi-name="java:jboss/datasources/MySqlDS" pool-name="MySqlDS">
<connection-url>jdbc:mysql://localhost:3306/securitytest</connection-url>
<driver-class>com.mysql.jdbc.Driver</driver-class>
<driver>com.mysql</driver>
<transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation>
<pool>
<min-pool-size>10</min-pool-size>
<max-pool-size>100</max-pool-size>
<prefill>true</prefill>
</pool>
<security>
<user-name>jboss_as</user-name>
<password>test</password>
</security>
<statement>
<prepared-statement-cache-size>32</prepared-statement-cache-size>
<share-prepared-statements>true</share-prepared-statements>
</statement>
</datasource>
<drivers>
<driver name="h2" module="com.h2database.h2">
<xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
</driver>
<driver name="com.mysql" module="com.mysql">
<xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>
</driver>
</drivers>
....
<security-domain name="JDBCRealm" cache-type="default">
<authentication>
<login-module code="Database" flag="required">
<module-option name="dsJndiName" value="java:jboss/datasources/MysqlDS"/>
<module-option name="principalsQuery" value="select user_password from USERS where user_name=?"/>
<module-option name="rolesQuery" value="select role_name, 'Roles' from ROLES where user_name=?"/>
</login-module>
</authentication>
</security-domain>
MySQL test database (securitytest) contains two tables (users - three columns ID, user_name, password and roles - three columns: ID, user_name, role_name, group_name) and I have populated these with "user" and "admin" both with "password" as the password. Role_name and group_name are set to the name of the respective users. Entries are cleartext (currently)
web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="WebApp_ID" version="2.5">
<!-- Roles -->
<security-role>
<description>Administrators</description>
<role-name>admin</role-name>
</security-role>
<security-role>
<description>Management</description>
<role-name>mgmt</role-name>
</security-role>
<!-- Resource/role mapping -->
<security-constraint>
<display-name>Admin Pages</display-name>
<web-resource-collection>
<web-resource-name>Protected Admin Area</web-resource-name>
<description />
<url-pattern>/admin/*</url-pattern>
<http-method>GET</http-method>
<http-method>POST</http-method>
<http-method>HEAD</http-method>
<http-method>PUT</http-method>
<http-method>OPTIONS</http-method>
<http-method>TRACE</http-method>
<http-method>DELETE</http-method>
</web-resource-collection>
<auth-constraint>
<description>For administrators only</description>
<role-name>admin</role-name>
</auth-constraint>
<user-data-constraint>
<transport-guarantee>NONE</transport-guarantee>
</user-data-constraint>
</security-constraint>
<security-constraint>
<display-name>All Access</display-name>
<web-resource-collection>
<web-resource-name>Unprotected User Area</web-resource-name>
<description>Open access for all users</description>
<url-pattern>/users/*</url-pattern>
<http-method>GET</http-method>
<http-method>POST</http-method>
<http-method>HEAD</http-method>
<http-method>PUT</http-method>
<http-method>OPTIONS</http-method>
<http-method>TRACE</http-method>
<http-method>DELETE</http-method>
</web-resource-collection>
<user-data-constraint>
<transport-guarantee>NONE</transport-guarantee>
</user-data-constraint>
</security-constraint>
<!-- Login prompt -->
<login-config>
<auth-method>FORM</auth-method>
<realm-name>JDBCRealm</realm-name>
<form-login-config>
<form-login-page>/login.xhtml</form-login-page>
<form-error-page>/loginerror.xhtml</form-error-page>
</form-login-config>
</login-config>
</web-app>
jboss.xml (in WEB-INF directory):
<?xml version="1.0" encoding="UTF-8"?>
<jboss-web>
<security-domain>java:/jaas/JDBCRealm</security-domain>
</jboss-web>
Finally, login.xhtml:
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:p="http://primefaces.prime.com.tr/ui"
xmlns:h="http://java.sun.com/jsf/html">
<h:head>
<title>Login Form</title>
</h:head>
<h:body>
<p:panel header="Login From">
<form method="post" action="j_security_check">
Username: <input type="text" name="j_username" />
Password: <input type="password" name="j_password" />
<br />
<input type="submit" value="Login" />
<input type="reset" value="Reset" />
</form>
</p:panel>
</h:body>
</html>
If anyone has any ideas I'd be really grateful as I'm tearing my hair out. I'm sure I've done something stupid, I just can't see it.
Cheers!
This might be help you for configuring it in the right way.
http://middlewaremagic.com/jboss/?p=2187