Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Filter not triggerring for applications outside webapps

 
Bijesh Vijayan
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I was trying to migrate from tomcat 5 to tomcat 7.

I copied the following contents from tomcat5/conf/web.xml to tomcat7/conf/web.xml

<filter>
<filter-name>Authenticate Filter</filter-name>
<filter-class>com.emp.EmpAuthorizationFilter</filter-class>
<init-param>
<param-name>SecurityLevel</param-name>
<param-value>0</param-value>
</init-param>
<init-param>
<param-name>Debug</param-name>
<param-value>1</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>Authenticate Filter</filter-name>
<url-pattern>/servlet/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>Authenticate Filter</filter-name>
<url-pattern>*.jsp</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>Authenticate Filter</filter-name>
<url-pattern>*.do</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>Authenticate Filter</filter-name>
<url-pattern>*.exe</url-pattern>
</filter-mapping>

<servlet>
<servlet-name>Authenticate</servlet-name>
<servlet-class>com.emp.EmpPortalAuthenticationForm</servlet-class>
</servlet>

<login-config>
<auth-method>FORM</auth-method>
<realm-name>UMIPortal Form-Based Authentication Area</realm-name>
<form-login-config>
<form-login-page>/servlet/Authenticate</form-login-page>
<form-error-page>/servlet/AuthenticateError</form-error-page>
</form-login-config>
</login-config>

I have more than one context. one in Employee and one Employee/Reports
the contexts are defined in

tomcat7/conf/Catalina/localhost/Employee.xml
<Context path="/Employee"
docBase="/home/bijesh/Employee"
crossContext="true"
reloadable="false"
workDir="Employee">

tomcat7/conf/Catalina/localhost/Employee#Reports.xml
<Context path="/Employee/Reports"
docBase="/home/bijesh/Employee/Reports"
crossContext="true"
reloadable="false"
workDir="Employee/Reports">

The filter jar is available in /home/bijesh/Employee/WEB-INF/lib and /homes/bijesh/Employee/Reports/WEB-INF/lib

The filter is initiated for the second app.

Bijesh.

 
Bijesh Vijayan
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was also getting the below error in the front end

HTTP Status 404 - /Employee/servlet/Authenticate
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64632
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bijesh Vijayan wrote:I have more than one context. one in Employee and one Employee/Reports

You have nested contexts? What's up with that?

the contexts are defined in

tomcat7/conf/Catalina/localhost/Employee#Reports.xml

A #?
 
Bijesh Vijayan
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

not nested context. (I think so, as it has got separate context files and separate path and docBase)

# I added as in tomcat5, the context names are Employee-context.xml and Reports-context.xml
I used # as per the below site(see the heading Naming).

http://tomcat.apache.org/tomcat-7.0-doc/config/context.html

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64632
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bijesh Vijayan wrote:not nested context.

You have one context inside the folder of another. That's nested.

Separate out the second context into its own folder before diagnosing any further.
 
Bijesh Vijayan
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Fine, so in tomcat5, the filter is loading for each context(Employee and Employee/Reports), but in tomcat7, its not loading for both(the init() method is not getting triggered).

In both the filter is not declared in the web.xml(/homes/bijesh/Employee/WEB-INF/web.xml and /homes/Employee/Reports/WEB-INF/web.xml)

The filter is defined only in /home/bijesh/tomcat7/conf/web.xml

Do we need to do anything for tomcat7 ?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64632
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are going to ignore the advice given, why are you asking the question?

/unsubscribes
 
Bijesh Vijayan
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I tried, to separate both the context

so now my directory structure is
/home/bijesh/Employee/WEB-INF/web.xml
/home/bijesh/Reports/WEB-INF/web.xml

I changed the doc base in context.xml
/home/bijesh/tomcat7/conf/Catalina/localhost/Employee.xml
/home/bijesh/tomcat7/conf/Catalina/localhost/Reports.xml
(I changed the name from Employee#Reports.xml to Reports.xml)

Still not loading the filter.
One thing also I noticed, in tomcat5 catalina.jar, there is a class named StandardHostDeployer, but its missing in tomcat7 catalina.jar. Also couple of other classes are missing in tomcat 7 catalina.jar(Eg:- HttpRequest, HttpResponse). Is there any way we can get these in tomcat 7

Bijesh.





 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic