Jython, websphere : Operation getStatsObject not in ModelMBeanInfo - websphere

Could you please help me to get the current value of ActiveCount (ThreadPoolModule) in websphere ?
Below you can find my code and the error generated :
perfName = AdminControl.completeObjectName ('name=WebContainer,type=ThreadPool,process=G5-WLS,*')
perfOName = AdminControl.makeObjectName (perfName)
sigs = ['javax.management.ObjectName', 'java.lang.Boolean']
jvmName = AdminControl.completeObjectName ('name=WebContainer,type=ThreadPool,process=G5-WLS,*')
params = [AdminControl.makeObjectName (jvmName), java.lang.Boolean ('false')]
jvmStats=AdminControl.invoke_jmx (perfOName, 'getStatsObject', params, sigs)
ActiveCount=jvmStats.getStatistic( 'ActiveCount').getCurrent()
Error in line 6 :
wsadmin> jvmStats=AdminControl.invoke_jmx (perfOName, 'getStatsObject', params, sigs)
WASX7015E: Exception reçue lors de l'exécution de la commande : " jvmStats=AdminControl.invoke_jmx (perfOName, 'getStatsObject', params, sigs)"; informations sur l'exception :
javax.management.MBeanException
javax.management.ServiceNotFoundException: Operation getStatsObject not in ModelMBeanInfo

Sorry I have found the answer :
perfName = AdminControl.completeObjectName ('type=Perf,process=G5-WLS,*')
perfOName = AdminControl.makeObjectName (perfName)
sigs = ['javax.management.ObjectName', 'java.lang.Boolean']
threadPoolName = AdminControl.completeObjectName ('name=WebContainer,type=ThreadPool,process=G5-WLS,*')
params = [AdminControl.makeObjectName (threadPoolName), java.lang.Boolean ('false')]
jvmStats=AdminControl.invoke_jmx (perfOName, 'getStatsObject', params, sigs)
ActiveCount=jvmStats.getStatistic( 'ActiveCount').getCurrent()
And the result :
wsadmin>print ActiveCount
1

Related

Encountering MappableException after upgrading helidon and jersey

After upgrading helidon to 2.5.4 and jersey to 2.35, I am getting the following exception in one of the API. With previous version of helidon(2.0.2) and jersey(2.29.1), it used to work fine. Can you please help to resolve this issue.
{"level":"ERROR","logger":"org.glassfish.jersey.server.ServerRuntime$Responder","thread":"jersey-thread-7","ts":1671639547627,"x-request-id":"","msg":"An I/O error has occurred while writing a response message entity to the container output stream.:\norg.glassfish.jersey.server.internal.process.MappableException: java.io.IOException: Bad news: the stream has been closed\n\tat org.glassfish.jersey.server.internal.MappableExceptionWrapperInterceptor.aroundWriteTo(MappableExceptionWrapperInterceptor.java:67)\n\tat org.glassfish.jersey.message.internal.WriterInterceptorExecutor.proceed(WriterInterceptorExecutor.java:139)\n\tat org.glassfish.jersey.message.internal.MessageBodyFactory.writeTo(MessageBodyFactory.java:1116)\n\tat org.glassfish.jersey.server.ServerRuntime$Responder.writeResponse(ServerRuntime.java:635)\n\tat org.glassfish.jersey.server.ServerRuntime$Responder.processResponse(ServerRuntime.java:373)\n\tat org.glassfish.jersey.server.ServerRuntime$Responder.process(ServerRuntime.java:363)\n\tat org.glassfish.jersey.server.ServerRuntime$1.run(ServerRuntime.java:258)\n\tat org.glassfish.jersey.internal.Errors$1.call(Errors.java:248)\n\tat org.glassfish.jersey.internal.Errors$1.call(Errors.java:244)\n\tat org.glassfish.jersey.internal.Errors.process(Errors.java:292)\n\tat org.glassfish.jersey.internal.Errors.process(Errors.java:274)\n\tat org.glassfish.jersey.internal.Errors.process(Errors.java:244)\n\tat org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:265)\n\tat org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:234)\n\tat org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:684)\n\tat io.helidon.webserver.jersey.JerseySupport$JerseyHandler.lambda$doAccept$4(JerseySupport.java:335)\n\tat io.helidon.common.context.Contexts.runInContext(Contexts.java:117)\n\tat io.helidon.common.context.ContextAwareExecutorImpl.lambda$wrap$7(ContextAwareExecutorImpl.java:154)\n\tat java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)\n\tat java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)\n\tat java.base/java.lang.Thread.run(Thread.java:834)\nCaused by: java.io.IOException: Bad news: the stream has been closed\n\tat io.helidon.webserver.jersey.ResponseWriter$DataChunkOutputStream.awaitRequest(ResponseWriter.java:327)\n\tat io.helidon.webserver.jersey.ResponseWriter$DataChunkOutputStream.write(ResponseWriter.java:186)\n\tat org.glassfish.jersey.message.internal.CommittingOutputStream.write(CommittingOutputStream.java:200)\n\tat org.glassfish.jersey.message.internal.WriterInterceptorExecutor$UnCloseableOutputStream.write(WriterInterceptorExecutor.java:276)\n\tat com.fasterxml.jackson.core.json.UTF8JsonGenerator._flushBuffer(UTF8JsonGenerator.java:2171)\n\tat com.fasterxml.jackson.core.json.UTF8JsonGenerator._writeBytes(UTF8JsonGenerator.java:1260)\n\tat com.fasterxml.jackson.core.json.UTF8JsonGenerator.writeFieldName(UTF8JsonGenerator.java:284)\n\tat com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:726)\n\tat com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:774)\n\tat com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.java:178)
I also see the below warning whenever the mappableexception is encountered.
{"level":"WARN","logger":"io.helidon.webserver.BareResponseImpl","thread":"jersey-thread-1","ts":1671689369384,"x-request-id":"","msg":"Entity was requested and not fully consumed before a response is sent. This is not supported. Connection will be closed. Please fix your route for POST /demo/api/v2/test/","podname":"deployment-demo-batch-0"}
Below is the signature of the api which errored,
#post
#path("test")
#produces(MediaType.APPLICATION_JSON + "; charset=UTF-8")
#consumes(MediaType.APPLICATION_JSON + "; charset=UTF-8")
#timed(name="app_kpi",
absolute = true,
reusable = true,
unit=MetricUnits.NANOSECONDS,displayName="test",
tags = {"api=test"})
#tag(name = "Version2")
#APIResponse(responseCode = "200", description = "Success", content = #content(schema = #Schema(type=SchemaType.ARRAY, implementation = OutputRecord.class)))
#APIResponse(responseCode = "403", description = "Forbidden")
#APIResponse(responseCode = "401", description = "Unauthorized")
#APIResponse(responseCode = "500", description = "An unexpected error occurred during the request.")
#authenticated
public Vector<OutputRecords> test(#requestbody(description = "An array of input records to be processed.", required = true,
content = #content(schema = #Schema(type = SchemaType.ARRAY, implementation = InputRecord.class))) Vector <InputRecords> inputRecords)
This has been reported as issue 5775 for Helidon.

Spring Boot : Cannot replace Jackson with Gson , jackson still appears in logs

Gson dependency
implementation("com.google.code.gson:gson:2.9.0")
application-dev.properties
spring.http.converters.preferred-json-mapper=gson
# Format to use when serializing Date objects.
spring.gson.date-format="yyyy-MM-dd HH:mm:ss"
Function to handle incoming post request with data payload
#RequestMapping(path = [ControllerEndPoints.AddCheckingPoint], method = [RequestMethod.POST])
fun addCheckingPoint(#RequestBody reqData: ChartServerVo): ResponseEntity<Ack> {
var ok = true
val data = CheckingPointEntity()
val cpDto = reqData.checkingPointDto
val gson = GsonBuilder().setDateFormat("yyyy-MM-dd HH:mm:ss").create()
val payload = gson.toJson(reqData)
mLog("json: \n json $payload")
//val gDto = reqData.gDto
data.apply {
name = cpDto.name
description = cpDto.description
cpTypeId = cpDto.cpTypeId
isCumulative = cpDto.isCumulative
cpCategoryGroupId = cpDto.cpCategoryGroupId
isTemplate = cpDto.isTemplate
isTopTemplate = cpDto.isTopTemplate
}
cpr.save(data)
pcRepo.save(reqData.purusharthChartDto.toEntity())
pcMappingrepo.save(reqData.purusharthChartCpMappingDto.toEntity())
return ResponseEntity(Ack(ok), HttpStatus.ACCEPTED)
}
JSON Payload
{"checkingPointDto":{"cpCategoryGroupId":1641785600780,"cpTypeId":1,"description":"","isCumulative":false,"isTemplate":false,"isTopTemplate":false,"name":"asdf","dbCreateDts":"2022-03-05 11:54:01","dbCreateSource":"","dbUpdateDts":"2022-03-05 11:54:01","dbUpdateSource":"","id":0},"purusharthChartCpMappingDto":{"cpId":0,"id":0,"purusharthChartId":1647652877927},"purusharthChartDto":{"adminID":0,"description":"","endDate":"2022-12-30 11:54:01","id":1647652877927,"isSelfChart":false,"name":"asdf","startDate":"2022-03-05 11:54:01","userId":8}}
Error log
POST "/api/v1/cp-add", parameters={}
2022-03-05 16:52:32.118 DEBUG 1360 --- [nio-9000-exec-2] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped to in_.co.innerpeacetech.bkp.controller.CheckingPointController#addCheckingPoint(ChartServerVo)
2022-03-05 16:52:32.358 DEBUG 1360 --- [nio-9000-exec-2] o.s.web.method.HandlerMethod : Could not resolve parameter [0] in public org.springframework.http.ResponseEntity<in_.co.innerpeacetech.bkp.dto.Ack> in_.co.innerpeacetech.bkp.controller.CheckingPointController.addCheckingPoint(in_.co.innerpeacetech.bkp.dto.ChartServerVo): JSON parse error: Cannot construct instance of `in_.co.innerpeacetech.bkp.dto.ChartServerVo`, problem: `java.lang.IllegalArgumentException`; nested exception is com.fasterxml.jackson.databind.exc.ValueInstantiationException: Cannot construct instance of `in_.co.innerpeacetech.bkp.dto.ChartServerVo`, problem: `java.lang.IllegalArgumentException`
at [Source: (PushbackInputStream); line: 1, column: 2]
2022-03-05 16:52:32.365 WARN 1360 --- [nio-9000-exec-2] .w.s.m.s.DefaultHandlerExceptionResolver : Resolved [org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Cannot construct instance of `in_.co.innerpeacetech.bkp.dto.ChartServerVo`,
My data class variable from the error log
#JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
var dbCreateDts: Date = Date(),
Why is com.fasterxml.jackson.databind still present in the logs and why is the params empty in the logs POST "/api/v1/cp-add", parameters={}, I am testing the api from postman and the headers and everything is fine and the json is also properly formatted. I am new to spring, what am I missing.

As it is referenced in the xpath to a one more view tag

I'm using scrapy framework and I can not load the other data from my analyzed webpage, it has a tag to see more. Could you tell me what you could do about it, thank you.
import scrapy
from scrapy.spiders import CrawlSpider,Rule
from scrapy.linkextractors import LinkExtractor
from prueba1.items import Prueba1Item
from scrapy.exceptions import CloseSpider
class PruebaSpider(CrawlSpider):
name = 'prueba1'
item_count = 0
allowed_domain = ['http://www.abc.com.py/']
start_urls = ['http://www.abc.com.py/buscar/?buscar=Santiago+Pe%C3%B1a'
'http://www.abc.com.py/buscar/?buscar=Santi+Pe%C3%B1a',
'http://www.abc.com.py/buscar/?buscar=santiago+pe%C3%B1a',
'http://www.abc.com.py/buscar/?buscar=santi+pe%C3%B1a']
rules = {
Rule(LinkExtractor(allow =(),canonicalize = True, unique =
True,restrict_xpaths=('//html/body/div/a[#id="load-more"]'))),
Rule(LinkExtractor(allow =(),canonicalize = True, unique =
True,restrict_xpaths=('//div[#class="article"]')),
callback = 'parse_item', follow=True)
}
def parse_item(self, response):
ml_item=Prueba1Item()
ml_item['article'] = response.xpath('normalize-space(//h1)').extract()
ml_item['fecha'] = response.xpath('normalize-
space(//small)').extract()
ml_item['contenido'] = response.xpath('normalize-
space(//p[#class="summary"])').extract()
ml_item['contenido2'] = response.xpath('normalize-
space(//div[#class="text"])').extract()
ml_item['url'] = response.xpath('normalize-
space(//link/#href)').extract()
ml_item['comentarioFacebook'] = response.xpath('normalize-
space(//div[#class="_30o4"]/span/span[#class="_5mdd"])').extract()
self .item_count += 1
if self.item_count > 50:
raise CloseSpider('item_exceeded')
yield ml_item
According to the search results I have more than 4000 results but I can not bring more than 50 with this code.
The contents are loaded dynamically using json in this format:
{
"titulo": "Tuma se suma a Marito",
"copete": "El diputado \u00d3scar Tuma oficializ\u00f3 su respaldo a la candidatura de Mario Abdo Ben\u00edtez a la presidencia, ya que sus reportes indicaron que el candidato de Colorado A\u00f1etet\u00e9 tiene mayor intenci\u00f3n de votos. El 100% de su dirigencia se lo pidi\u00f3, dice. ",
"publicacion": "09-11-2017 08:00",
"imagen": "2017\/10\/02\/el-diputado-scar-tuma-inscribio-ayer-las-precandidaturas-de-su-movimiento-tu-asuncion-en-la-junta-de-gobierno--200750000000-1634915.jpg",
"url": "nacionales\/tuma-se-suma-a-marito-1648202.html",
"autor": "",
"hits": "3163",
"comentarios": "1",
"corte_url": "https:\/\/s3-sa-east-1.amazonaws.com\/assets.abc.com.py\/2017\/10\/02\/_146_162_1542245.jpg",
"corte_width": 146,
"corte_height": 162,
"autor_nombre": null,
"autor_url": "http:\/\/www.abc.com.py\/autor\/-.html",
"total": "4861"
}
Therefore you can get the data in json format directly from the url below without using Xpath or css selector(try open this url in your browser):
http://www.abc.com.py/ajax.php?seccion=busqueda-avanzada&tipo=4&tipoplant=0&buscar=Santiago+Pe%C3%B1a&desde=&hasta=&seccion-noticia=&temas=&begin=0&limit=7&aditional=
I believe it's not difficult to modify the url to get the data you want and put them into your scripts, for example, get 10 items from the second item, just change begin to 2 and limit to 10:
http://www.abc.com.py/ajax.php?seccion=busqueda-avanzada&tipo=4&tipoplant=0&buscar=Santiago+Pe%C3%B1a&desde=&hasta=&seccion-noticia=&temas=&begin=2&limit=10&aditional=

XMLType with 238 characters fails

With Oracle.ManagedDataAccess 4.121.2.0 product version "4.121.2.20141216 ODAC RELEASE 3" and product version "4.121.2.20150926 ODAC RELEASE 4", the use of OracleXmlType with a value of 238 characters fails. If i use 239 or 237 characters it's work fine. At the beginning, i thinked that because i have a special character like ( or / but i replaced all characters by 'a' and i have the same issue and the error message is very strange (sorry for the french):
ORA-31011: Echec d'analyse XML ORA-19202: Une erreur s'est produite
lors du traitement la fonction XML ( LPX-00231: invalid character 47
('/') found in a Name or Nmtoken)
See below my unit test, used to reproduce the issue:
using(Oracle.ManagedDataAccess.Client.OracleConnection connection = new Oracle.ManagedDataAccess.Client.OracleConnection(myConnectionString))
{
connection.Open();
using(Oracle.ManagedDataAccess.Client.OracleTransaction transaction = connection.BeginTransaction())
{
try
{
Oracle.ManagedDataAccess.Client.OracleCommand command = new Oracle.ManagedDataAccess.Client.OracleCommand();
command.CommandText = "INSERT INTO MYTABLE(XML_VALUE) VALUES (:XML_VALUE)";
command.Connection = connection;
Oracle.ManagedDataAccess.Types.OracleXmlType xmlValue = new Oracle.ManagedDataAccess.Types.OracleXmlType(connection, "<root>aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa</root>");
using(Oracle.ManagedDataAccess.Client.OracleParameter parameter = new Oracle.ManagedDataAccess.Client.OracleParameter("XML_VALUE", Oracle.ManagedDataAccess.Client.OracleDbType.XmlType, xmlValue, ParameterDirection.Input))
{
command.Parameters.Add(parameter);
command.ExecuteNonQuery();
}
} finally {
transaction.Rollback();
}
}
}
And the script of table creation:
CREATE TABLE MYTABLE(XML_VALUE XMLTYPE NOT NULL)

symfony validation form doesn't call

I'm making a website with symfony2, and i have some troubles with form validaiton. It seems like method "isValid()" on my form is never called :
heres is my form creation :
public function createAction(Request $request)
{
$pro = new Professionnel();
$created=false;
$form = $this->createFormBuilder($pro)
->add("raison_sociale",null,array("label"=>"Raison sociale * : "))
->add("siret",null,array("label"=>"N° SIREN * : "))
->add("nom",null,array("label"=>"Nom *: "))
->add("prenom",null,array(
"label"=>"Prénom *: "
))
->add("adresse",null,array(
"required"=>false,
"label"=>"Adresse : "
))
->add("code_postal","text",array(
"required"=>false,
"label"=> "Code Postal : "
))
->add("ville",null,array(
"required"=>false,
"label"=> "Ville : "
))
->add("tel",null,array("label"=>"Téléphone * : ","required"=>true))
->add("mobile",null,array(
"required"=>false,
"label"=>"Mobile : "
))
->add("fax",null,array(
"required"=>false,
"label"=>"Fax : "
))
->add("email","email",array("label"=>"Email * : "))
->add("username",null,array("label"=>"Login * : "))
->add("password","password",array("label"=>"Mot de passe * : "))
->add("newsletter",null,array("required"=>false,"label"=>"Je souhaite m'inscrire à la newsletter"))
->add("accept","checkbox",array("label"=>" "))
->getForm()
;
if ($request->isMethod("POST"))
{
$form->bind($request);
if ($form->isValid())
{
$em=$this->getDoctrine()->getEntityManager();
$pro=$form->getData();
$encoder = $this->get('security.encoder_factory')->getEncoder($pro);
$pro->setPassword($encoder->encodePassword($pro->getPassword(),$pro->getSalt()));
$em->persist($pro);
$em->flush();
$created=true;
$this->get("session")->getFlashBag()->add("success", "Votre compte a bien été créé. Vous avez reçu un mail confirmant votre inscritpion.");
}
}
return $this->render('OverscanProfessionnelBundle:Front:create.html.twig',array('form'=>$form->createView(),'created'=>$created));
}
and here is my validatio.yml :
webapp\ProfessionnelBundle\Entity\Professionnel:
constraints:
Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity:
fields: email
message: "L'email est déjà pris"
Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity:
fields: username
message: "Ce login est déjà pris"
properties:
raison_sociale:
- Valid:
siret:
- Length:
min : 9
max : 9
minMessage: "Le SIREN doit contenir 9 caractères"
maxMessage: "Le SIREN doit contenir 9 caractères"
- Regex:
pattern: "/\d/"
match: true
message: "Le SIREN ne doit pas contenir de lettre"
tel:
- Length:
min : 10
max : 10
minMessage: "Le numéro de téléphone doit contenir 10 chiffres"
maxMessage: "Le numéro de téléphone doit contenir 10 chiffres"
so when i post my form no validation are called but constraints are !
Can someone help me please ?
Take a look at your "app/../config.yml"
You should see something like this :
framework:
...
validation: { enable_annotations: true }
Set it to :
framework:
...
validation: { enabled: true, enable_annotations: true }
And then, your validation.yml should be loaded !
Try adding the data class to your form like this:
$this->createFormBuilder($entity, array(
'data_class' => '\Vendor\YourBundle\Entity\MyEntity',
)
)
// -> add()

Resources