Sorry Anirudh -- I didn't read far enough in to your code.
I think what is happening in this case is that since the implementation cannot find a handler for OPTIONS, that is generating an default automatic response, which is returns a 200. Your method in the Resource2 class is not being called. You should be able to confirm this by checking the console to see if shows your Resource2 options message or not.
I was hoping, some one could throw some light from a holistic point of view on this particular behavior with JAX-RS, Jersey2.4, JDK1.7, and the URI mismatch scenario posed.
1. How is HTTP supposed to work?
2. How a Java based HTTP container(eg. Tomcat) expected to behave under the circumstances?
3. What does the JAX-RS spec say about it, and
4. Is there some anomaly (specified or unspecified) by the Jersey reference implementation?
I would be grateful for the information/answers to the questions posed above or even a re-direction to any literature/blog/online learning tutorial etc.
You might want to read the JAX-RS: Java™ API for RESTful Web Services documentation for answers on how it is supposed to work. What you are asking about is detailed in sections 3.4 and 3.7. The default behaviour for HEAD and OPTIONS is explained in 3.3.5.
Jersey 2.x claims to be fully compliant to JSR 339.