File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Why is web.xml not prior to annotation in conflict? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Why is web.xml not prior to annotation in conflict?" Watch "Why is web.xml not prior to annotation in conflict?" New topic
Author

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

Leon Omk
Ranch Hand

Joined: Aug 17, 2010
Posts: 75





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?


OK, so that other guy knows Java better than I do, but I bet he can't speak Wuhanese(a Chinese Dialect) like me.
abani patra
Ranch Hand

Joined: Oct 11, 2011
Posts: 70
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

Joined: Aug 17, 2010
Posts: 75



This is the annotation for servletTwo.

Kumaravadivel Subramani
Ranch Hand

Joined: Jul 05, 2008
Posts: 166

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.


No pain, No gain.
OCJP 1.6
Hebert Coelho
Ranch Hand

Joined: Jul 14, 2010
Posts: 754

Is your class in the default package?


[uaiHebert.com] [Full WebApplication JSF EJB JPA JAAS with source code to download] One Table Per SubClass [Web/JSF]
Leon Omk
Ranch Hand

Joined: Aug 17, 2010
Posts: 75

Hebert Coelho wrote:Is your class in the default package?


Yes, all servlets are in default package.
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3849

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...


SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Why is web.xml not prior to annotation in conflict?