File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Why is web.xml not prior to annotation in conflict?

 
Leon Omk
Ranch Hand
Posts: 75
Chrome Eclipse IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator




Running in Tomcat 7.x, I type http://localhost/MyApp/ServletOne, then ServletOne is invoked. Why not ServletTwo?


i. Configuration specified in the main web.xml or a web fragment takes
precedence over the configuration specified via annotations.



In the servlet3.0 spec page 103, doesn't it mean web.xml is prior to annotation when there is conflict? Is it a bug for Tomcat?
 
abani patra
Ranch Hand
Posts: 70
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I do not have much idea still I think the ServletTwo url pattern is overriding the pattern so it is being called.
 
Leon Omk
Ranch Hand
Posts: 75
Chrome Eclipse IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


This is the annotation for servletTwo.

 
Kumaravadivel Subramani
Ranch Hand
Posts: 171
Java Linux Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Can you please provide your full view of web.xml file? Since no url-pattern is defined for ServletTwo, web container can't initiate/process this. Also you can provide us the log file to proceed further.
 
Hebert Coelho
Ranch Hand
Posts: 754
Eclipse IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is your class in the default package?
 
Leon Omk
Ranch Hand
Posts: 75
Chrome Eclipse IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hebert Coelho wrote:Is your class in the default package?


Yes, all servlets are in default package.
 
Vijitha Kumara
Bartender
Posts: 3908
9
Chrome Fedora Hibernate
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, all servlets are in default package.

don't do that, you'll run in to trouble if you do so. Use packages and see still the issue exists...
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic