I have a problem that the files from src/main/resources are not copied and included when i run tests.
I have a persistence.xml file, and I am using eclipse link. The persistence.xml file defines an in memory h2 database. I have a single test that attempts to access these entities. The problem is that no entities are registered with the entity manager.
Checking the build/classes/main directory, I don’t find the persistence.xml file, but it is included in the final jar. This causes my tests to fail.
This might be some simple problem with the classpath. You can try debugging it if you add a dummy test that just attempts to read this particular file from the classpath, e.g. classLoader.getResource()…
However, even though this is the case, my resource does not show up on the classpath and am therefore unable to load it from my task class using class.getResourceAsStream(…). I am trying to create a custom task that loads a file from the classpath and uses it to generate a configuration file. This sounds similar to the post at the beginning of this thread.
Ugh…typo on my part. Once I got the correct filename passed to getResourceAsStream, it worked. That doesn’t explain why my resource is showing up in build/classes/main if the belief is that it should be in a different subfolder under build. Any insight would be appreciated.
Seems the problem is as described in what you linked. Since persistence.xml doesn’t end up in build/classes, EclipseLink will not find the entity classes. What EclipseLink does, and I guess the JPA spec, is look for the classpath entry where persistence.xml is located, and search for classes from that root. So I need to put resouces into build/classes/main
I’ll close this one off as there is another issue raised about this particular proble . The end result will be that resources and classes will be by default in the same output directory in some manner.