You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Daniel Ruggeri <dr...@primary.net> on 2016/11/11 01:47:32 UTC

Bug or incorrect expectations with ContextConfig custom class and embedded Tomcat?

Hi, Tomcat devs;
    I'm a bit out of my usual neighborhood with httpd... but I'm working 
on creating a custom Authenticator for a non-standard auth-method in 
Tomcat and noticed there isn't a "stock" method for adding 
Authenticators aside from cracking open catalina.jar and messing with 
Authenticators.properties. After a bit of poking around I came across 
the ContextConfig class and found that I can create an implementation 
that allows me to create/assign the Map of customAuthenticators. Sweet - 
so I set up a little testing playground in Eclipse, wrote up my classes 
and am a bit confused by results.

    What I have come to find is that when starting Tomcat normally, the 
custom configClass works as expected when setting server.xml up as 
detailed below. When starting Tomcat in embedded mode via eclipse, 
however, I cannot seem to get the custom class to ever be used. I am not 
sure if this is expected behavior based on the way embedded Tomcat works 
or if this may actually be a bug.

Thoughts?



--- info below ---
server.xml Host tag:
       <Host name="localhost"  appBase="webapps" 
configClass="ruggeri.daniel.tester.CustomAuthenticatorsContextConfig"
             unpackWARs="true" autoDeploy="true">


Snip of JUnit test for embedded mode:
		tomcat = new Tomcat();
		tomcat.setBaseDir(tempDir.toString());
		tomcat.setHostname("localhost");
		tomcat.setPort(8080);

		tomcat.getHost().setConfigClass(CustomAuthenticatorsContextConfig.class.getCanonicalName());

		Context ctx = tomcat.addWebapp(tomcat.getHost(), "/testerApp", 
warPath);
		tomcat.init();
		tomcat.start();


Demonstration class to confirm the class is being used.
CustomAuthenticatorsContextConfig.java:
package ruggeri.daniel.tester;

import org.apache.catalina.startup.ContextConfig;

public class CustomAuthenticatorsContextConfig extends ContextConfig {
	public CustomAuthenticatorsContextConfig() {
		super();
		System.out.println("Custom Authenticators ContextConfig created!!!");
	}
}

-- 
Daniel Ruggeri

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


Re: Bug or incorrect expectations with ContextConfig custom class and embedded Tomcat?

Posted by Daniel Ruggeri <DR...@primary.net>.
On 11/11/2016 3:55 AM, Mark Thomas wrote:
> It is a bug. It has been fixed for the next set of releases.
>
> Thanks for the report.
>
> Mark

Awesome - thanks for the quick fix, Mark. I'll keep an eye out for the
next release.

-- 
Daniel Ruggeri


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


Re: Bug or incorrect expectations with ContextConfig custom class and embedded Tomcat?

Posted by Mark Thomas <ma...@apache.org>.
On 11/11/2016 01:47, Daniel Ruggeri wrote:
> Hi, Tomcat devs;
>    I'm a bit out of my usual neighborhood with httpd... but I'm working
> on creating a custom Authenticator for a non-standard auth-method in
> Tomcat and noticed there isn't a "stock" method for adding
> Authenticators aside from cracking open catalina.jar and messing with
> Authenticators.properties. After a bit of poking around I came across
> the ContextConfig class and found that I can create an implementation
> that allows me to create/assign the Map of customAuthenticators. Sweet -
> so I set up a little testing playground in Eclipse, wrote up my classes
> and am a bit confused by results.
> 
>    What I have come to find is that when starting Tomcat normally, the
> custom configClass works as expected when setting server.xml up as
> detailed below. When starting Tomcat in embedded mode via eclipse,
> however, I cannot seem to get the custom class to ever be used. I am not
> sure if this is expected behavior based on the way embedded Tomcat works
> or if this may actually be a bug.
> 
> Thoughts?

It is a bug. It has been fixed for the next set of releases.

Thanks for the report.

Mark


> 
> 
> 
> --- info below ---
> server.xml Host tag:
>       <Host name="localhost"  appBase="webapps"
> configClass="ruggeri.daniel.tester.CustomAuthenticatorsContextConfig"
>             unpackWARs="true" autoDeploy="true">
> 
> 
> Snip of JUnit test for embedded mode:
>         tomcat = new Tomcat();
>         tomcat.setBaseDir(tempDir.toString());
>         tomcat.setHostname("localhost");
>         tomcat.setPort(8080);
> 
>        
> tomcat.getHost().setConfigClass(CustomAuthenticatorsContextConfig.class.getCanonicalName());
> 
> 
>         Context ctx = tomcat.addWebapp(tomcat.getHost(), "/testerApp",
> warPath);
>         tomcat.init();
>         tomcat.start();
> 
> 
> Demonstration class to confirm the class is being used.
> CustomAuthenticatorsContextConfig.java:
> package ruggeri.daniel.tester;
> 
> import org.apache.catalina.startup.ContextConfig;
> 
> public class CustomAuthenticatorsContextConfig extends ContextConfig {
>     public CustomAuthenticatorsContextConfig() {
>         super();
>         System.out.println("Custom Authenticators ContextConfig
> created!!!");
>     }
> }
> 


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