# Receiving java.lang.IllegalArgumentException: Failed to derive xcontent while using @Query annotiation

**URL:** <https://discuss.elastic.co/t/receiving-java-lang-illegalargumentexception-failed-to-derive-xcontent-while-using-query-annotiation/194965>\
**Category:** Elasticsearch\
**Created:** [August 13, 2019, 6:47am UTC](https://discuss.elastic.co/t/receiving-java-lang-illegalargumentexception-failed-to-derive-xcontent-while-using-query-annotiation/194965 "2019-08-13T06:47:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kbsivacse](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kbsivacse/32/52172_2.png) [@kbsivacse](https://discuss.elastic.co/u/kbsivacse)\
**Post date:** [August 13, 2019, 6:47am UTC](https://discuss.elastic.co/t/receiving-java-lang-illegalargumentexception-failed-to-derive-xcontent-while-using-query-annotiation/194965/1 "2019-08-13T06:47:24Z")

</div>

I'm using below library for my spring-boot app and I'm getting below error while running the query in my Spring repository,

@Query(""\_source": {"includes": ["Id","appOwner","empId","status","salary","indicator","createdTimestamp","remarks"]},"query" : {"bool" : {"must" : {"match" : {"appOwner" : ?0}}]}}")

pom.xml

* * *

spring-boot-parent -\> 2.1.0.RELEASE  
spring-data-elasticsearch  
spring-data-commons

Exception

* * *

java.lang.IllegalArgumentException: Failed to derive xcontent  
at org.elasticsearch.common.xcontent.XContentFactory.xContent(XContentFactory.java:216)  
at org.elasticsearch.common.xcontent.XContentFactory.xContent(XContentFactory.java:203)  
at org.elasticsearch.index.query.WrapperQueryBuilder.doRewrite(WrapperQueryBuilder.java:162)  
at org.elasticsearch.index.query.AbstractQueryBuilder.rewrite(AbstractQueryBuilder.java:269)  
at org.elasticsearch.search.builder.SearchSourceBuilder.rewrite(SearchSourceBuilder.java:888)  
at org.elasticsearch.search.builder.SearchSourceBuilder.rewrite(SearchSourceBuilder.java:79)  
at org.elasticsearch.index.query.Rewriteable.rewriteAndFetch(Rewriteable.java:96)  
at org.elasticsearch.index.query.Rewriteable.rewriteAndFetch(Rewriteable.java:86)  
at org.elasticsearch.action.search.TransportSearchAction.doExecute(TransportSearchAction.java:215)  
at org.elasticsearch.action.search.TransportSearchAction.doExecute(TransportSearchAction.java:68)  
at org.elasticsearch.action.support.TransportAction$RequestFilterChain.proceed(TransportAction.java:167)  
at org.elasticsearch.xpack.security.action.filter.SecurityActionFilter.apply(SecurityActionFilter.java:128)  
at org.elasticsearch.action.support.TransportAction$RequestFilterChain.proceed(TransportAction.java:165)  
at org.elasticsearch.action.support.TransportAction.execute(TransportAction.java:139)  
at org.elasticsearch.action.support.HandledTransportAction$TransportHandler.messageReceived(HandledTransportAction.java:79)  
at org.elasticsearch.action.support.HandledTransportAction$TransportHandler.messageReceived(HandledTransportAction.java:69)  
at org.elasticsearch.xpack.security.transport.SecurityServerTransportInterceptor$ProfileSecuredRequestHandler$1.doRun(SecurityServerTransportInterceptor.java:259)  
at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37)  
at org.elasticsearch.xpack.security.transport.SecurityServerTransportInterceptor$ProfileSecuredRequestHandler.messageReceived(SecurityServerTransportInterceptor.java:317)  
at org.elasticsearch.transport.RequestHandlerRegistry.processMessageReceived(RequestHandlerRegistry.java:66)  
at org.elasticsearch.transport.TcpTransport$RequestHandler.doRun(TcpTransport.java:1592)  
at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37)  
at org.elasticsearch.common.util.concurrent.EsExecutors$1.execute(EsExecutors.java:135)  
at org.elasticsearch.transport.TcpTransport.handleRequest(TcpTransport.java:1550)  
at org.elasticsearch.transport.TcpTransport.messageReceived(TcpTransport.java:1414)  
at org.elasticsearch.transport.netty4.Netty4MessageChannelHandler.channelRead(Netty4MessageChannelHandler.java:64)  
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)  
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)  
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)  
at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:310)  
at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:297)  
at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:413)  
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:265)  
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)  
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)  
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)  
at io.netty.handler.logging.LoggingHandler.channelRead(LoggingHandler.java:241)  
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)  
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)  
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)  
at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1359)  
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)  
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)  
at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:935)  
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:134)  
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:645)  
at io.netty.channel.nio.NioEventLoop.processSelectedKeysPlain(NioEventLoop.java:545)  
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:499)  
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:459)  
at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:858)  
at java.lang.Thread.run(Thread.java:748)

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [August 13, 2019, 7:12am UTC](https://discuss.elastic.co/t/receiving-java-lang-illegalargumentexception-failed-to-derive-xcontent-while-using-query-annotiation/194965/2 "2019-08-13T07:12:00Z")

</div>

Please format your code, logs or configuration files using `</>` icon as explained in [this guide](https://discuss.elastic.co/t/about-the-elasticsearch-category/21) and not the citation button. It will make your post more readable.

Or use markdown style like:

````
```
CODE
```

````

This is the icon to use if you are not using markdown format:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/7/e/7e6e239431ec2d71cbf1beef741f2e93e7cc762c.jpg)

There's a live preview panel for exactly this reasons.

Lots of people read these forums, and many of them will simply skip over a post that is difficult to read, because it's just too large an investment of their time to try and follow a wall of badly formatted text.  
If your goal is to get an answer to your questions, it's in your interest to make it as easy to read and understand as possible.  
Please update your post.

Is there a way to debug what is actually sent as json to elasticsearch?  
I wonder if `?0` is correctly transformed.

BTW when using springboot with  
elasticsearch, you need to be explicit with some transitive dependencies as SpringBoot declares a version 6.4...

Basically you can put this in your `pom.xml`:

```auto
<properties>
  <elasticsearch.version>7.0.0<elasticsearch.version>
</properties>

```

See documentation here: [https://docs.spring.io/spring-boot/docs/current/reference/html/howto-build.html#howto-customize-dependency-versions](https://docs.spring.io/spring-boot/docs/current/reference/html/howto-build.html#howto-customize-dependency-versions)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [September 10, 2019, 7:12am UTC](https://discuss.elastic.co/t/receiving-java-lang-illegalargumentexception-failed-to-derive-xcontent-while-using-query-annotiation/194965/3 "2019-09-10T07:12:02Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
