Error in ResponseExeption while populating FOSElasticaBundle/Symfony2
Asked Answered
F

2

6

I am trying to get FOSElasticaBundle to work. ElasticSearch Instance is running on localhost:9200 and responding.

I followed each step in the docs https://github.com/FriendsOfSymfony/FOSElasticaBundle/blob/master/Resources/doc/setup.md

but at the last step, I get this error in my console:

c:\xampp\htdocs\my\folder>php app/console fos:elastica:populate
Resetting app

Fatal error: Wrong parameters for Exception([string $exception [, long $code [,
Exception $previous = NULL]]]) in C:\xampp\htdocs\my\folder\vendor\rufli
n\elastica\lib\Elastica\Exception\ResponseException.php on line 34

[Symfony\Component\Debug\Exception\FatalErrorException]

Error: Wrong parameters for Exception([string $exception [, long $code [, Exception $previous = NULL]]])


fos:elastica:populate [--index[="..."]] [--type[="..."]] [--no-reset] [--offset="..."] [--sleep="..."] [--batch-size="..."] [--ignore-errors] [--no-overwrite-format]

It seems like there are 3 parameters mandatory for "__construct"-Function, but there are only 2 of them. I've simply tried to add "NULL"-parameter to get it work, but then another function throws an error.

public function __construct(Request $request, Response $response)
{
    $this->_request = $request;
    $this->_response = $response;
    parent::__construct($response->getError());
}

Is this a common problem? How do I solve it?

Freemon answered 20/10, 2015 at 6:24 Comment(6)
Possible duplicate of #21684888 (you must update your PHP version to 5.3)Shluh
My PHP-Version is 5.6.3Freemon
OK, you are right this is not a problem of PHP version. Looking at the code, the problem must be that $response->getError() does not return a string. I looked at the code and could not figure out why this could happen.Shluh
Did you find anything? Same problem here.Educated
I got this issue upgrading elasticsearch 1.7.3 to 2.0, this is not an issue with foselastica, but rather with ruflin/Elastica which is used by foselastica, I've moved the ticket there: github.com/ruflin/Elastica/issues/974Vulcan
-Anil- is right. This is not an issue with foselastica. There is a weird behaviour, but I got my server working. I did this with a dirty trick: Just add to the "__contruct" function -> "HttpKernelInterface $kernel,"Freemon
V
7

This is because the ruflin/Elastica package is not compatible with elasticsearch 2.0 yet.

https://github.com/ruflin/Elastica/issues/946

An alternative for now (until ruflin/Elastica is 2.0 upgraded), is to use the latest 1.x version.

You can download it here: https://www.elastic.co/downloads/past-releases/elasticsearch-1-7-3

ES 1.7.3 + FosElasticaBundle (which uses ruflin/Elastica) works fine with Elasticsearch 1.7.3 version.

Vulcan answered 9/11, 2015 at 15:8 Comment(1)
confirm resolved error above with this version: elastic.co/downloads/past-releases/elasticsearch-1-7-3 (thanks Anil!)Troth
E
4

The reason for this issue is, that with elasticsearch 2.0 the structure of the response error changed (more details here: https://github.com/ruflin/Elastica/issues/946). Instead of a string before it is now a nested array. Elastica is currently not yet fully compatible with elasticsearch 2.0. As soon as a new release of Elastica is out which is compatible with Elasticsearch 2.0 it will probably mean that also foselastica bundle will have to be updated as these changes will break backward compatibility. Be also aware, that this is not the only backward compatibility breaking change.

To follow the progress of the upgrade, follow this issue: https://github.com/ruflin/Elastica/issues/946

Endothermic answered 9/11, 2015 at 15:6 Comment(2)
Hi ruflin, after simply "killing" this error message, my application is working just fine. I don't see any more issues in my case. Best regards!Freemon
I also commented out the error construct and was able to move on successBroadnax

© 2022 - 2024 — McMap. All rights reserved.