How to invoke getConnection method missing from JConsole? - jmx

I would like to monitor the following Tomcat resource using JConsole:
<Resource name="jdbc/DSamdb" auth="Container" type="javax.sql.DataSource" description="My DB"
factory="my.package.CustomDataSourceFactory" initialSize="10" maxWaitMillis="10000"
maxTotal="80" maxIdle="20" minIdle="10" validationQuery="select 1" username="userz"
password="passwordz" driverClassName="com.mysql.cj.jdbc.Driver"
url="jdbc:mysql://localhost:3306/mydb?useUnicode=true&characterEncoding=utf8&serverTimezone=UTC"
/>
Here, my.package.CustomDataSourceFactory extends org.apache.tomcat.dbcp.dbcp2.BasicDataSourceFactory.
This is what I see in JConsole:
Notice that the only getConnection operation available is BasicDataSource#getConnection(String,String), which org.apache.tomcat.dbcp.dbcp2.BasicDataSource does not support. The one I would like to invoke is BasicDataSource#getConnection(), but it is not shown.
Now I try adding the following to my data source:
jmxEnabled="true" jmxName="org.apache.commons.dbcp2:name=basicDataSource"
This is what I see:
I appreciate that I can separate the data source, but now all but two operations are missing.
Can anyone instruct me on how to configure my data source such that I can invoke the getConnection() operation via JConsole?

Related

Custom configuration not getting reflected in applicationcontext.xml

I am using custom configuration for my RabbitMQ connectivity. I'm connecting to multiple hosts.
<context:property-placeholder location="classpath:/test_setting.properties" ignore-unresolvable="true"/>
...
<rabbit:connection-factory id="testConnectionFactory"
addresses="${test.addresses}"
username="${test.username}"
password="${test.password}"
virtual-host="${test.virtualhost}"
connection-factory="rhb" />
<bean id="rhb" class="com.rabbitmq.client.ConnectionFactory">
<property name="requestedHeartbeat" value="${test.connection.heartbeat}" />
</bean>
My property file looks like: test_setting.properties
test.queue=testQueue
test.virtualhost=/global_api
test.addresses=host1:5672,
host2:5672
test.username=guest
test.password=guest
test.connection.heartbeat=60
test.consumer.concurrency=1
When i trigger my main class properties not getting replaced inside applicationcontext.xml in Spring. Thereby I am getting connection refused exception.
Please note if I hard code the connection details everything works fine.
ignore-unresolvable="true"
It looks like the file is not being found - change that to false to see the error.
Also, turning on DEBUG logging for org.springframework will provide a great deal of information about property resolution.
test.addresses=host1:5672,
host2:5672
Properties have to be on one line (you can terminate a line with \) for continuation.
test.addresses=host1:5672, \
host2:5672

badarg when trying to read a csv file in erlang, with tsung

I am using tsung to load test my websocket server. I am new to tsung and to erlang.
I have a list of users and keys exported to a .csv file. To get it running i reduced the csv file to:
1;2
with no empty line at the end of the file.
This is a snippet of my tsung config (otherwise working fine):
<options>
<option name="file_server" id="users" value="PATH_TO_MY_CSV/users.csv"/>
</options>
[...]
<setdynvars sourcetype="erlang" callback="loadusers:user">
<var name="connection_url" />
</setdynvars>
[...]
<request subst="true">
<websocket type="connect" path="/?%%_connection_url%%"/>
</request>
Here's my loadusers.erl, which makes use of a ts_file_server tsung module:
-module(loadusers).
-export([user/1]).
user({Pid,DynVar})->
{ok,Line} = ts_file_server:get_next_line(),
[Username, Passwd] = string:tokens(Line,";"),
"username=" ++ Username ++"&password=" ++ Passwd.
Here's the erlang error stack:
** State machine <0.90.0> terminating
** Last message in was {timeout,#Ref<0.0.0.414>,end_thinktime}
** When State == think
** Data == {state_rcv,none,
{{0,0,0,0},0},
undefined,0,10000,"192.168.59.103",443,ts_tcp,
{proto_opts,negociate,"/http-bind/","/chat","binary",10,
600000,infinity,32768,32768,undefined,undefined,[]},
true,1,undefined,true,undefined,
{1431,872144,388666},
6,6,false,undefined,0,[],<<>>,
{websocket_session,undefined,undefined},
0,2,524288,524288,
[{tsung_userid,2}],
ts_websocket,[],undefined,none}
** Reason for termination =
** {{badarg,[{dict,fetch,
[default,
{dict,1,16,16,8,80,48,
{[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]},
{{[],[],[],
[[users|{file,{<<"1;2">>},1,-1}]],
[],[],[],[],[],[],[],[],[],[],[],[]}}}],
[{file,"dict.erl"},{line,130}]},
{ts_file_server,handle_call,3,
[{file,"src/tsung_controller/ts_file_server.erl"},
{line,159}]},
{gen_server,try_handle_call,4,
[{file,"gen_server.erl"},{line,607}]},
{gen_server,handle_msg,5,[{file,"gen_server.erl"},{line,639}]},
{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,237}]}]},
{gen_server,call,[{global,ts_file_server},{get_next_line,default}]}}
I know dynvars can be directly pulled from a tsung config, but I need to do it in the script since later I will need to dynamically manipulate the data. IMPORTANT: reading the same csv file works fine, so it seems like the script is the problem.
Can someone explain to me what erlang is complaining about here?
The error message is saying that dict:fetch(default, SomeDict) was called and threw a badarg exception. Typically this would happen when the key (default in your case) doesn't exist.
The problem is that in the Tsung config you set id="users", which sets the file id to users. But ts_file_server:get_next_line/0 expects the file id to be default.
Either remove id="users" from the config or change the Erlang part to use ts_file_server:get_next_line/1, passing in the file id you used in the config file.

Set the maxParameterCount attribute on the Connector JBoss EAP6

I have a main page with many elements included to another page but with different parameters using jsf 2.2 and it works with seam & jboss 5, but with jboss EAP6 (without seam) it gives me those errors :
java.lang.IllegalStateException: JBWEB002004: More than the maximum number of request parameters (GET plus POST) for a single request (512) were detected. Any parameters beyond this limit have been ignored. To change this limit, set the maxParameterCount attribute on the Connector.
org.apache.tomcat.util.http.Parameters.addParameter(Parameters.java:184)
org.apache.tomcat.util.http.Parameters.processParameters(Parameters.java:360)
org.apache.tomcat.util.http.Parameters.processParameters(Parameters.java:213)
org.apache.catalina.connector.Request.parseParameters(Request.java:2858)
org.apache.catalina.connector.Request.getParameter(Request.java:1279)
org.apache.catalina.connector.RequestFacade.getParameter(RequestFacade.java:349)
com.sun.faces.context.RequestParameterMap.containsKey(RequestParameterMap.java:99)
java.util.Collections$UnmodifiableMap.containsKey(Collections.java:1337)
org.jboss.weld.jsf.WeldPhaseListener.getConversationId(WeldPhaseListener.java:171)
org.jboss.weld.jsf.WeldPhaseListener.activateConversations(WeldPhaseListener.java:99)
org.jboss.weld.jsf.WeldPhaseListener.beforePhase(WeldPhaseListener.java:85)
com.sun.faces.lifecycle.Phase.handleBeforePhase(Phase.java:228)
com.sun.faces.lifecycle.Phase.doPhase(Phase.java:99)
com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:116)
com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
Any idea to solve these?
I searched and I have found this :
<system-properties>
<property name="org.apache.tomcat.util.http.Parameters.MAX_COUNT" value="5000"/>
</system-properties>
I found that I have to add that to standalone.xml but when I tried it doesn't start.

Custom Error Handler in Wso2 Mediation

In my In sequence mediatior, I need to process some logic on the input values and based on that i need to decide whether to call the webservice or return a fault. I have defined the sequence as following
<sequence xmlns="http://ws.apache.org/ns/synapse" name="m1">
<class name="com.myclass">
</class>
<makefault version="soap11">
<code xmlns:soap11Env="http://schemas.xmlsoap.org/soap/envelope/" value="soap11Env:Client"/>
<reason value="ERROR_MESSAGE"/>
<role>Acc</role>
<detail>Test Details</detail>
</makefault>
<log/>
</sequence>
The problem is by default the webservice is always passing fault information to the webservice. How do i make of the following
1. Incase the there is an custom exception thrown in Mediator, soap fault is thrown back to the webservice client.
2. Incase all the information are correct, the webservice is called properly and client gets the proper response.
You need to define a separate sequence to handle the faults. Then, in your InSequence, you need to set that fault sequence to the "onError" attribute. So your InSequence will look like
<sequence xmlns="http://ws.apache.org/ns/synapse" name="m1" onError="yourFaultSequence">
<class name="com.myclass">
</class>
<log/>
<send/>
</sequence>
Above configuration was added to give an idea. Note the onError attribute.
Following sample will also help.

Axis2 generates wrong WSDL, where is the error?

I've used NetBeans plugin "Axis2 Support" to create webservice from my pojo class.
When I go to create the client from wsdl file I get some errors.
Here is the message:
[ERROR] missing required property "style" of element "operation"
This is an example of element operation that generates the error:
<wsdl:operation name="addObjectPropertyAssertion">
<wsdl:input message="ns:addObjectPropertyAssertionRequest" wsaw:Action="urn:addObjectPropertyAssertion"/>
<wsdl:fault message="ns:EcourbStorageServiceInvalidURIException" name="EcourbStorageServiceInvalidURIException" wsaw:Action="urn:addObjectPropertyAssertionEcourbStorageServiceInvalidURIException"/>
<wsdl:fault message="ns:EcourbStorageServiceInvalidURIReferenceException" name="EcourbStorageServiceInvalidURIReferenceException" wsaw:Action="urn:addObjectPropertyAssertionEcourbStorageServiceInvalidURIReferenceException"/>
</wsdl:operation>
Deploying web service I've just some errors like this (I will correct it after, I don't think is the cause)
[WARN] We don't support method overloading. Ignoring [addRDFTriple]
Using some simple service operation in browser it works.
I found the solution: the problem was methods with void return. Set a return value of any type solves the problem.

Resources