Error when creating a template

I have a problem when I create a new template.
As I wrote in the previous post I must create a simple template whit a different tokenizer because the standard one delete some character that I need.

so I create this one:

"template": "apache_access-*",
"order": 1,
"settings": {
"number_of_shards": 3,
"number_of_replicas": 1
"analysis": {
"my_analyzer": {
"type": "custom",
"filter": "standard",
"tokenizer": "whitespace"
"mappings": {
"referer": {"type": "string"},
"request": {"type": "string"},
"auth": {"type": "string"},
"sslClient": {"type": "string"},
"type": {"type": "string"},
"path": {"type": "string"},
"pathFolder": {"type": "string"},
"sslProt": {"type": "string"},
"httpVersion": {"type": "string"},
"bSent": {"type": "long"},
"clientIP": {"type": "string"},
"@version": {"type": "string"},
"host": {"type": "string"},
"connection": {"type": "string"},
"uniqueID": {"type": "string"},
"timestamp": {"type": "string"},
"chiper": {"type": "string"},
"keepAlive": {"type": "long"},
"query": {"type": "string"},
"@timestamp": {
"format": "strict_date_optional_time||epoch_millis",
"type": "date"
"response": {"type": "long"},
"header": {"type": "string"},
"rBytes": {"type": "long"},
"bReceived": {"type": "long"},
"status": {"type": "string"}

Elasticsearch accept this template but when I try to check it using the command

-XGET localhost:9200/_template/?pretty=true

I receive back this error

"error" : {
"root_cause" : [ {
"type" : "class_cast_exception",
"reason" : "java.lang.String cannot be cast to java.util.Map"
} ],
"type" : "class_cast_exception",
"reason" : "java.lang.String cannot be cast to java.util.Map"
"status" : 500

When I remove it

curl -XDELETE localhost:9200/_template/apache

The _template command works again

Maybe, like always is a stupid question but i can't understand why this happen!

Can you create other Templates?

I would take out half or more of the mapping and create the template again. Then see if you can check it. If it works add more lines of code back in until it breaks.

Likewise if it breaks on the first test try another part until you isolate the offending code.

Possible that Java is not up to date?

Hi and thank you for your reply.

Yes, I have other template for other type of data and they work without any problems.
As you suggest I will try to create the template "step by step" adding a new element each time.

Java is update at last version, otherwise I suppose that I will receive back an error also for the other template.