Can't find resources in annotation processor

I have two subprojects in my gradle project. The first (A) with my actual code and the second (B) with code for a annotation processor. When building A and using the annotation processor from B the resources are not found by the classloader. When running javac using the annotation processor it is found. The resource is in the B’s artifact.
This error appears occasionally, so not in every time. But when it happens I can’t get gradle to get out of this state and I have to restart the daemon to get it to work again.