This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 223563 - New Hint: duplicate Servlet name
Summary: New Hint: duplicate Servlet name
Status: RESOLVED WONTFIX
Alias: None
Product: javaee
Classification: Unclassified
Component: Servlet (show other bugs)
Version: 7.3
Hardware: PC Windows 7
: P3 normal (vote)
Assignee: issues@javaee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-12-10 01:27 UTC by ecerichter
Modified: 2016-07-07 08:54 UTC (History)
2 users (show)

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description ecerichter 2012-12-10 01:27:26 UTC
Product Version = NetBeans IDE Dev (Build 201212080001)
Operating System = Windows 7 version 6.1 running on amd64
Java; VM; Vendor = 1.7.0_09
Runtime = Java HotSpot(TM) 64-Bit Server VM 23.5-b02

Is very difficult for a programmer to know that there are two servlets with same name in the context - what happens, is "error 404: page not found" in browser, even if ULR is correct.
When two servlets have annotation "@WebServlet(name = "xxx", ...) with same name, then a Hint should alert user that he is in violation of Servlet specification.

Regards,

Edson.
Comment 1 Martin Fousek 2012-12-10 08:15:03 UTC
That looks like really useful tip for the hint. Thanks for reporting such enhancement.
Comment 2 David Konecny 2012-12-10 18:47:42 UTC
(In reply to comment #0)
> what happens, is "error 404: page not found" in
> browser, even if ULR is correct.

What server do you use? I tried this on GlassFish 3.x and it runs (randomly?) one of the servlets and logs error in its output log about the other servlet class. Your server should not respond with "404" - that's an error on the server side. It should either run one of the servlets or report this problem during application deployment.

The IDE hint warning user about this issue makes sense.
Comment 3 ecerichter 2012-12-10 19:12:26 UTC
(In reply to comment #2)
> (In reply to comment #0)
> > what happens, is "error 404: page not found" in
> > browser, even if ULR is correct.
> 
> What server do you use? I tried this on GlassFish 3.x and it runs (randomly?)
> one of the servlets and logs error in its output log about the other servlet
> class. Your server should not respond with "404" - that's an error on the
> server side. It should either run one of the servlets or report this problem
> during application deployment.
> 
> The IDE hint warning user about this issue makes sense.

I'm using Apache Tomcat 7.0.32.
I think either run random servlet or gives 404 error are servers bug.
You are completely right, both servers should give an error during deployment.
I'll file a bug report against Apache Tomcat.
Comment 4 ecerichter 2012-12-10 21:54:31 UTC
Ok, now I understand Tomcat behavior (that is much better than random choice):

a) First servlet is loaded with the name X and url Y
b) Second servlet is loaded with the name X and url Z, that replaces the first servlet.

What happens is that I can always use url Z, but never url Y.
Comment 5 David Konecny 2012-12-10 22:29:44 UTC
Which servlet gets loaded first and which second is unspecified and can change in different server releases and so it is still "random".
Comment 6 ecerichter 2013-01-08 13:04:07 UTC
I've analyzed this further:

1) If working with web.xml, then the order is the order defined in XML file.
2) If working with annotations, order is unpredictable unless specified a loading order. In that case, the last loaded has precedence.


I've created a ticket at Tomcat for this issue:

https://issues.apache.org/bugzilla/show_bug.cgi?id=54387

Since I would not be able to open a ticket for every application server in the world, would be nice to have the hint in the IDE as agreed.

Thanks,

Edson
Comment 7 ecerichter 2013-01-16 21:08:21 UTC
This has been fixed in Tomcat 7.0.35.

They asked to Servlet specs team to clarify the correct behavior: container should forbid deployment if two or more servlets have same URL.

Bug tracking in Tomcat: https://issues.apache.org/bugzilla/show_bug.cgi?id=54387
Bug tracking from experts: http://java.net/jira/browse/SERVLET_SPEC-53

I think someone should warn Glassfish developers about it.

Regards,

Edson
Comment 8 Martin Fousek 2013-01-17 06:59:33 UTC
(In reply to comment #7)
> I think someone should warn Glassfish developers about it.

Thanks for providing all links. I entered issue against GlassFish and provided there links to issues you entered:
http://java.net/jira/browse/GLASSFISH-19547
Comment 9 Martin Fousek 2013-01-23 06:28:37 UTC
(In reply to comment #8)
> http://java.net/jira/browse/GLASSFISH-19547

According to the GF issue, the warning is already in place since GF 3.1.2.
Comment 10 ecerichter 2013-01-23 10:18:37 UTC
(In reply to comment #9)
> (In reply to comment #8)
> > http://java.net/jira/browse/GLASSFISH-19547
> 
> According to the GF issue, the warning is already in place since GF 3.1.2.

Good - but the EG explains that the container should not deploy the app in such case. It is an error that prevents the correct execution of the application.

Nevertheless, it is Glassfish team decision if they will follow or not the EG guidelines. I'm jusr warning.

Regards,

Edson Richter
Comment 11 Martin Fousek 2013-01-23 10:44:37 UTC
(In reply to comment #10)
> Good - but the EG explains that the container should not deploy the app in such
> case. It is an error that prevents the correct execution of the application.

Sorry, I didn't expressed correctly before. The GF not just warns but it doesn't deploy the app and fails with following error:
SEVERE: Exception while deploying the app [WebApplication280]
SEVERE: Exception during lifecycle processing
java.lang.IllegalArgumentException: Servlet [NewServlet] and Servlet [NewServlet2] have the same url pattern: [/NewServlet]
Comment 12 Martin Balin 2016-07-07 08:54:47 UTC
This old bug may not be relevant anymore. If you can still reproduce it in 8.2 development builds please reopen this issue.

Thanks for your cooperation,
NetBeans IDE 8.2 Release Boss