javax.naming.NoInitialContextException while deploying .war


Web tier: servlets, JSP, Web frameworks: javax.naming.NoInitialContextException while deploying .war

  1. Hi all,

    While deploying a .war file in Weblogic 5.1 I am getting following error message and the deployment fails.

    Tue Mar 27 10:05:20 EST 2001:<E> <ServletContext-userreg> failure pre-compiling
    weblogic.servlet.jsp.JspException: (line 11): Could not create a bean of type: c
    om.imany.userReg.javaBean.UserBean: java.lang.ClassNotFoundException: class com.
    imany.userReg.javaBean.UserBean : javax.naming.NoInitialContextException: Cannot
     create context for 'null' outside the scope of an application.
            at weblogic.servlet.jsp.JspLexer.jspException(
            at weblogic.servlet.jsp.JspLexer.processBeanTag(
            at weblogic.servlet.jsp.JspLexer.mXML_OPEN_USEBEAN(, Compil
    ed Code)
            at weblogic.servlet.jsp.JspLexer.mXML_THING(
            at weblogic.servlet.jsp.JspLexer.mTOKEN(
            at weblogic.servlet.jsp.JspLexer.nextToken(, Compiled Code)

    In my JSP code I am using the following tag

    <jsp:useBean id="sessionuser" class="com.imany.userReg.javaBean.UserBean" scope="session" />

    When I comment this tag then the exception is not occuring and the deployment is successfull.

    Can anyone please give me a solution for this?

  2. The exception you are getting is javax.naming.NoInitialContextException and usually this is because inside the class you are trying to get a context which is null. I hope it helps.
  3. Hi Neeraj,

    Thanks for your help. The problem was, I didnot define a environment variable and tried to lookup. Now I defined it in the web.xml and is working fine.