You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Harish <ha...@postmark.net> on 2000/03/21 07:34:13 UTC

Bug in the Impl of Interceptor architecture?

Hi costin,

	I wrote a test interceptor which just checks if all the methods of the
Interface are being called.Added the following entry in server.xml:
"<RequestInterceptor className="MyInterceptor" />"
(after all the Request Interceptors present). 

	[I've attached the code and the output below.]

	The results say that only
contextMap(),requestMap(),authorize(),beforeBody() are being called.
Other methods like: preService(), postService() aren't getting called at
all.
 	Isn't that a bug?
	I tried accessing the admin context apart from the ROOT and got the
same results.

Also, the AdminContext isn't adding the contexts on the fly. I'm going
through the source of tomcat. I know that i'm getting the error from the
"DefaultErrorPage" servlet, but am not able to find out who's causing it
as request.getAttribute(tomcat.servlet.error.throwable) is NULL(and so i
cant do a printStackTrace()). This is the case with servlets. Regarding
Jsps it tries to fetch the page from "c:\program files\apache
group\jakarta-tomcat\" directory.

I need to figure out the problem with the hot deployment of SERVLETS
soon as i can. Please help me as to how to fix this problem with
"hot-deployment".

Regards,
harish

<code>
import org.apache.tomcat.core.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.*;
import java.rmi.*;
import com.pramati.util.*;

public class MyInterceptor extends BaseInterceptor{
	
    public int contextMap(Request request){
		System.out.println("contextMap() called! class="+ request.getClass());
		return 0;
	}
    public int requestMap(Request request){
		System.out.println("requestMap() called!");
		return 0;
	}
    public int authenticate(Request request, Response response)
	{
		return 0;
	}
    public int authorize(Request request, Response response){
		System.out.println("authorize() called!");
		return 0;
	}
    public int preService(Request request, Response response){
		System.out.println("preService() called!");
		return 0;
	}
    public int beforeBody( Request request, Response response){
		System.out.println("beforeBody() called!");
		return 0;
	}
    public int beforeCommit( Request request, Response response){
		System.out.println("beforeCommit() called!");
		return 0;
	}
    public int afterBody( Request request, Response response){
		System.out.println("afterBody() called!");
		return 0;
	}
    public int postService(Request request, Response response){
		System.out.println("postService() called!");
		return 0;
	}
    public String[] getMethods(){
		System.out.println("getMethods() called!");
		return new String[0];
	}

}

</code>

output:(for each request sent to tomcat)

contextMap() called! class=class
org.apache.tomcat.service.http.HttpRequestAdapt
er
requestMap() called!
authorize() called!
contextMap() called! class=class org.apache.tomcat.core.RequestImpl
requestMap() called!
contextMap() called! class=class
org.apache.tomcat.service.http.HttpRequestAdapt
er
requestMap() called!
beforeBody() called!

Re: I've built RPMS

Posted by jv...@kw.igs.net.
Sorry I forgot to mention that I used the GNU classpathx JSDK and
that's built in the RPM as well. I'm not sure if this is acceptable, I know
there are some serialization issues with the GNU JSDK because they
can't legally look at the sources to see what SUN is doing.

Jason van Zyl


I've built RPMS

Posted by jv...@kw.igs.net.
Hello,

I have a first version of an RPM for tomcat. Right now it's suited to my particular needs but
the
RPM could easily be modified to be useful for others. Here's a quick list of what's in it:

-> builds ApacheJServ as a DSO (with EAPI for use with mod_ssl)
-> builds jakarta-ant package
-> builds jakarta-tomcat package (all the examples are present)
-> htttp.conf has been modifed to take -DJSERV or -DTOMCAT so you
       can use the servlet engine of your choice.
-> RedHat init script takes the same options as above so they can be
       passed into apache. The selection of TOMCAT will automatically
       start tomcat.

Some notes:

I don't use the standard RedHat layout: I use

/www/apache

and keep everything under there. So there's a

/www/apache/jserv

and a

/www/apache/tomcat

As well, my base apache RPM has been built using the EAPI so that I could build
mod_ssl as a DSO.

Like I said the above oddities could easily be changed if the RPMs would be generally
useful. Maybe someone has already done this. It was still in the TOMCAT todo.

I also don't have anywhere to put the RPMs for sharing. I would be glad to
make a set of RPMs for easy installation if someone could provide a little space.

Jason van Zyl


Error in reading XML

Posted by Harish <ha...@postmark.net>.
Hi,
	I added code to expand the war file into webapps directory and now i'm
able to do hot deployment. [BTW, I'm on Win98 using tomcat standalone,
could that be the reason that i'd to do all whatever i have done?]
[I've done some not-so-nice coding in this. I'll make it neater and send
it within a couple of days - U guys can check it and put it 'in' or
throw it 'off' :) ] 
There's another problem now:
	I get this error whenever i deploy war files which have the
<descrption>DESC</descrption> tag. The exception is:
java.lang.NoSuchMethodException: setDescription(st. trace is appended
below). The problem is that in XmlMapper.matchend() method[which in turn
calls MethodSetter.end()]: ServletWrapper.setDescription() is getting
called(method.invoke()).But setDescription() method is not present in
SW[There is a setServletDescription() method in SW,however] I found a
workaround by adding the method, but i'm not very sure that its correct.
u guys please tell me what to do.
[I'm adding the xml as well below: ]

Cheers to the Jakarta group,
harish

STACK TRACE:
===========
ERROR reading C:\Program Files\Apache
Group\jakarta-tomcat\webapps\hello\WEB-INF
\web.xml
At Line 15 /web-app/servlet/description/ [[[SEE BELOW FOR THE WEB.XML
FILE]]]

ERROR reading C:\Program Files\Apache
Group\jakarta-tomcat\webapps\hello\WEB-INF
\web.xml
java.lang.NoSuchMethodException: setDescription
        at java.lang.Class.getMethod0(Native Method)
        at java.lang.Class.getMethod(Class.java, Compiled Code)
        at org.apache.tomcat.util.xml.MethodSetter.end(XmlMapper.java,
Compiled
Code)
        at org.apache.tomcat.util.xml.XmlMapper.matchEnd(XmlMapper.java,
Compile
d Code)
        at
org.apache.tomcat.util.xml.XmlMapper.endElement(XmlMapper.java, Compi
led Code)
        at com.sun.xml.parser.Parser.maybeElement(Parser.java, Compiled
Code)
        at com.sun.xml.parser.Parser.content(Parser.java, Compiled Code)
        at com.sun.xml.parser.Parser.maybeElement(Parser.java, Compiled
Code)
        at com.sun.xml.parser.Parser.content(Parser.java, Compiled Code)
        at com.sun.xml.parser.Parser.maybeElement(Parser.java, Compiled
Code)
        at com.sun.xml.parser.Parser.parseInternal(Parser.java:491)
        at com.sun.xml.parser.Parser.parse(Parser.java:283)
        at
org.apache.tomcat.util.xml.XmlMapper.readXml(XmlMapper.java:198)
        at
org.apache.tomcat.context.WebXmlReader.processFile(WebXmlReader.java:
124)
        at
org.apache.tomcat.context.WebXmlReader.contextInit(WebXmlReader.java:
38)
        at
org.apache.tomcat.core.ContextManager.initContext(ContextManager.java
, Compiled Code)
        at
org.apache.tomcat.core.ContextManager.init(ContextManager.java, Compi
led Code)
        at org.apache.tomcat.startup.Tomcat.execute(Tomcat.java:123)
        at org.apache.tomcat.startup.Tomcat.main(Tomcat.java:130)


WEB.XML
======
<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE web-app>

<web-app> 
  <icon> 
    <small-icon /> 
    <large-icon /> 
  </icon> 
  <display-name>web-app1</display-name> 
  <description>No Description</description> 
  <servlet> 
    <servlet-name>newaccount</servlet-name> 
    <display-name>newaccount</display-name> 
    <description>No Description</description> <!-- harish: I think the
prob. is here!! -->
    <jsp-file>newaccount.jsp</jsp-file> 
  </servlet> 
  <servlet> 
    <servlet-name>bank</servlet-name> 
    <display-name>bank</display-name> 
    <description>No Description</description> 
    <jsp-file>bank.jsp</jsp-file> 
  </servlet> 
  <servlet> 
    <servlet-name>info</servlet-name> 
    <display-name>info</display-name> 
    <description>No Description</description> 
    <jsp-file>info.jsp</jsp-file> 
  </servlet> 
  <servlet> 
    <servlet-name>viewledger</servlet-name> 
    <display-name>viewledger</display-name> 
    <description>No Description</description> 
    <jsp-file>viewledger.jsp</jsp-file> 
  </servlet> 
  <servlet> 
    <servlet-name>options</servlet-name> 
    <display-name>options</display-name> 
    <description>No Description</description> 
    <jsp-file>options.jsp</jsp-file> 
  </servlet> 
  <servlet> 
    <servlet-name>transfer</servlet-name> 
    <display-name>transfer</display-name> 
    <description>No Description</description> 
    <jsp-file>transfer.jsp</jsp-file> 
  </servlet> 
  <servlet> 
    <servlet-name>allaccounts</servlet-name> 
    <display-name>allaccounts</display-name> 
    <description>No Description</description> 
    <jsp-file>allaccounts.jsp</jsp-file> 
  </servlet> 
  <session-config> 
    <description>No Description</description> 
    <session-timeout>-1</session-timeout> 
  </session-config> 
  <ejb-ref> 
    <description>No Description</description> 
    <ejb-ref-name>ejb/Transfer</ejb-ref-name> 
    <ejb-ref-type>Entity Bean</ejb-ref-type> 
    <home>proton.bank.TransferHome</home> 
    <remote>proton.bank.Transfer</remote> 
    <ejb-link /> 
  </ejb-ref> 
  <ejb-ref> 
    <description>No Description</description> 
    <ejb-ref-name>ejb/Ledger</ejb-ref-name> 
    <ejb-ref-type>Entity Bean</ejb-ref-type> 
    <home>proton.bank.LedgerHome</home> 
    <remote>proton.bank.Ledger</remote> 
    <ejb-link /> 
  </ejb-ref> 
  <ejb-ref> 
    <description>No Description</description> 
    <ejb-ref-name>ejb/Checking</ejb-ref-name> 
    <ejb-ref-type>Entity Bean</ejb-ref-type> 
    <home>proton.bank.CheckingHome</home> 
    <remote>proton.bank.Checking</remote> 
    <ejb-link /> 
  </ejb-ref> 
</web-app>



Costin Manolache wrote:
> 
> Harish wrote:
> 
> > Hi,
> >         Earlier, i'd posted my questions to tomcat-dev in error. I'm resending
> > it to tomcat-user.
> >
> 
> I fixed it, it will show up in nightly builds. Thanks for the report - some of the callbacks
> were never used/tested.
> 
> Costin
> 
> --------------------------------------------------------------------------
> To unsubscribe, email: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commmands, email: tomcat-user-help@jakarta.apache.org

Re: Bug in the Impl of Interceptor architecture?

Posted by Costin Manolache <co...@eng.sun.com>.

Harish wrote:

> Hi,
>         Earlier, i'd posted my questions to tomcat-dev in error. I'm resending
> it to tomcat-user.
>

I fixed it, it will show up in nightly builds. Thanks for the report - some of the callbacks
were never used/tested.

Costin


Re: Bug in the Impl of Interceptor architecture?

Posted by Harish <ha...@postmark.net>.
Hi,
 	Earlier, i'd posted my questions to tomcat-dev in error. I'm resending
it to tomcat-user.

Thanks in adv,
harish

Harish wrote:
> 
> Hi,
> 
>         I wrote a test interceptor which just checks if all the methods of the
> Interface are being called.Added the following entry in server.xml:
> "<RequestInterceptor className="MyInterceptor" />"
> (after all the Request Interceptors present).
> 
>         [I've attached the code and the output below.]
> 
>         The results say that only
> contextMap(),requestMap(),authorize(),beforeBody() are being called.
> Other methods like: preService(), postService() aren't getting called at
> all.
>         Isn't that a bug?
>         I tried accessing the admin context apart from the ROOT and got the
> same results.
> 
> Also, the AdminContext isn't adding the contexts on the fly. I'm going
> through the source of tomcat. I know that i'm getting the error from the
> "DefaultErrorPage" servlet, but am not able to find out who's causing it
> as request.getAttribute(tomcat.servlet.error.throwable) is NULL(and so i
> cant do a printStackTrace()). This is the case with servlets. Regarding
> Jsps it tries to fetch the page from "c:\program files\apache
> group\jakarta-tomcat\" directory.
> 
> I need to figure out the problem with the hot deployment of SERVLETS
> soon as i can. Please help me as to how to fix this problem of
> "hot-deployment".
> 
> Regards,
> harish









> 
> <code>
> import org.apache.tomcat.core.*;
> import javax.servlet.*;
> import javax.servlet.http.*;
> import java.util.*;
> import java.rmi.*;
> import com.pramati.util.*;
> 
> public class MyInterceptor extends BaseInterceptor{
> 
>     public int contextMap(Request request){
>                 System.out.println("contextMap() called! class="+ request.getClass());
>                 return 0;
>         }
>     public int requestMap(Request request){
>                 System.out.println("requestMap() called!");
>                 return 0;
>         }
>     public int authenticate(Request request, Response response)
>         {
>                 return 0;
>         }
>     public int authorize(Request request, Response response){
>                 System.out.println("authorize() called!");
>                 return 0;
>         }
>     public int preService(Request request, Response response){
>                 System.out.println("preService() called!");
>                 return 0;
>         }
>     public int beforeBody( Request request, Response response){
>                 System.out.println("beforeBody() called!");
>                 return 0;
>         }
>     public int beforeCommit( Request request, Response response){
>                 System.out.println("beforeCommit() called!");
>                 return 0;
>         }
>     public int afterBody( Request request, Response response){
>                 System.out.println("afterBody() called!");
>                 return 0;
>         }
>     public int postService(Request request, Response response){
>                 System.out.println("postService() called!");
>                 return 0;
>         }
>     public String[] getMethods(){
>                 System.out.println("getMethods() called!");
>                 return new String[0];
>         }
> 
> }
> 
> </code>
> 
> output:(for each request sent to tomcat)
> 
> contextMap() called! class=class
> org.apache.tomcat.service.http.HttpRequestAdapt
> er
> requestMap() called!
> authorize() called!
> contextMap() called! class=class org.apache.tomcat.core.RequestImpl
> requestMap() called!
> contextMap() called! class=class
> org.apache.tomcat.service.http.HttpRequestAdapt
> er
> requestMap() called!
> beforeBody() called!
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org