I'm using sprindoc-openapi-ui for spring boot API docs and facing the following issue:
Inlalid Character (?)
Follow bellow my configs
<!-- Spring Boot and Spring Core -->
<spring.pom.version>2.0.5.RELEASE</spring.pom.version>
<springVersion>5.0.9.RELEASE</springVersion>
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-ui</artifactId>
<version>1.6.9</version>
</dependency>
As you can see the accented characters are correct in the openapi response 3.0.1
"/siafic/tipo-diaria" : {
"post" : {
"tags" : [ "tipo-diaria" ],
"summary" : "Salva um tipo de diária",
"description" : "Este metodo deve ser invocado para armazenar um novo tipo de diária.",
"operationId" : "save",
...
}
application.properties
springdoc.writer-with-default-pretty-printer=true
springdoc.swagger-ui.path=/swagger-ui.html
springdoc.api-docs.path=/api-docs
springdoc.swagger-ui.display-request-duration=true
springdoc.swagger-ui.operations-sorter=method
springdoc.cache.disabled=true
Using java 8
Related
I'm using Spring Boot and would like to have this code:
LOG.info("Scheduled appointment for user 12345 [appointment ID 100]");
Produce the following log message in JSON GELF format:
{
"version": "1.1",
"host": "hostname.ec2.internal",
"short_message": "Scheduled appointment for user 12345 [appointment ID 100]",
"timestamp": 1318280136,
"level": 1,
"_user": "user#acme.com",
"_clientip": "127.0.0.1",
"_env": "prod",
"_app":"scheduler"
}
Do I need to create my own logger for this or can I customize Logback/Log4j2 to behave this way?
From a Log4j 2.x perspective, you can use the JSON Layout Template, which has a built-in eventTemplate for GELF.
Your appender configuration in the log4j2-spring.xml file would look like:
<Console name="CONSOLE">
<JsonTemplateLayout eventTemplateUri="classpath:GelfLayout.json" />
</Console>
Remark: Since Spring Boot uses Logback as default logging system, you'll have to exclude the spring-boot-starter-logging and replace it with spring-boot-starter-log4j2.
Moreover the JSON Layout Template requires an additional dependency:
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-layout-template-json</artifactId>
</dependency>
I am trying to fetch records from Elastic search and i get this error as below
ElasticsearchStatusException[Elasticsearch exception [type=exception, reason=SearchPhaseExecutionException[Failed to execute phase [query_fetch], all shards failed;
shardFailures {[-kDbP0fmTUa5B8v1gpgoZQ][dataintelindex_ra][0]: SearchParseException[[dataintelindex_ra]
[0]: from[-1],size[-1]: Parse Failure [Failed to parse source [{"query":{"geo_bounding_box":{"loc":
{"top_left":[-74.1,40.73],"bottom_right":
[-73.99,40.717]},"validation_method":"STRICT","type":"MEMORY","ignore_unmapped":false,"boost":1.0}}}]]];
nested: QueryParsingException[[dataintelindex_ra] No query registered for [geo_bounding_box]]; }]]]
My Java Code is as below
SearchRequest searchRequest = new SearchRequest("dataintelindex_ra").types("station_info");
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
searchSourceBuilder.query(QueryBuilders.geoBoundingBoxQuery("loc").setCorners(40.73,-74.1,40.717,-73.99));
searchRequest.source(searchSourceBuilder);
SearchResponse response = elasticSearchClient.search(searchRequest, RequestOptions.DEFAULT);
for (SearchHit searchHit : response.getHits().getHits()) {
System.out.println("~~~~~~~~SearchHit[] searchHits~~~~~~~~~~~~~~ "+searchHit.getSourceAsString());
}
Please let me know if i missed something while trying to index , i am new to Elastic search.
Also incase if i want to include one more criteria to my query like below
searchSourceBuilder.query(QueryBuilders.termsQuery("zoneType", ["test","oms"]));
Below is the result for the above query and it works fine
~~~~~~~~SearchHit[] searchHits~~~~~~~~~~~~~~ {"tag_datatype":"sensor","loc":[{"lat":"0","lon":"0"}],"level":1,"kml_path":"","created":"Mon Aug 10 16:02:51 IST 2020","latitude":"0","station_id":"5f312253b4c93c1d20bbbb39","longtitude":"0","tag_owner":"","description":"","zoneType":"oms","tag_network_name":"chak_network","display_name":"506020200236117-O1","supply_zone":"506020200236117-O1","outflow":null,"tag_sector":"dmameter","name":"506020200236117-O1","tag_category":"sensorstation","inflow":null,"_id":"5f312253b4c93c1d20bbbb39","tag_location":"NA","lastmod":"Mon Aug 10 16:02:51 IST 2020","status":"ACTIVE"}
~~~~~~~~SearchHit[] searchHits~~~~~~~~~~~~~~ {"tag_datatype":"sensor","loc":[{"lat":"0","lon":"0"}],"level":1,"kml_path":"","created":"Tue Aug 11 11:36:51 IST 2020","latitude":"0","station_id":"5f32357b3ccb8f51e003587e","longtitude":"0","tag_owner":"","description":"","zoneType":"village","display_name":"testvillage1","supply_zone":"testvillage1","outflow":null,"tag_sector":"dmameter","name":"testvillage1","tag_category":"sensorstation","inflow":null,"_id":"5f32357b3ccb8f51e003587e","tag_location":"NA","lastmod":"Tue Aug 11 11:36:51 IST 2020","status":"ACTIVE"}
how do i combine with above geoboundingbox query ? do i need to add it as a filter?
Update : Dependencies
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>transport</artifactId>
<version>6.4.0</version>
</dependency>
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>6.4.0</version>
</dependency>
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>elasticsearch-rest-client</artifactId>
<version>6.4.0</version>
</dependency>
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>elasticsearch-rest-high-level-client</artifactId>
<version>6.4.0</version>
</dependency>
{
"status" : 200,
"name" : "test1",
"version" : {
"number" : "1.2.2",
"build_hash" : "243243432feaga",
"build_timestamp" : "2014-07-09T12:02:32Z",
"build_snapshot" : false,
"lucene_version" : "4.8"
},
"tagline" : "You Know, for Search"
}
Thanks in advance
Rakesh
The problem is that you're running ES server v1.2.2 (extremely old version) with a 6.4.0 client.
So the 6.4.0 client has the geoBoundingBoxQuery() method, however the 1.2.2 client provides the geoBoundingBoxFilter() method, both are incompatible. There has been a big query/filter refactor in ES 2.x.
As a rule of thumb you should always run the same version of ES and the client library. In your case, you have a delta of several versions betweem your server and your client.
You should definitely consider upgrading your ES cluster to at least 6.4.0 or downgrade your client to 1.x.
I have upgraded Ext Direct from 1.3.2 to 1.8.0 and Spring Framework from 4.2.6.RELEASE to 5.1.7.RELEASE
After that actions in REMOTING_API becomes empty
Ext.app.REMOTING_API = {
"url" : "/ui/.../services/router",
"namespace" : "Ext....",
"type" : "remoting",
"actions" : { }
};
I'm stuck on this, any help will be appreciated.
Spring Data ES 3.2.0.M1 still uses old TransportClient instead of HighLevelRestClient
Spring Data ES 3.2.0.M1 supports High Level Rest Client, see Add support for Java High Level REST Client. I've added Spring Data ES 3.2.0.M1 to the SB2 app:
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-elasticsearch</artifactId>
<version>3.2.0.M1</version>
</dependency>
However, still TransportClient is used. There are two indication of that: exceptions on start-up:
o.e.transport.netty4.Netty4Transport : exception caught on transport layer [NettyTcpChannel{localAddress=/127.0.0.1:61171, remoteAddress=localhost/127.0.0.1:8085}], closing connection
io.netty.handler.codec.DecoderException: java.io.StreamCorruptedException: invalid internal transport message format, got (48,54,54,50)
at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:472) ~[netty-codec-4.1.33.Final.jar:4.1.33.Final]
and exception stacktrace when calling ElasticsearchTemplate:
at org.elasticsearch.client.transport.TransportClientNodesService.ensureNodesAreAvailable(TransportClientNodesService.java:349)
at org.elasticsearch.client.transport.TransportClientNodesService.execute(TransportClientNodesService.java:247)
at org.elasticsearch.client.transport.TransportProxyClient.execute(TransportProxyClient.java:60)
at org.elasticsearch.client.transport.TransportClient.doExecute(TransportClient.java:382)
at org.elasticsearch.client.support.AbstractClient.execute(AbstractClient.java:395)
at org.elasticsearch.client.support.AbstractClient.execute(AbstractClient.java:384)
at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:46)
at org.springframework.data.elasticsearch.core.ElasticsearchTemplate.getSearchResponse(ElasticsearchTemplate.java:947)
Are there any config param to tell Spring Data ES to switch to new High Level Rest Client? The docs say nothing about it.
P.S. Spring Data ES 3.2.0.M1 has 6.4.3 ES client version:
Caused by: java.io.StreamCorruptedException: invalid internal transport message format, got (48,54,54,50)
at org.elasticsearch.transport.TcpTransport.validateMessageHeader(TcpTransport.java:1327) ~[elasticsearch-6.4.3.jar:6.4.3]
at org.elasticsearch.transport.netty4.Netty4SizeHeaderFrameDecoder.decode(Netty4SizeHeaderFrameDecoder.java:36) ~[transport-netty4-client-6.4.3.jar:6.4.3]
at io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:502) ~[netty-codec-4.1.33.Final.jar:4.1.33.Final]
at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:441) ~[netty-codec-4.1.33.Final.jar:4.1.33.Final]
... 20 common frames omitted
back-end runs 6.4.2 version:
bash-4.4$ curl http://127.0.0.1:8085
{
"name" : "NA17WWR",
"cluster_name" : "494164851665",
"cluster_uuid" : "7t3LoK7PRp-ur6FyxSmHwQ",
"version" : {
"number" : "6.4.2",
"build_flavor" : "oss",
"build_type" : "zip",
"build_hash" : "04711c2",
"build_date" : "2018-10-16T09:16:35.059415Z",
"build_snapshot" : false,
"lucene_version" : "7.4.0",
"minimum_wire_compatibility_version" : "5.6.0",
"minimum_index_compatibility_version" : "5.0.0"
},
"tagline" : "You Know, for Search"
}
As mentioned in the issue you're referring to, the high level REST client is available in ElasticsearchRestTemplate (see PR #216) not in ElasticsearchTemplate, which they'll keep until ES 7 for backward compatibility reasons.
You can create one with the configuration below:
<bean name="elasticsearchTemplate"
class="org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate">
<constructor-arg name="client" ref="restClient"/>
</bean>
<elasticsearch:rest-client id="restClient"/>
I am using Apache Superset and trying to configure its OAuth2 capability to connect to my (custom) Spring-Security OAuth2 server. Unfortunately, it ain't working right now. The stack track begins with this.
15:09:16.584 [qtp1885996206-21] ERROR org.springframework.boot.web.support.ErrorPageFilter - Forwarding to error page from request [/oauth/authorize] due to exception [Could not resolve view with name 'forward:/oauth/confirm_access' in servlet with name 'dispatcherServlet'] javax.servlet.ServletException: Could not resolve view with name 'forward:/oauth/confirm_access' in servlet with name 'dispatcherServlet' at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1262) ~[spring-webmvc-4.3.8.RELEASE.jar:4.3.8.RELEASE] at
Here is the relevant portion of my config.py from Superset.
AUTH_TYPE = AUTH_OAUTH
OAUTH_PROVIDERS = [
{
"name" : "MY-OAUTH",
"icon" : APP_ICON,
"token_key" : "password",
"remote_app" : {
"consumer_key" : "my_dashboard",
"consumer_secret" : "my_secret",
"base_url" : "http://localhost:8088/myoauth",
"request_token_params" : {
"scope": "my_dashboard read write",
"grant_type" : "password"
},
"request_token_url" : None,
"access_token_url" : "http://localhost:8088/myoauth/oauth/token",
"access_token_params" : {
"scope": "my_dashboard read write",
"grant_type" : "password",
"response_type" : "authorization_code"
},
"access_token_method" : "POST",
"authorize_url" : "http://localhost:8088/myoauth/oauth/authorize"
}
}
]
A nice gentleman suggested that I have somehow disabled the servlet handler for /oauth/confirm_access, but I am not sure how to check on that or fix such a problem.
Do you know what is going on here, what I can do to fix this or where I can start looking?
Thanks,
Matt