Unable to handled dynamic cookie value from request - jmeter

Please help me to get out from this issue.
Added CookieManager.save.cookies=true line to user.properties file
Restarted JMeter to pick the property up
Accessed the cookie value as ${COOKIE_WRAPv0.8}
but got below error.
java.net.URISyntaxException: Illegal character in query at index 55:
https://sqa-web.molace-pcc.net/Ref/DashBoard?WRAPv0.8=${COOKIE_WRAPv0.8} at
java.net.URI$Parser.fail(Unknown Source) at
java.net.URI$Parser.checkChars(Unknown Source) at
java.net.URI$Parser.parseHierarchical(Unknown Source) at
java.net.URI$Parser.parse(Unknown Source) at
java.net.URI. (Unknown Source) at
java.net.URL.toURI(Unknown Source) at
org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl.sample(HTTPHC4Impl.java:357) at
org.apache.jmeter.protocol.http.sampler.HTTPSamplerProxy.sample(HTTPSamplerProxy.java:74) at
org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1189) at
org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1178) at
org.apache.jmeter.threads.JMeterThread.executeSamplePackage(JMeterThread.java:491) at
org.apache.jmeter.threads.JMeterThread.processSampler(JMeterThread.java:425) at
org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:254) at
java.lang.Thread.run(Unknown Source)

First check that you have added a HTTP Cookie Manager in your test plan.
But I tested your site , there is no cookie except this one:
COOKIE_ApplicationGatewayAffinity
As a consequence, COOKIE_WRAPv0.8 variable is not defined which leads to your issue

It seems like you cookie value is not passing through properly. I have used a local variable as cookie and pass in your request. It went successfully. But, if I change the variable name or delete it..then I am getting the same error as you are.
As you can see below, the first request is good if the value is passing correctly.
But, the second request will give the same error, if the cookie value is not passing.
Hope this helps.

Related

Jmeter, read BLOB (Which contains an XML) using Jmeter

I have a database table in which one column has a BLOB data, which can contain a text or an XML [Please do not ask why, somehow a dev made this choice]. I want to read the BLOB data and save it in a file. Can anyone help me on how to read the BLOB data?
I have the following JSR 223, POST processor (Groovy Code):
byte[] blobByte = vars.getObject("gaurav").get(0).get("TEXT");
String blob = new String(blobByte);
log.info(blob);
However, I get the following error:
javax.script.ScriptException: groovy.lang.GroovyRuntimeException: Ambiguous method overloading for method java.lang.String#<init>.
Cannot resolve which method to invoke for [null] due to overlapping prototypes between:
[class [B]
[class [C]
[class java.lang.String]
at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:324) ~[groovy-all-2.4.16.jar:2.4.16]
at org.codehaus.groovy.jsr223.GroovyCompiledScript.eval(GroovyCompiledScript.java:72) ~[groovy-all-2.4.16.jar:2.4.16]
at javax.script.CompiledScript.eval(Unknown Source) ~[?:1.8.0_251]
at org.apache.jmeter.util.JSR223TestElement.processFileOrScript(JSR223TestElement.java:223) ~[ApacheJMeter_core.jar:5.2.1]
at org.apache.jmeter.extractor.JSR223PostProcessor.process(JSR223PostProcessor.java:44) [ApacheJMeter_components.jar:5.2.1]
at org.apache.jmeter.threads.JMeterThread.runPostProcessors(JMeterThread.java:931) [ApacheJMeter_core.jar:5.2.1]
at org.apache.jmeter.threads.JMeterThread.executeSamplePackage(JMeterThread.java:569) [ApacheJMeter_core.jar:5.2.1]
at org.apache.jmeter.threads.JMeterThread.processSampler(JMeterThread.java:490) [ApacheJMeter_core.jar:5.2.1]
Can anyone help me what is wrong in my logic?
PS: I refer this page for the conversion logic : https://www.blazemeter.com/blog/performance-testing-blob-from-a-mysql-database-with-jmeter
In the article you're referring to the TEXT is the name of the column, I strongly doubt that your column has this name therefore your blobByte is null therefore your BLOB reading logic fails.
Check which variables are being produced by your JDBC Request sampler using Debug Sampler and View Results Tree listener combination, your approach will work only if you see gaurav JMeter Variable with the value of java.sql.Blob
See Debugging JDBC Sampler Results in JMeter article for more information on working with JDBC Result Sets in JMeter tests

JMeter-Passing an id value from Response Header in path of next HTTP Request

I have following Response headers info from first HTTP Request:
HTTP/1.1 200 OK
set-cookie: x-usercontext=x-language=en&x-client=000; path=/
content-type: application/json
content-length: 7350
x-csrf-token: MiMegLCohX2qMT42ba3lzA==
cache-control: no-cache
x-rewriteurl: /x(cz1TSUQlM2FBTk9OJTNhbGRjaWtpd19LSVdfMDAlM2FNeXBWZklCU3pCOF9rUlB6S01TN2w4TmMxVERJTUNSRThBX1Q5RU1MLUFUVA==)/bw/ina/GetServerInfo
x-url-session-id: x(cz1TSUQlM2FBTk9OJTNhbGRjaWtpd19LSVdfMDAlM2FNeXBWZklCU3pCOF9rUlB6S01TN2w4TmMxVERJTUNSRThBX1Q5RU1MLUFUVA==)
x-server: true
x-perf-fesrec: 14161.000000
I must put the sequence of the x-url-session-id into the path of the next HTTP Request as below:
http://test.xxx.xxx.xxx:50000/{x-url-session-id}/bw/ina/GetResponse?xxx-client=000&xxx-language=en_UK&xxx-sessionviaurl=X
I tried to use Regex Extractor but I can not put the needed id as ${x-url-session-id} because I get the error:
java.net.URISyntaxException: Illegal character in path at index 35:
http://xxx.xxx.xxx.xxx:50000/${x-url-session-id}/bw/ina/GetResponse?xxx-client=000&xx-language=en_UK&xxx-sessionviaurl=X
at java.net.URI$Parser.fail(Unknown Source)
at java.net.URI$Parser.checkChars(Unknown Source)
at java.net.URI$Parser.parseHierarchical(Unknown Source)
at java.net.URI$Parser.parse(Unknown Source)
at java.net.URI.<init>(Unknown Source)
at java.net.URL.toURI(Unknown Source)
Is there a way to put the given value from the first HTTP request as an part of the path in the second HTTP Request?
Many thanks...
It means that your ${x-url-session-id} variable is not defined, most probably due to incorrect Regular Expression Extractor configuration, double check it using Debug Sampler and View Results Tree listener combination and if this is the case - make sure to properly configure the Regular Expression Extractor, in particular it needs to be applied to Response Headers
Also if there is a redirection in place you also need to apply it to sub samples as well.
Example setup:

JMeter intermittently failing to parse URL variables while load testing

While load testing with JMeter I am attempting to send 1000 requests in one second. The issue is that I need to send the access token aquired from each previous login. While doing so I am getting the following error:
java.net.URISyntaxException: Illegal character in path at index 67: https://greenback-api.com/api/subscribers/getSavings/${USER_ID}?access_token=${AUTH_TOKEN}
Typical under a low load JMETER has no problem transforming the variables into a valid url likeso:
api.com/api/subscribers/getSavings/4?access_token=443hrr4938rh9ghreughughtrugtrgt4
Is there a way to force JMETER to render the url variables before issuing a get request even under a high load?
It looks like sometimes ${USER_ID} and ${AUTH_TOKEN} are not returned by login (or whatever sets them). As a result JMeter will use the expression ${...} as is. And the characters {} are indeed invalid for URI (they have to be encoded).
Another option is that ${USER_ID} or ${AUTH_TOKEN} really contain some characters invalid for URI and that need to be encoded.
So you may need to
URL Encode your ${AUTH_TOKEN} (and possibly ${USER_ID})
Make stricter checking upon login completion (and any other operations that fill ${USER_ID} or ${AUTH_TOKEN}) to make sure they don't proceed to the following operations if the value was not returned.

WAS Liberty profile java.lang.IllegalArgumentException: Cookie name "Path" is a reserved token

I am getting following exception when trying to access the deployed war application.
Environment Details:
WAS Liberty Profile and
IBM JDK 6
<pre>
Exception = java.lang.IllegalArgumentException
Source = com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters
probeid = 1105
Stack Dump = java.lang.IllegalArgumentException: Cookie name "Path" is a reserved token
at javax.servlet.http.Cookie.<init>(Cookie.java:139)
at com.ibm.ws.webcontainer.osgi.request.IRequestImpl.getCookies(IRequestImpl.java:147)
at com.ibm.ws.webcontainer.srt.SRTServletRequest.getCookies(SRTServletRequest.java:1600)
at com.ibm.ws.webcontainer.security.internal.WebRequestImpl.determineIfRequestHasAuthenticationData(WebRequestImpl.java:155)
at com.ibm.ws.webcontainer.security.internal.WebRequestImpl.hasAuthenticationData(WebRequestImpl.java:176)
at com.ibm.ws.webcontainer.security.internal.WebAppSecurityCollaboratorImpl.optionallyAuthenticateUnprotectedResource(WebAppSecurityCollaboratorImpl.java:392)
at com.ibm.ws.webcontainer.security.internal.WebAppSecurityCollaboratorImpl.performSecurityChecks(WebAppSecurityCollaboratorImpl.java:343)
at com.ibm.ws.webcontainer.security.internal.WebAppSecurityCollaboratorImpl.preInvoke(WebAppSecurityCollaboratorImpl.java:327)
at com.ibm.wsspi.webcontainer.collaborator.CollaboratorHelper.preInvokeCollaborators(CollaboratorHelper.java:431)
at com.ibm.ws.webcontainer.osgi.collaborator.CollaboratorHelperImpl.preInvokeCollaborators(CollaboratorHelperImpl.java:267)
at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1033)
at com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:81)
at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:930)
at com.ibm.ws.webcontainer.osgi.DynamicVirtualHost$1.run(DynamicVirtualHost.java:253)
at com.ibm.ws.http.dispatcher.internal.channel.HttpDispatcherLink$TaskWrapper.run(HttpDispatcherLink.java:457)
at com.ibm.ws.threading.internal.Worker.executeWork(Worker.java:398)
at com.ibm.ws.threading.internal.Worker.run(Worker.java:380)
at java.lang.Thread.run(Thread.java:770)
</pre>
Can somebody help on this?
There are restrictions on cookie names, including a selection of reserved names/tokens[1]. (No need to worry about the specific environment in this case.) =) You may not use any of the following names (this list may not be exhaustive):
comment
discard
domain
expires
max-age
path
secure
version
Also, since cookies are case-insensitive[2], "Path" will spark the same java.lang.IllegalArgumentException as "path" will.
As for the restrictions, cookie names:
must not be null or empty[3]
must not contain any whitespace[3]
must not start with $[2]
must not include commas , or semicolons ;[3]
=)
References
"Cookie Reserved Names- Who's to blame?" article
RFC 2109 specification (see sections 4.1 and 4.2.2 respectively)
Java EE 6 Cookie constructor documentation
From the stacktrace, it looks like that the cookie from the client side (maybe the browser ?) has an invalid name. Per the Cookie java doc, some reserved words are not allowed for cookie name.
java.lang.IllegalArgumentException - if the cookie name is null or
empty or contains any illegal characters (for example, a comma, space,
or semicolon) or matches a token reserved for use by the cookie
protocol

the form object placed in ModelMap seems cleared somewhere when some action is invoked

I have a Controller, that deals with two forms.
in initialize Form Method i set all the stuff requird to render the screen. and put the form object to the model map.
on the render phase the rendering is done successfuly. but when submit is done and the #ActionMapping is invoked.
I got the exception with.
org.springframework.web.portlet.handler.PortletSessionRequiredException: Session attribute 'someForm' required - not found in session
at org.springframework.web.portlet.mvc.annotation.AnnotationMethodHandlerAdapter$PortletHandlerMethodInvoker.raiseSessionRequiredException(AnnotationMethodHandlerAdapter.java:554)
at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.resolveModelAttribute(HandlerMethodInvoker.java:758)
at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.resolveHandlerArguments(HandlerMethodInvoker.java:356)
at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:171)
at org.springframework.web.portlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:360)
at org.springframework.web.portlet.mvc.annotation.AnnotationMethodHandlerAdapter.doHandle(AnnotationMethodHandlerAdapter.java:347)
at org.springframework.web.portlet.mvc.annotation.AnnotationMethodHandlerAdapter.handleAction(AnnotationMethodHandlerAdapter.java:281)
at org.springframework.web.portlet.DispatcherPortlet.doActionService(DispatcherPortlet.java:641)
at org.springframework.web.portlet.FrameworkPortlet.processRequest(FrameworkPortlet.java:519)
at org.springframework.web.portlet.FrameworkPortlet.processAction(FrameworkPortlet.java:460)
at com.liferay.portlet.FilterChainImpl.doFilter(FilterChainImpl.java:70)
at com.nomadsoft.cortex.infrastructure.spring.security.SecurityContextAuthenticatedPortletFilter.doFilter(SecurityContextAuthenticatedPortletFilter.java:99)
at sun.reflect.GeneratedMethodAccessor554.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
If i Place the Object into HTTP session that i obtain from Request object and manipulate through the process every thing Goes fine
I do;t know what is going wrong when i work with model map.
in the rest of the application there are more other controllers those are working fine.
Any Clue will be highly appriciated.
it seems that your forms need the 'someForm' attributs (Session attribute 'someForm' required).
This attribut must be called in your page.

Resources