I needed to include @RolesAllowed annotation into the project.
For that I’ve used the following IVY dependency:
<dependency org=”javax” name=”javaee-api” rev=”6.0″ conf=”compile->default”/>
This dependency basically provides interface to most of java ee components without implementation.
Hence, it is usually used to compile the project, because implementation is usually within the web container (eg. Tomcat).
However, the project used to fail with an error above whenever I ran ant test task.
Mock of HttpServletRequest object was failing. My guess is that reflection was trying to go deeper into actual implementation which dependency above does not provide.
It was even harder to spot, because IDE was running all tests just fine. Probably, because classes were loaded in a different order in IDE and in ANT.
JVM grabs whichever class is loaded first and ignores the next one, hence error did not show in IDE.
IDE was loading full implementation, while ANT was loading interface (dependency above) first.
Getting a smaller jar file that contains implementation of javax.annotation.security package helped solve the problem.
<dependency org=”javax.annotation” name=”jsr250-api” rev=”1.0″ conf=”compile->default”/>
Good times!