You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Lazar Kirchev <la...@gmail.com> on 2012/04/11 14:10:21 UTC

Using ServletContainerInitializer for 2.5 applications

Hello,

In servlet 3.0 specification ServletContainerInitilizer class is defined to
allow programatic addition of servlet/filters/listeners. I am using a
ServletContextInitializer to add a ServletContextListener to the
ServletContext. I use Tomcat 7.0.25. This works fine if the web.xml major
version is 3, but if it is 2 it does not work. I checked the
org.apache.catalina.startup.ContextConfig code and it seems that
ServletContainerInitializers are added to the StandardContext only if the
major version is >= 3 (in an if-statement in the webConfig() method). Could
you help me with this?

Regards,
Lazar

Re: Using ServletContainerInitializer for 2.5 applications

Posted by Konstantin Kolinko <kn...@gmail.com>.
2012/4/11 Konstantin Kolinko <kn...@gmail.com>:
> 2012/4/11 Lazar Kirchev <la...@gmail.com>:
>> I want the ServletContainerInitializer to be called for all applications I
>> deploy, not only with web.xml version 3.0, but also with lower version. Is
>> this possible?
>
> 2. You would even be able to load the class that implements that
> interface. The "ServletContainerInitializer" class is in
> "javax.servlet" package and it will be absent.
>
> The spec forbids you from bundling your own servlet-api.jar.
>

My apologies that I've misread your question.

(I though you were asking about deploying your thing on Tomcat 6.
There was several questions like that recently and I missed the point.

Instead of that you are asking about behaviour of 2.5 webapp on Tomcat 7).

Best regards,
Konstantin Kolinko

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Using ServletContainerInitializer for 2.5 applications

Posted by Konstantin Kolinko <kn...@gmail.com>.
2012/4/11 Lazar Kirchev <la...@gmail.com>:
> I want the ServletContainerInitializer to be called for all applications I
> deploy, not only with web.xml version 3.0, but also with lower version. Is
> this possible?

1. Do not top post. Write answers below the questions.

2. You would even be able to load the class that implements that
interface. The "ServletContainerInitializer" class is in
"javax.servlet" package and it will be absent.

The spec forbids you from bundling your own servlet-api.jar.

Best regards,
Konstantin Kolinko

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Using ServletContainerInitializer for 2.5 applications

Posted by Violeta Georgieva <vi...@apache.org>.
Ok I understood.
Thanks

2012/4/12 Christopher Schultz <ch...@christopherschultz.net>

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Mark,
>
> On 4/12/12 8:58 AM, markt@apache.org wrote:
> > If you want to use Servlet 3.0 features then you need to declare
> > 3.0 in the web.xml.
>
> +1
>
> Since the spec is (almost entirely) backward-compatible, this shouldn't
> represent an undue hardship. If you have to support customers who
> don't necessarily have a 3.0-spec container available, then you'll
> have to find another way to satisfy your requirement.
>
> - -chris
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
> Comment: GPGTools - http://gpgtools.org
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>
> iEYEARECAAYFAk+HH/AACgkQ9CaO5/Lv0PDLRACfVApXPTtjeyTIBsNVrarNfXto
> mlsAnjThrgVIKKV1ZnoN82RA5/nCG+Jc
> =13Wk
> -----END PGP SIGNATURE-----
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Re: Using ServletContainerInitializer for 2.5 applications

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Mark,

On 4/12/12 8:58 AM, markt@apache.org wrote:
> If you want to use Servlet 3.0 features then you need to declare
> 3.0 in the web.xml.

+1

Since the spec is (almost entirely) backward-compatible, this shouldn't
represent an undue hardship. If you have to support customers who
don't necessarily have a 3.0-spec container available, then you'll
have to find another way to satisfy your requirement.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk+HH/AACgkQ9CaO5/Lv0PDLRACfVApXPTtjeyTIBsNVrarNfXto
mlsAnjThrgVIKKV1ZnoN82RA5/nCG+Jc
=13Wk
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Using ServletContainerInitializer for 2.5 applications

Posted by ma...@apache.org.
Violeta Georgieva <vi...@apache.org> wrote:

>Hi,
>
>This mechanism is meant to be a standard way for web frameworks to
>extend
>the Servlet Container. IMHO this is compliant with the specification:

Your not really humble at all opinion is wrong. This is a Servlet 3.0 feature and therefore not available to 2.5 or earlier webapps.

If you look elsewhere in the Servlet, JSP and EL specs you'll find things that would break if the container used syntax from a newer spec version with a web app written for an older spec. If you want to use Servlet 3.0 features then you need to declare 3.0 in the web.xml.

Mark

>
>
>
>"8.2.4 Shared libraries / runtimes pluggability
>
>In addition to supporting fragments and use of annotations one of the
>requirements
>
>is that not only we be able to plug-in things that are bundled in the
>WEB-INF/lib
>
>but also plugin shared copies of frameworks - including being able to
>plug-in to the
>
>web container things like JAX-WS, JAX-RS and JSF that build on top of
>the
>web
>
>container. The ServletContainerInitializer allows handling such a use
>case
>
>as described below."
>
>
>Lazar just wants to extend the Servlet Container using this standard
>mechanism. He wants his implementation of ServletContainerInitializer
>to be
>invoked for every web application.
>
>Regards
>Violeta
>
>2012/4/12 Pid * <pi...@pidster.com>
>
>> On 11 Apr 2012, at 14:42, Lazar Kirchev <la...@gmail.com>
>wrote:
>>
>> > ServletContainerInitializer
>>
>> Only exists in Servlet 3.0. Supporting it in lower spec versions
>would
>> be non-compliant.
>>
>> And silly.
>>
>>
>> p
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Using ServletContainerInitializer for 2.5 applications

Posted by Violeta Georgieva <vi...@apache.org>.
Hi,

This mechanism is meant to be a standard way for web frameworks to extend
the Servlet Container. IMHO this is compliant with the specification:



"8.2.4 Shared libraries / runtimes pluggability

In addition to supporting fragments and use of annotations one of the
requirements

is that not only we be able to plug-in things that are bundled in the
WEB-INF/lib

but also plugin shared copies of frameworks - including being able to
plug-in to the

web container things like JAX-WS, JAX-RS and JSF that build on top of the
web

container. The ServletContainerInitializer allows handling such a use case

as described below."


Lazar just wants to extend the Servlet Container using this standard
mechanism. He wants his implementation of ServletContainerInitializer to be
invoked for every web application.

Regards
Violeta

2012/4/12 Pid * <pi...@pidster.com>

> On 11 Apr 2012, at 14:42, Lazar Kirchev <la...@gmail.com> wrote:
>
> > ServletContainerInitializer
>
> Only exists in Servlet 3.0. Supporting it in lower spec versions would
> be non-compliant.
>
> And silly.
>
>
> p
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Re: Using ServletContainerInitializer for 2.5 applications

Posted by Pid * <pi...@pidster.com>.
On 11 Apr 2012, at 14:42, Lazar Kirchev <la...@gmail.com> wrote:

> ServletContainerInitializer

Only exists in Servlet 3.0. Supporting it in lower spec versions would
be non-compliant.

And silly.


p

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Using ServletContainerInitializer for 2.5 applications

Posted by Lazar Kirchev <la...@gmail.com>.
On Wed, Apr 11, 2012 at 3:54 PM, Caldarale, Charles R <
Chuck.Caldarale@unisys.com> wrote:

> > From: Lazar Kirchev [mailto:lazar.kirchev@gmail.com]
> > Subject: Re: Using ServletContainerInitializer for 2.5 applications
>
> > I want the ServletContainerInitializer to be called for all applications
> I
> > deploy, not only with web.xml version 3.0, but also with lower version.
> Is
> > this possible?
>
> Simply put, no.  ServletContainerInitializer doesn't exist in the 2.5 spec
> and thus cannot be used with webapps written to that version of the spec.
>
>  - Chuck
>


Actually I have created a shared library, which extends the web container.
This library provides an implementation of the ServletContainerInitializer
interface according to the servlet 3.0 specification - chapter 8.2.4,
Shared libraries / runtimes pluggability.

I expect the ServletContainerInitializer to be called for each web
application, deployed in the web container. However, it gets called only if
the version of the web.xml of the deployed application is 3.0.

Is this according to the specification? After all, the library extends the
container itself and not a particular application.

>
>
> THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
> MATERIAL and is thus for use only by the intended recipient. If you
> received this in error, please contact the sender and delete the e-mail and
> its attachments from all computers.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

RE: Using ServletContainerInitializer for 2.5 applications

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Lazar Kirchev [mailto:lazar.kirchev@gmail.com] 
> Subject: Re: Using ServletContainerInitializer for 2.5 applications

> I want the ServletContainerInitializer to be called for all applications I
> deploy, not only with web.xml version 3.0, but also with lower version. Is
> this possible?

Simply put, no.  ServletContainerInitializer doesn't exist in the 2.5 spec and thus cannot be used with webapps written to that version of the spec.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Using ServletContainerInitializer for 2.5 applications

Posted by Lazar Kirchev <la...@gmail.com>.
I want the ServletContainerInitializer to be called for all applications I
deploy, not only with web.xml version 3.0, but also with lower version. Is
this possible?

On Wed, Apr 11, 2012 at 3:17 PM, Mikolaj Rydzewski <mi...@ceti.pl> wrote:

> On 11.04.2012 14:10, Lazar Kirchev wrote:
>
>  In servlet 3.0 specification ServletContainerInitilizer class is defined
>> to
>> allow programatic addition of servlet/filters/listeners. I am using a
>> ServletContextInitializer to add a ServletContextListener to the
>> ServletContext. I use Tomcat 7.0.25. This works fine if the web.xml major
>> version is 3, but if it is 2 it does not work. I checked the
>> org.apache.catalina.startup.**ContextConfig code and it seems that
>> ServletContainerInitializers are added to the StandardContext only if the
>> major version is >= 3 (in an if-statement in the webConfig() method).
>> Could
>> you help me with this?
>>
>
> Help with what? What is the problem?
>
> --
> Mikolaj Rydzewski <mi...@ceti.pl>
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.**apache.org<us...@tomcat.apache.org>
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Re: Using ServletContainerInitializer for 2.5 applications

Posted by Mikolaj Rydzewski <mi...@ceti.pl>.
On 11.04.2012 14:10, Lazar Kirchev wrote:

> In servlet 3.0 specification ServletContainerInitilizer class is 
> defined to
> allow programatic addition of servlet/filters/listeners. I am using a
> ServletContextInitializer to add a ServletContextListener to the
> ServletContext. I use Tomcat 7.0.25. This works fine if the web.xml 
> major
> version is 3, but if it is 2 it does not work. I checked the
> org.apache.catalina.startup.ContextConfig code and it seems that
> ServletContainerInitializers are added to the StandardContext only if 
> the
> major version is >= 3 (in an if-statement in the webConfig() method). 
> Could
> you help me with this?

Help with what? What is the problem?

-- 
Mikolaj Rydzewski <mi...@ceti.pl>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org