You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Zhiyong Liu <zh...@nanometrics.ca> on 2007/06/19 23:32:46 UTC

Cannot load customized valve and realm from META-INF/context.xml

I am using Tomcat 5.0.28 and trying to get my customized valve and realm 
work but no luck with the following steps.
(1) put the jar file containing MyRealm.class and MyValve.class into 
webapps/myapp/WEB-INF/lib;
(2) created a context.xml file in webapps/myapp/META-INF with the 
following content
     <?xml version="1.0" encoding="utf-8" ?>
      <Context>
           <Valve className="com.mycompany.myapp.MyValve" />
           <Realm className="com.mycompany.myapp.MyRealm" />
      </Context>
(3)Then I restarted Tomcat and debugged it but only found MyValve and 
MyRealm were not called at all.

I tried to move the context.html to conf/Catalina/localhost and the jar 
file to server/lib then everything went well. But this is not what I 
want since the customized Realm and Valve are specific to my application.

I am new to Tomcat and start to get frustrated with this. I thought it 
should be easy but after googled a lot I still cannot figure out a 
solution. Any tip will be highly appreciated

Zhiyong

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


Re: Cannot load customized valve and realm from META-INF/context.xml

Posted by Zhiyong Liu <zh...@nanometrics.ca>.
Thanks for all the reply. I found this page while searching for a 
solution 
http://mail-archives.apache.org/mod_mbox/geronimo-user/200703.mbox/%3COFF64BD4B6.FD52A9F1-ON85257291.007C3D4E-85257292.00237D98@mxi.com%3E. 
Although it does not address my problem since I don't use Geronimo, I 
put the link here in hope helping someone else hits this thread.

To response Chris's question. I saw my valve and realm were invoked by 
debugging it as a Java remote application.

Zhiyong

Mark Thomas wrote:
> Christopher Schultz wrote:
>   
>> Zhiyong Liu wrote:
>> It looks to be that the difference is the placement of the JAR file.
>> Perhaps valves must be available through Tomcat's classloader instead of
>> the web application's disposable one.
>>     
>
> That will indeed be the problem. They need to be visible to the
> Catalina classloader.
>
> Mark
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>   

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


Re: Cannot load customized valve and realm from META-INF/context.xml

Posted by Mark Thomas <ma...@apache.org>.
Christopher Schultz wrote:
> Zhiyong Liu wrote:
> It looks to be that the difference is the placement of the JAR file.
> Perhaps valves must be available through Tomcat's classloader instead of
> the web application's disposable one.

That will indeed be the problem. They need to be visible to the
Catalina classloader.

Mark

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


Re: Cannot load customized valve and realm from META-INF/context.xml

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

Zhiyong,

Zhiyong Liu wrote:
> Thanks Chuck's reply.
> 
> However, there was no such myapp.xml file there. In fact, I manually
> copied my context.xml into localhost and renamed it to myapp.xml and
> it did not work either.

You claimed that it did:

>>> I tried to move the context.html to conf/Catalina/localhost and the
>>> jar file to server/lib then everything went well.

It looks to be that the difference is the placement of the JAR file.
Perhaps valves must be available through Tomcat's classloader instead of
the web application's disposable one.

> Is there a simple way to check whether the context.xml is loaded or
> not at all?

If your application deploys, then the context.xml file should have been
"loaded". I'm kind of interested in why the webapp works when those
valves have obviously not been attached.

How are you testing that your valves have been started?

- -chris

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGeGw89CaO5/Lv0PARApb9AJ0a7W0CxncGMbTUragB+9TF1vpelACfQhuF
Rblq9BrsHyGG3jwCC3MosoY=
=AdUp
-----END PGP SIGNATURE-----

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


Re: Cannot load customized valve and realm from META-INF/context.xml

Posted by Zhiyong Liu <zh...@nanometrics.ca>.
Thanks Chuck's reply. 

However, there was no such myapp.xml file there. In fact, I manually copied my context.xml into localhost and renamed it to myapp.xml and it did not work either. 

Is there a simple way to check whether the context.xml is loaded or not at all? 

Zhiyong
----- Original Message -----
From: Charles R Caldarale <Ch...@unisys.com>
To: Tomcat Users List <us...@tomcat.apache.org>
Sent: Tuesday, June 19, 2007 5:47:14 o'clock PM GMT-0500 Auto-Detected
Subject: RE: Cannot load customized valve and realm from META-INF/context.xml

> From: Zhiyong Liu [mailto:zhiyongliu@nanometrics.ca] 
> Subject: Cannot load customized valve and realm from 
> META-INF/context.xml
> 
> I tried to move the context.html to conf/Catalina/localhost 
> and the jar file to server/lib then everything went well.

Is it possible you already had a myapp.xml in conf/Catalina/localhost?
(Tomcat sometimes creates one there during deployment.)  If so, that
would have overridden the webapps/myapp/META-INF/context.xml values.

 - 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 start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org



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


RE: Cannot load customized valve and realm from META-INF/context.xml

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Zhiyong Liu [mailto:zhiyongliu@nanometrics.ca] 
> Subject: Cannot load customized valve and realm from 
> META-INF/context.xml
> 
> I tried to move the context.html to conf/Catalina/localhost 
> and the jar file to server/lib then everything went well.

Is it possible you already had a myapp.xml in conf/Catalina/localhost?
(Tomcat sometimes creates one there during deployment.)  If so, that
would have overridden the webapps/myapp/META-INF/context.xml values.

 - 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 start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org