psylo66
psylo66

Reputation: 628

JMS\Serializer\Exception\RuntimeException: Resources are not supported in serialized data. Path: Monolog\Handler\StreamHandler -> etc

I'm working with Symfony 4 and i have installed JMS serializer with FOSRest bundle.

So every time i've got an error i've got this message :

JMS\Serializer\Exception\RuntimeException: Resources are not supported in serialized data. Path: Monolog\Handler\StreamHandler -> Symfony\Bridge\Monolog\Logger -> Symfony\Component\Cache\Adapter\PhpFilesAdapter -> Symfony\Component\Cache\Adapter\TraceableAdapter -> Symfony\Component\Cache\Adapter\PhpArrayAdapter -> Symfony\Component\Cache\DoctrineProvider -> Doctrine\Common\Annotations\CachedReader -> Sensio\Bundle\FrameworkExtraBundle\EventListener\ControllerListener -> Symfony\Component\EventDispatcher\EventDispatcher -> Symfony\Component\HttpKernel\Debug\TraceableEventDispatcher -> ContainerYCXy4ht\srcTestDebugProjectContainer -> FOS\RestBundle\Request\ParamFetcher -> Symfony\Component\HttpFoundation\ParameterBag -> Symfony\Component\HttpFoundation\Request -> Symfony\Component\HttpKernel\Exception\HttpException

And after the real error and i dont understand why ? I use JMS contrib recipe :

/packages/dev/jms_serializer.yaml

jms_serializer:
visitors:
    json:
        options:
            - JSON_PRETTY_PRINT
            - JSON_UNESCAPED_SLASHES
            - JSON_PRESERVE_ZERO_FRACTION

/packages/prod/jms_serializer.yaml

jms_serializer:
visitors:
    json:
        options:
            - JSON_UNESCAPED_SLASHES
            - JSON_PRESERVE_ZERO_FRACTION

/packages/jms_serializer

jms_serializer:
visitors:
    xml:
        format_output: '%kernel.debug%'

So i don't understand why this behavior ? If someone could help me ? Thanks by advance

Upvotes: 0

Views: 680

Answers (1)

psylo66
psylo66

Reputation: 628

I found the solution it was an fos_rest configuration error

Before

fos_rest:
exception:
    enabled: true
    exception_controller: 'fos_rest.exception.controller:showAction'
param_fetcher_listener: force
body_listener: true
format_listener:
    enabled: true
    rules:
        - { path: '^/api', priorities: ['json'], prefer_extension: true}
        - { path: '^/', priorities: [ 'html', '*/*'], fallback_format: html, prefer_extension: true }
view:
    view_response_listener: 'force'

After

fos_rest:
param_fetcher_listener: force
format_listener:
    enabled: true
    rules:
        - { path: '^/api', priorities: ['json'], prefer_extension: true}
        - { path: '^/', priorities: [ 'html', '*/*'], fallback_format: html, prefer_extension: true }
view:
    view_response_listener: 'force'

Upvotes: 0

Related Questions