About Question enthuware.jwpv6.2.570 :

Moderator: admin

Post Reply
ETS User

About Question enthuware.jwpv6.2.570 :

Post by ETS User »

It is not specified anywhere that the DefaultServlet is correctly mapped in the web.xml and that web.xml has a metadata-complete atrribute set?

admin
Site Admin
Posts: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.jwpv6.2.570 :

Post by admin »

Hello,
The general rule here is that you should assume that everything that has no bearing on the question is valid unless explicitly specified in the question. For example, it is not given in the question that there are no compilation errors, or that the given code is present in the right place, and so on. But you assume that all such things are ok because those are not really relevant to the question.

In this case, all the information that is required to answer the question is given.

HTH,
Paul.
If you like our products and services, please help us by posting your review here.

renatumb
Posts: 47
Joined: Mon Apr 08, 2013 7:55 pm
Contact:

Re: About Question enthuware.jwpv6.2.570 :

Post by renatumb »

As metadata-complete=true, every annotations will be "ignored", even the @webServlet on class the DefaultServlet ?

How about annotations used for injection or life cycles, such as @postConstruct, @Resource, @EJB, etc?

admin
Site Admin
Posts: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.jwpv6.2.570 :

Post by admin »

Ideally, as per the specification it should ignore every annotation. In fact, it should not even scan any class for annotations.

HTH,
Paul.
If you like our products and services, please help us by posting your review here.

lukenhung
Posts: 17
Joined: Fri Aug 14, 2015 9:35 am
Contact:

Re: About Question enthuware.jwpv6.2.570 :

Post by lukenhung »

Hi, Paul!
I have a little curious about metadata-complete attribute.
As the servlet spec(3.0) said, If I set metadata-complete = true in web-fragment.xml
the deployment tool only examines the web-fragment.xml and must
ignore annotations such as @WebServlet, @WebFilter and @WebListener present
in the class files of the fragment

So I wonder whether the web.xml will be examined in this case or not?

Thank you in advance.

admin
Site Admin
Posts: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.jwpv6.2.570 :

Post by admin »

Web.xml is ALWAYS examined.
The issue it about annotations. If metadata-complete = true in a web fragment, then annotations of that fragment will be ignored.
Paul.
If you like our products and services, please help us by posting your review here.

himaiMinh
Posts: 358
Joined: Fri Nov 29, 2013 8:26 pm
Contact:

Re: About Question enthuware.jwpv6.2.570 :

Post by himaiMinh »

According to Servlet 3.0 spec, if metadata-complete = false, the container will argument the deployment descriptor and annotation. If that is the case, WFTestFilter2 will be applied to both patterns :"/" and "/wftest2".

But the spec also said deployment descriptor overrides annotation. If that is the case, WFTestFilter2 will only be applicable to "/".

So, which case is true?

admin
Site Admin
Posts: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.jwpv6.2.570 :

Post by admin »

There is no one rule about merging. In some cases the information is additive and in some cases information in web.xml overrides. In case of servlet mappings, the information is additive.

Please go through section "8.2.3 Assembling the descriptor from web.xml, web-
fragment.xml and annotations" of Servlet 3.0 specification for complete details.
If you like our products and services, please help us by posting your review here.

himaiMinh
Posts: 358
Joined: Fri Nov 29, 2013 8:26 pm
Contact:

Re: About Question enthuware.jwpv6.2.570 :

Post by himaiMinh »

Hi, in the spec 8.2.3,
5. If metadata-complete is not specified in the descriptors, or is set to false in the deployment descriptor , then the effective metadata for the application is derived by combining the metadata present in the annotations and the descriptors.
So, I assume all containers should argument the dd and annotation instead of using dd to override the annotations.

admin
Site Admin
Posts: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.jwpv6.2.570 :

Post by admin »

Again, please read that section of the specification completely. It gives exactly what things are overridden and what are additive. You can't just pick one line. You have to read the whole thing.
If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

Users browsing this forum: No registered users and 13 guests