cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Error mapping field: java.util.MissingFormatArgumentException: Format specifier '%s'

Hi all,
I´m using java and SDN6
I have and endpoint that return a list of "Feed"
3X_2_2_228a0ced311a80046b5df98b79a35d1287543487.png
the query cypher return this:

3X_8_9_89cff7d6f95bcbba522d39ca79e7ac1c1fda192c.png

and I have to map this field "v" into Feed.java

Feed.java
3X_9_0_90ac010bfca88ee3b1a78a663f83acb4ec3ff47c.png

when I map the v as listaProp y get this error:

ERROR 46684 --- [nio-8080-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.util.MissingFormatArgumentException: Format specifier '%s'] with root cause

java.util.MissingFormatArgumentException: Format specifier '%s'
	at java.base/java.util.Formatter.format(Formatter.java:2672) ~[na:na]
	at java.base/java.util.Formatter.format(Formatter.java:2609) ~[na:na]
	at java.base/java.lang.String.format(String.java:2897) ~[na:na]
	at org.springframework.data.neo4j.repository.query.DtoInstantiatingConverter.lambda$getPropertyValueFor$2(DtoInstantiatingConverter.java:134) ~[spring-data-neo4j-6.0.5.jar:6.0.5]
	at org.springframework.core.log.LogMessage$SupplierMessage.buildString(LogMessage.java:155) ~[spring-core-5.3.4.jar:5.3.4]
	at org.springframework.core.log.LogMessage.toString(LogMessage.java:70) ~[spring-core-5.3.4.jar:5.3.4]
	at java.base/java.lang.String.valueOf(String.java:2951) ~[na:na]

Thanks in advance!
Regards

4 REPLIES 4

You cannot just tell SDN to map arbitrary information into a map.
So there are a few things in here that need more information.

  1. What is a Feed? It seems not to be a defined entity.
  2. What kind of repository is involved?
  3. Are you using custom queries in the repository?

The problem itself seems to be a smaller bug on our side to not populate the warning message correctly but in the end, it will produce what it says: null for the field.

Hi Gerry. Thanks for your response.
Feed.java is not a node, is a class made for result only and I need to use custom queries
I need a non-domain result so I'm going to do it this way:
Spring Data Neo4j.
I only need no return the field "v" from a cypher query to an endpoint that return a json.

It´s the only way to do it, right?

Do you have any link where I have a small complete example of this?
Thanks a lot

at the end I use:
(sevice.java)

public Collection<ResultFeed> findListaPropFeed(String email) {
	 return this.neo4jClient
			.query("match p=(u:User {eMail:$email})-[:INTERESADO_EN]->(:Concept)<-[:RELACIONADO_CON]-(e)\r\n"
					+ "call apoc.case([labels(e)[0]='Lex', 'RETURN labels(e)[0] as label, e.id as id, e.titulo as titulo, e.fechaDisposicion_txt as fecha, \"BOE/EURLEX\" as fuente'\r\n"
					+ "               ,labels(e)[0]='New', 'RETURN labels(e)[0] as label, e.id as id, e.titulo as titulo, e.fecha_txt as fecha, \"EFSA\" as fuente' \r\n"
					+ "               ,labels(e)[0]='Alert', 'RETURN labels(e)[0] as label, e.id as id, e.sustanciaPeligro as titulo, e.fechaNotificacion_txt as fecha, \"RASFF\" as fuente' \r\n"
					+ "               ,labels(e)[0]='Science', 'RETURN labels(e)[0] as label, e.id as id, e.titulo as titulo, e.fecha_txt as fecha, \"EFSA\" as fuente' \r\n"
					+ "               ],\r\n"
					+ "               'RETURN \"error\" as label, \"error\" as id, \"error\" as titulo, \"error\" as fecha, \"error\" as fuente',{e:e}) yield value as v\r\n"
					+ "return u.eMail as email, v as listaProp, length(p) as score limit 5\r\n"
					+ "union\r\n"
					+ "match p=(u:User {eMail:$email})-[:INTERESADO_EN]->(:Concept)-[:broader*..3]-(:Concept)<-[:RELACIONADO_CON]-(e)\r\n"
					+ "call apoc.case([labels(e)[0]='Lex', 'RETURN labels(e)[0] as label, e.id as id, e.titulo as titulo, e.fechaDisposicion_txt as fecha, \"BOE/EURLEX\" as fuente'\r\n"
					+ "               ,labels(e)[0]='New', 'RETURN labels(e)[0] as label, e.id as id, e.titulo as titulo, e.fecha_txt as fecha, \"EFSA\" as fuente' \r\n"
					+ "               ,labels(e)[0]='Alert', 'RETURN labels(e)[0] as label, e.id as id, e.sustanciaPeligro as titulo, e.fechaNotificacion_txt as fecha, \"RASFF\" as fuente' \r\n"
					+ "               ,labels(e)[0]='Science', 'RETURN labels(e)[0] as label, e.id as id, e.titulo as titulo, e.fecha_txt as fecha, \"EFSA\" as fuente' \r\n"
					+ "               ],\r\n"
					+ "               'RETURN \"error\" as label, \"error\" as id, \"error\" as titulo, \"error\" as fecha, \"error\" as fuente',{e:e}) yield value as v\r\n"
					+ "return u.eMail as email, v as listaProp, length(p) as score order by score asc limit 5")
			.in(database())
			.bind(email).to("email")
			.fetchAs(ResultFeed.class)
			.mappedBy((typeSystem, record) -> new ResultFeed(record.get("listaProp").asObject())) 
			.all();	
}

(xxController.java)
@GetMapping(value="/feedinicial", produces = MediaType.APPLICATION_JSON_VALUE)
Collection findListaPropFeed(@RequestParam("email") String email) {
return conceptService.findListaPropFeed(email);
}

Thanks, regards

So you are now good with using the Neo4jClient?
This would also be the alternative that I would have advised you to use. The Cypher statement that picks "random" data that cannot really mapped to a domain entity is a good candidate to go this way.
The abstraction levels above (Neo4jTemplate and Neo4jRepository) do their mapping work on top of the metadata you are providing for entities that represent real nodes in the graph.

Nodes 2022
Nodes
NODES 2022, Neo4j Online Education Summit

All the sessions of the conference are now available online