Categories
BLOG

auto loaded

Annotation does not exist, or could not be auto-loaded. #855

Comments

Copy link Quote reply

rafa-acioly commented Jan 16, 2018

Q A
Bug report? yes
Feature request? no
BC Break report? no
RFC? no

I’m trying to use the Type class but always get the error:

The annotation “@jms\Serializer\Annotation\Type” in property App\Product::$sellersku does not exist, or could not be auto-loaded.’

I’ve declare que use statement and used the example from http://jmsyst.com/libs/serializer/master/reference/annotations

the deserialize method:

the product class:

goetas commented Jan 16, 2018

rafa-acioly commented Jan 16, 2018

@goetas thank you, but everything is null on the object! 🤣

goetas commented Jan 16, 2018

you need an object Request that contains a property Product

rafa-acioly commented Jan 16, 2018

even if i remove the request knot the result from serialize is:

goetas commented Jan 16, 2018

pay attention that by default the serializer uses snake_case . you have to specify @SerializedName for for each prop (or to enable “identical name naming strategy”)

  • © 2020 GitHub, Inc.
  • Terms
  • Privacy
  • Cookie Preferences
  • Security
  • Status
  • Help
  • Contact GitHub
  • Pricing
  • API
  • Training
  • Blog
  • About

You can’t perform that action at this time.

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.

Q A Bug report? yes Feature request? no BC Break report? no RFC? no I'm trying to use the Type class but always get the error: The annotation "@jms\Serializer\Annotation\Type" in property App\Product::$sellersku does not exist, or could …

[Serializer] The annotation does not exist, or could not be auto-loaded. #36263

Comments

Copy link Quote reply

Sengorius commented Mar 30, 2020

Symfony version(s) affected: I am working with 4.4.6

Description
Same problem as described in #1402. I have tried the ideas mentioned in this issue.

The configuration:

The Code:

The error message:

Additional context

But: It works if the cache is empty! Deleting the whole cache directory lets the code just work fine ( php bin/console cache:clear is not enough). Reloading the page then fails with the error every time.

blowski commented Mar 30, 2020

What do you get when you run the following on the command line?

Sengorius commented Mar 30, 2020

So, as I am working with Docker Containers, the cache is moved away from the project folder into the docker container. This speeds up the access time when running the project locally.

It’s done via Kernel.php :

The directory looks like this:

blowski commented Mar 30, 2020

Ah, I’m guessing there’s a bug in your getCacheDir() method. Try setting that to a fixed value (i.e. no conditionals in there) and see what happens then.

As a side-note, I’ve run into the same performance problems as you with the cache. Instead of moving the cache folder, I use Docker’s cached volume directive – https://docs.docker.com/compose/compose-file/#caching-options-for-volume-mounts-docker-for-mac.

Sengorius commented Mar 30, 2020 •

Hmm, but it worked pretty well until today. Good, I’ve tried the following:

  • reset the getCacheDir() to it’s default
  • restarted the Docker environment
  • first try went well and was executed as expected, as there was no cache
  • after reloading I got the same issue
  • then used chown -R www-data:www-data var/cache/ to fix access issue (if any)
  • still the same issue
  • removed the cache with rm -rf var/cache/dev/* (from project directory)
  • first try went well and was executed as expected
  • next try brought the same issue, again

From my point of view, not a problem with Docker.

blowski commented Mar 30, 2020

I’ve run into similar issues, where the CLI is warming the cache in one place and the FPM is trying to load it from another. I can’t say that’s definitely what’s happening here, but it at least has similar symptoms. That’s why I thought relying on Symfony’s getCacheDir() method would fix the problem, so I’m really surprised there.

Just for a sanity check, the vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Column.php is definitely there?

Sengorius commented Mar 30, 2020

Well, I never ran into the cache warming case, as with the getCacheDir() controlled from the .env , it rests at the same place as long as the container is running.

PS: Thanks for the hint with the Caching Options in Docker, but I’m using Linux 😉

blowski commented Mar 30, 2020

When you run the CLI app, do you know if your shell is parsing the .env file and loading the values as environment variables? Have you done anything recently like changed to ZSH or Fish?

Sengorius commented Mar 30, 2020

The .env is just included via docker-compose.yml and loaded with the symfony/dotenv component internally. There is only sh and bash within the container.

But it seems, you partially have a point here. Symfony profiler says, anything is defined as regular env variables.

But does this matter?

blowski commented Mar 30, 2020

Where do you run the the Symfony CLI – on your host system, or in the Docker container?

Sengorius commented Mar 31, 2020

What Symfony CLI do you mean? I’m running a pretty simple docker-compose setup:

Okay, so I stopped my Docker environment and just php -S localhost:8080 -t public/ from the projects directory. Worked fine the first time, then I got the same issue again.

blowski commented Mar 31, 2020

Are you running the PHP commands inside the container, or on the host?

Sengorius commented Mar 31, 2020

The php -S localhost:8080 -t public/ was executed directly on my host Linux, nothing else was used.

In the docker-compose setup, PHP-FPM is used without any configuration or addition commands. Just as you find the image on https://hub.docker.com/_/php.

blowski commented Mar 31, 2020

I wonder if the mix of Docker and native means Symfony is getting confused about where to look for the cache. When using Docker’s FPM it’s looking in the /tmp/ directory on the container, but when it’s running directly on the host then it’s looking in the host system’s /tmp/ directory.

You could have a look in the /tmp directories in both environments to check.

Perhaps try running everything from the host system, without having Docker running. (Or the other way round, do everything through Docker and stop PHP on the host system.)

Sengorius commented Mar 31, 2020

I wonder if the mix of Docker and native means Symfony is getting confused about where to look for the cache.

But I already tested with and without Docker. Just running a PHP server with no other dependencies or configurations.

Perhaps try running everything from the host system, without having Docker running.

That’s what I did with php -S localhost:8080 -t public/ from my host Linux.

I have tested the Symfony project with production environment and php -S localhost:8080 -t public/ , again. Got a “500 Internal Server Error” on the front page and following logs:

Can we stop discussing about Docker? I dont think, we will find the problem within its configuration or my setup, as the problem appears event with php only. Any other component is working fine, productive or in develop mode; Docker or not Docker. I have also used the caching myself several times. All went well, independent from the cachin adapter.

Symfony version(s) affected: I am working with 4.4.6 Description Same problem as described in #1402. I have tried the ideas mentioned in this issue. The configuration: # config/packages/framework.yaml framework: secret: '%env(APP_SECRET)…