You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Terence Kwan <te...@logicspace.com> on 2000/05/13 10:50:18 UTC
getContext causes NullPointerException in tomcat 3.1
I was using Orion server and I just tried tomcat with my source code.
I did:
ServletConfig config=getServletConfig();
ServletContext cx = config.getServletContent();
cx=cx.getContext(<the root URL of this servlet>);
It causes NullPointerException
at org.apache.tomcat.core.ServletContextFacade.getContext(ServletContextFacade.jav:116)
Is it a known bug?
It does not have any problem in orion server.
I am running tomcat 3.1 + apache 1.3.12
Thanks
TK
Re: getContext causes NullPointerException in tomcat 3.1
Posted by "Craig R. McClanahan" <Cr...@eng.sun.com>.
Terence Kwan wrote:
> I was using Orion server and I just tried tomcat with my source code.
>
> I did:
> ServletConfig config=getServletConfig();
> ServletContext cx = config.getServletContent();
> cx=cx.getContext(<the root URL of this servlet>);
>
> It causes NullPointerException
> at org.apache.tomcat.core.ServletContextFacade.getContext(ServletContextFacade.jav:116)
>
> Is it a known bug?
>
The 99.9% cause of this is that you have an init method that looks like this:
public void init(ServletConfig config) {
...
}
but you don't call
super.init(config)
inside. Although this might work with Orion, it's guaranteed to cause null pointer
exception problems in many other engines.
>
> It does not have any problem in orion server.
> I am running tomcat 3.1 + apache 1.3.12
>
> Thanks
>
> TK
Craig McClanahan