Freemarker Performance - performance

Hi i have a legacy program which uses struts 2.0.11 with spring 2 and using freemarker 2.4.23 as the template engine.
My struts.properties are as follows:
struts.freemarker.wrapper.altMap=true
struts.freemarker.mru.max.strong.size =250
struts.freemarker.beanwrapperCache=true
struts.freemarker.templatesCache=true
struts.freemarker.templatesCache.updateDelay=600000
We notice that there is always a delay of a few seconds when the last line of our jsp content is processed. For example, this is an extract from our log:
[6/12/16 15:41:42:253 SGT] 0000014b SystemOut O [12/6/2016 15:41:42] INFO [WebContainer : 5] | End Session:2016-06-12 15:41:42.252
[6/12/16 15:41:44:794 SGT] 0000014b TimerIntercep I com.opensymphony.xwork2.interceptor.TimerInterceptor doLog Executed action [/!execute] took 4195 ms.
I am still not sure what causes the 2 second delay. Can any experts on freemarker explain this?
Part of the thread dump
at com.ibm.wsspi.webcontainer.facade.ServletContextFacade.getRealPath(ServletContextFacade.java:243)
at freemarker.cache.WebappTemplateLoader.findTemplateSource(WebappTemplateLoader.java:103)
at freemarker.cache.MultiTemplateLoader.findTemplateSource(MultiTemplateLoader.java:73)
at freemarker.cache.TemplateCache.findTemplateSource(TemplateCache.java:788)
at freemarker.cache.TemplateCache.lookupTemplateWithAcquisitionStrategy(TemplateCache.java:748)
at freemarker.cache.TemplateCache.access$500(TemplateCache.java:58)
at freemarker.cache.TemplateCache$TemplateCacheTemplateLookupContext.lookupWithAcquisitionStrategy(TemplateCache.java:914)
at freemarker.cache.TemplateCache$TemplateCacheTemplateLookupContext.lookupWithLocalizedThenAcquisitionStrategy(TemplateCache.java:934)
at freemarker.cache.TemplateLookupStrategy$Default020300.lookup(TemplateLookupStrategy.java:105)
at freemarker.cache.TemplateCache.lookupTemplate(TemplateCache.java:736)
at freemarker.cache.TemplateCache.getTemplateInternal(TemplateCache.java:372)
at freemarker.cache.TemplateCache.getTemplate(TemplateCache.java:291)
at freemarker.template.Configuration.getTemplate(Configuration.java:2383)
at freemarker.core.Environment.getTemplateForInclusion(Environment.java:2478)
at freemarker.core.Include.accept(Include.java:162)
at freemarker.core.Environment.visit(Environment.java:326)
at freemarker.core.Environment.visit(Environment.java:332)
at freemarker.core.Environment.include(Environment.java:2505)
at freemarker.core.Include.accept(Include.java:171)
at freemarker.core.Environment.visit(Environment.java:326)
at freemarker.core.Environment.visit(Environment.java:332)
at freemarker.core.Environment.process(Environment.java:305)
at freemarker.template.Template.process(Template.java:384)
at org.apache.struts2.components.template.FreemarkerTemplateEngine.renderTemplate(FreemarkerTemplateEngine.java:168)
at org.apache.struts2.components.UIBean.mergeTemplate(UIBean.java:530)
at org.apache.struts2.components.UIBean.end(UIBean.java:484)
at org.apache.struts2.views.jsp.ComponentTagSupport.doEndTag(ComponentTagSupport.java:43)
at com.ibm._jsp._generalenquirysearch._jspx_meth_s_select_0(_generalenquirysearch.java:3500)
at com.ibm._jsp._generalenquirysearch._jspx_meth_s_form_0(_generalenquirysearch.java:7904)
at com.ibm._jsp._generalenquirysearch._jspService(_generalenquirysearch.java:806)
at com.ibm.ws.jsp.runtime.HttpJspBase.service(HttpJspBase.java:99)

Related

Mulesoft EC2 *describeInstances* with *filter* option

I'm having problems using the EC2 connector with filters for DescribeInstances. Specifically, I'm trying to find all instances that have the tag "classId" set.
I've also tried to find all instances that have the classId tag with specific string, e.g. "123".
Below are the XMLs of the describeInstance for both scenarios.
tag-key ------
<ec2:describe-instances doc:name="Describe instances" doc:id="ca64b7d4-99bb-4045-bbb4-16c0c27b1df5" config-ref="Amazon_EC2_Configuration">
<ec2:filters>
<ec2:filter name="tag-key" values="#[['classId']]">
</ec2:filter>
</ec2:filters>
</ec2:describe-instances>
tag:classId:----
<ec2:describe-instances doc:name="Describe instances" doc:id="ca64b7d4-99bb-4045-bbb4-16c0c27b1df5" config-ref="Amazon_EC2_Configuration">
<ec2:filters>
<ec2:filter name="tag:classId">
<ec2:values >
<ec2:value value="#['123']" />
</ec2:values>
</ec2:filter>
</ec2:filters>
</ec2:describe-instances>
Each time I receive an error like the following (for tag:classId):
ERROR 2021-03-29 08:32:49,693 [[MuleRuntime].uber.04: [ec2-play].ec2-playFlow.BLOCKING #1092a5bc] [processor: ; event: df5e2df0-908a-11eb-94b5-38f9d38da5c3] org.mule.runtime.core.internal.exception.OnErrorPropagateHandler: 
********************************************************************************
Message        : The filter 'null' is invalid (Service: AmazonEC2; Status Code: 400; Error Code: InvalidParameterValue; Request ID: 33e3bbfb-99ea-4382-932f-647662810c92; Proxy: null)
Element        : ec2-playFlow/processors/0 # ec2-play:ec2-play.xml:33 (Describe instances)
Element DSL      : <ec2:describe-instances doc:name="Describe instances" doc:id="ca64b7d4-99bb-4045-bbb4-16c0c27b1df5" config-ref="Amazon_EC2_Configuration">
<ec2:filters>
<ec2:filter name="tag:classId">
<ec2:values>
<ec2:value value="#['123']"></ec2:value>
</ec2:values>
</ec2:filter>
</ec2:filters>
</ec2:describe-instances>
Error type      : EC2:INVALID_PARAMETER_VALUE
FlowStack       : at ec2-playFlow(ec2-playFlow/processors/0 # ec2-play:ec2-play.xml:33 (Describe instances))
 (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
********************************************************************************
NOTE: The code works without a filter, returning all instances. But, that isn't what I want or need. The more filtering I can do the faster the response.
Does anyone have samples of the filter option working? Can you tell me what I'm doing wrong?
Thanks!
This surely is a bug. I tried the same and it was not working for me as well. I enabled debug logging and found that the connector is not sending the filter.1.Name=tag:classId as a query parameter in the request. Here is the debug log that I found. (Notice there is no filter.1.Name=tag:classId in the query string)
DEBUG 2021-04-02 21:55:17,198 [[MuleRuntime].uber.03: [test-aws-connector].test-aws-connectorFlow.BLOCKING #2dff3afe] [processor: ; event: 91a34891-93d0-11eb-af49-606dc73d31d1] org.apache.http.wire: http-outgoing-0 >> "Action=DescribeInstances&Version=2016-11-15&Filter.1.Value.1=123"
However, I tried to use the Expression or Bean Reference option and set the expression directly as [{name: 'tag:classId', values:['123']}] like this:
and it worked correctly. Here is the same debug log after this change
DEBUG 2021-04-02 21:59:17,198 [[MuleRuntime].uber.03: [test-aws-connector].test-aws-connectorFlow.BLOCKING #2dff3afe] [processor: ; event: 91a34891-93d0-11eb-af49-606dc73d31d1] org.apache.http.wire: http-outgoing-0 >> "Action=DescribeInstances&Version=2016-11-15&Filter.1.Name=tag%3AclassId&Filter.1.Value.1=123"
Also, I want to point out very weird behaviour, this does not work if you try to format [{name: 'tag:classId',values: ['123']}] across multiple lines in the expression and will give an error during deployment.

Using UltimateThreadGroup with Java API gives Nullpointer exception

I am trying to use UltimateThreadGroup with the JMeter Java API, I am creating the UltimateThreadGroup object as in the below code[2] and add it to the Hashtree.
Finally handover it to the JMeter engine to execute. 
But It gives the following NullPointerException in the middle of execution. As I debugged the code, the Issue seems coming from JMeterThread class following method.
public JMeterThread(HashTree test, JMeterThreadMonitor monitor, ListenerNotifier note, Boolean isSameUserOnNextIteration)
But issue throws on different code lines from execution to execution. So it's difficult figure out what causing the NullPointer.
Does anybody have an idea on what's going on here? Appreciate your answers.
[1]
2020-11-03 13:08:20 DEBUG TestCompiler:273 - adding controller: kg.apc.jmeter.threads.UltimateThreadGroup#30b2b76f to sampler config
2020-11-03 13:08:22 ERROR JMeterThread:319 - Test failed!
java.lang.NullPointerException
at org.apache.jmeter.threads.AbstractThreadGroup.addTestElement(AbstractThreadGroup.java:122)
at org.apache.jmeter.threads.AbstractThreadGroup.addTestElementOnce(AbstractThreadGroup.java:131)
at org.apache.jmeter.threads.TestCompiler.subtractNode(TestCompiler.java:151)
at org.apache.jorphan.collections.HashTree.traverseInto(HashTree.java:997)
at org.apache.jorphan.collections.HashTree.traverseInto(HashTree.java:994)
at org.apache.jorphan.collections.HashTree.traverse(HashTree.java:976)
at org.apache.jmeter.threads.JMeterThread.initRun(JMeterThread.java:704)
at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:252)
at java.lang.Thread.run(Thread.java:748)
[2]
UltimateThreadGroup ultimateThreadGroup = new UltimateThreadGroup();
ultimateThreadGroup.setName(threadGroupName);
ultimateThreadGroup.setProperty(AbstractThreadGroup.ON_SAMPLE_ERROR, AbstractThreadGroup.ON_SAMPLE_ERROR_CONTINUE);
PowerTableModel dataModel = new PowerTableModel(UltimateThreadGroupGui.columnIdentifiers, UltimateThreadGroupGui.columnClasses);
dataModel.addRow(new Integer[]{2, 4, 10, 60, 10});
dataModel.addRow(new Integer[]{3, 4, 10, 120, 10});
CollectionProperty prop = JMeterPluginsUtils.tableModelRowsToCollectionProperty(dataModel, UltimateThreadGroup.DATA_PROPERTY);
ultimateThreadGroup.setData(prop);
ultimateThreadGroup.setEnabled(setEnabled);
ultimateThreadGroup.setProperty(TestElement.TEST_CLASS, UltimateThreadGroup.class.getName());
ultimateThreadGroup.setProperty(TestElement.GUI_CLASS, UltimateThreadGroupGui.class.getName());
First you need to create a Loop Controller instance like:
LoopController loopController = new LoopController();
loopController.setLoops(1);
loopController.setFirst(true);
loopController.setProperty(TestElement.TEST_CLASS, LoopController.class.getName());
loopController.setProperty(TestElement.GUI_CLASS, LoopControlPanel.class.getName());
loopController.initialize();
Second you need to add the Loop Controller from the step 1 to your Ultimate Thread Group:
ultimateThreadGroup.setSamplerController(loopController);
More information:
Five Ways To Launch a JMeter Test without Using the JMeter GUI
jmeter-from-code
Going forward just compare the .jmx which you generate programatically with the one which is created by JMeter GUI, you will be able to see what fields, properties, etc. are missing

Validation of FHIR Resources against different aspects listed at https://www.hl7.org/fhir/validation.html using HAPI Library

Getting the below exception when running the code:
FhirContext ctx = FhirContext.forR4();
// Create a FhirInstanceValidator and register it to a validator
FhirValidator validator = ctx.newValidator();
FhirInstanceValidator instanceValidator = new FhirInstanceValidator();
validator.registerValidatorModule(instanceValidator);
/*
* If you want, you can configure settings on the validator to adjust
* its behaviour during validation
*/
instanceValidator.setAnyExtensionsAllowed(true);
// input is Patient resource in String https://www.hl7.org/fhir/patient-example.json.html
ValidationResult result = validator.validateWithResult(input);
I am using Hapi Library to validate a resource (if i am not wrong this is a Patient resource https://www.hl7.org/fhir/patient-example.json.html ). I have stored this Patient Json in a string
and trying to Validate its :
1: Structure -> i think using Parse Validation it can be achieved and i did the same.
2: Cardinality -> I created two "active:true" Json key-value pair thinking that it will throw cardinality error but neither of SchemxxxValidator / ParseValidator / InstanceValidator working.
...
How to validate a resource against properties listed here https://www.hl7.org/fhir/validation.html (structure ,cardinality , ValueDomains ...) , Do i have to use all three ways
That is Parser , FhirInstanceValidator and SchemaBaseValidator / SchematronBaseValidator .
Please Help as i am new to FHIR and excuse for lame question.
15:58| INFO | VersionUtil.java 72 | HAPI FHIR version 4.1.0 - Rev 03163c2cf5
15:58| INFO | FhirContext.java 174 | Creating new FHIR context for FHIR version [R4]
15:58| INFO | DefaultProfileValidationSupport.java 227 | Loading structure definitions from classpath: /org/hl7/fhir/r4/model/profile/profiles-resources.xml
15:58| INFO | DependencyLogImpl.java 75 | FHIR XML procesing will use StAX implementation 'Woodstox' version '5.1.0'
15:58| INFO | DefaultProfileValidationSupport.java 227 | Loading structure definitions from classpath: /org/hl7/fhir/r4/model/profile/profiles-types.xml
15:58| INFO | DefaultProfileValidationSupport.java 227 | Loading structure definitions from classpath: /org/hl7/fhir/r4/model/profile/profiles-others.xml
15:58| INFO | DefaultProfileValidationSupport.java 227 | Loading structure definitions from classpath: /org/hl7/fhir/r4/model/extension/extension-definitions.xml
15:58| ERROR | FhirInstanceValidator.java 222 | Failure during validation
java.lang.UnsupportedOperationException
at org.hl7.fhir.r4.hapi.ctx.HapiWorkerContext.generateSnapshot(HapiWorkerContext.java:242)
at org.hl7.fhir.r4.elementmodel.ParserBase.getDefinition(ParserBase.java:122)
at org.hl7.fhir.r4.elementmodel.JsonParser.parse(JsonParser.java:123)
at org.hl7.fhir.r4.validation.InstanceValidator.validate(InstanceValidator.java:539)
at org.hl7.fhir.r4.validation.InstanceValidator.validate(InstanceValidator.java:531)
at org.hl7.fhir.r4.hapi.validation.FhirInstanceValidator.validate(FhirInstanceValidator.java:220)
at org.hl7.fhir.r4.hapi.validation.FhirInstanceValidator.validate(FhirInstanceValidator.java:242)
at org.hl7.fhir.r4.hapi.validation.BaseValidatorBridge.doValidate(BaseValidatorBridge.java:20)
at org.hl7.fhir.r4.hapi.validation.BaseValidatorBridge.validateResource(BaseValidatorBridge.java:43)
at org.hl7.fhir.r4.hapi.validation.FhirInstanceValidator.validateResource(FhirInstanceValidator.java:33)
at ca.uhn.fhir.validation.FhirValidator.validateWithResult(FhirValidator.java:243)
at ca.uhn.fhir.validation.FhirValidator.validateWithResult(FhirValidator.java:198)
at com.json.schema.validator.InstanceValidatorEx.instanceValidator(InstanceValidatorEx.java:223)
at com.json.schema.validator.InstanceValidatorEx.main(InstanceValidatorEx.java:191)
Exception in thread "main" ca.uhn.fhir.rest.server.exceptions.InternalErrorException: Unexpected failure while validating resource
at org.hl7.fhir.r4.hapi.validation.FhirInstanceValidator.validate(FhirInstanceValidator.java:223)
at org.hl7.fhir.r4.hapi.validation.FhirInstanceValidator.validate(FhirInstanceValidator.java:242)
at org.hl7.fhir.r4.hapi.validation.BaseValidatorBridge.doValidate(BaseValidatorBridge.java:20)
at org.hl7.fhir.r4.hapi.validation.BaseValidatorBridge.validateResource(BaseValidatorBridge.java:43)
at org.hl7.fhir.r4.hapi.validation.FhirInstanceValidator.validateResource(FhirInstanceValidator.java:33)
at ca.uhn.fhir.validation.FhirValidator.validateWithResult(FhirValidator.java:243)
at ca.uhn.fhir.validation.FhirValidator.validateWithResult(FhirValidator.java:198)
at com.json.schema.validator.InstanceValidatorEx.instanceValidator(InstanceValidatorEx.java:223)
at com.json.schema.validator.InstanceValidatorEx.main(InstanceValidatorEx.java:191)
Caused by: java.lang.UnsupportedOperationException
at org.hl7.fhir.r4.hapi.ctx.HapiWorkerContext.generateSnapshot(HapiWorkerContext.java:242)
at org.hl7.fhir.r4.elementmodel.ParserBase.getDefinition(ParserBase.java:122)
at org.hl7.fhir.r4.elementmodel.JsonParser.parse(JsonParser.java:123)
at org.hl7.fhir.r4.validation.InstanceValidator.validate(InstanceValidator.java:539)
at org.hl7.fhir.r4.validation.InstanceValidator.validate(InstanceValidator.java:531)
at org.hl7.fhir.r4.hapi.validation.FhirInstanceValidator.validate(FhirInstanceValidator.java:220)
Cardinality -> I created two "active:true" Json key-value pair thinking that it will throw cardinality error but neither of SchemxxxValidator / ParseValidator / InstanceValidator working. ...
That's an issue in HAPI - it validates the objects it loads from the JSON, and the JSON parser silently drops the duplicate property key. If you use the validator directly, this won't happen. I believe that this is going to be addressed at some stage
generateSnapshot failed
that's a real issue - I'm not sure why that's not set up, but the validator can't work if snapshots are not being generated

IBM Content Collector error receiving response after external WS call

In my current project using IBM Content Collector 4.0.1 SP5 with IBM Filenet P8 Content Engine 5.2.1 I need to collect files from file system and add them to a certain P8's object store.
This issue is related and comes after this one.
The WS response must conform to a custom metadata source called Esito which contains two metadata properties called resultCode and message.
The call seems correct but when getting the response I can read this message in the log and the file is not uploaded into P8 Content Manager:
2017-11-10T08:54:05.708Z FINEST [52] [ctms-native]
2017-11-10T08:54:05Z Trace2 0x15a4 Feeding JavaTask with 1 TaskInputs
ufibridge.dll:0x114ac [com.ibm.afu.ufibridge.logging.LoggingAdapter
log] [CTMS-task-15a4 45] 2017-11-10T08:54:05.708Z FINEST [53] Prepared
content to send to
webservice:{"e:\report\amm_000001_00001\2017\11\201711_amm_000001_00001_qxn_report_00.pdf":{"esito":"KO","fileName":"201711_AMM_000001_00001_QXN_REPORT_00(1)(2)(3).pdf"},"e:\report\amm_000001_00001\2017\11\201711_amm_000001_00001_qxn_report_00.xml":{"esito":"KO","fileName":"201711_AMM_000001_00001_QXN_REPORT_00(1)(2)(3).xml"}}
[com.ibm.afu.connector.webservice.task.InvokeServiceTask
getInputHttpEntity] [CTMS-task-15a4 45] 2017-11-10T08:54:05.708Z
FINEST [54] Configuration:
property name="message" type="STRING" displayName="message"
property name="resultCode" type="STRING" displayName="resultCode"
http://192.168.8.29:8080/sirfAcq/filenet/notificaArchiviazione
fileName esito
[com.ibm.afu.connector.webservice.task.InvokeServiceTask execute]
[CTMS-task-15a4 45] 2017-11-10T08:54:05.708Z FINEST [55] Invoking
webservice
URI:http://192.168.8.29:8080/sirfAcq/filenet/notificaArchiviazione
[com.ibm.afu.connector.webservice.task.InvokeServiceTask execute]
[CTMS-task-15a4 45] 2017-11-10T08:54:05.739Z FINEST [56] Invocation
took time (ms): 31
[com.ibm.afu.connector.webservice.task.InvokeServiceTask execute]
[CTMS-task-15a4 45] 2017-11-10T08:54:05.739Z SEVERE [57]
java.lang.String incompatible with com.ibm.json.java.JSONObject
[com.ibm.afu.connector.webservice.task.InvokeServiceTask execute]
[CTMS-task-15a4 45]Exception [java.lang.ClassCastException]:
java.lang.String incompatible with com.ibm.json.java.JSONObject
com.ibm.afu.connector.webservice.task.InvokeServiceTask.processResponse(InvokeServiceTask.java:140)
com.ibm.afu.connector.webservice.task.InvokeServiceTask.execute(InvokeServiceTask.java:112)
Could someone please explain me the correct format of the WS response JSON?
Could it be possible to use the One-Way mode instead of the Request-Response mode?
This issue seems to happen because of the incompatibility between the produce and the response body definition, based on the code snippet I had for your first post, your problem should be here:
produces = {MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE })
#ResponseBody
String notificaArchiviazione(#RequestParam("fileName") String fileName, #RequestParam("esito") String esito)
The first parameter in produce is sat as JSONMediaType.APPLICATION_JSON_VALUE while in the response body you expect a string #RequestParam("fileName") String fileName

Entity Manager EJB query could not locate named parameter

enter code hereHi I'm using Entity manager(EJB) which internally depends on hibernate to get Object.
My query is ........
TypedQuery<FraudDetectionInfoEntity> queryKount = em_oltp.createQuery("SELECT o FROM FraudDetectionInfoEntity o WHERE o.order.orderId=:orderId",FraudDetectionInfoEntity.class);
query.setParameter("orderId", orderEntity.getOrderId());
FraudDetectionInfoEntity infoEntity=queryKount.getSingleResult();
I'm getting folowing error If I run that query.
org.hibernate.QueryParameterException: could not locate named parameter [orderId]
org.hibernate.QueryParameterException: could not locate named parameter [orderId]
12:46:58,639 ERROR [com.vip.enterprise.admin.web.controller.OrderPlacementController] (http-/127.0.0.1:8084-6) error com.vip.enterprise.service.exception.ServiceException: org.hibernate.QueryParameterException: could not locate named parameter [orderId]
12:47:00,001 ERROR [com.vip.enterprise.service.jobs.ReplenishmentJob] (EJB default - 4) Replenish Orders JOB : Mon Jan 27 12:47:00 IST 2014
Your code is ok. Missing variable query or queryKount?
TypedQuery<FraudDetectionInfoEntity> queryKount = em_oltp.createQuery("SELECT o FROM FraudDetectionInfoEntity o WHERE o.order.orderId=:orderId",FraudDetectionInfoEntity.class);
query.setParameter("orderId", orderEntity.getOrderId());
<or>
queryKount.setParameter("orderId", orderEntity.getOrderId());

Resources