javax.naming.NoInitialContextException while deploying .war

Discussions

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
    JSP's
    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(JspLexer.java:574)
            at weblogic.servlet.jsp.JspLexer.processBeanTag(JspLexer.java:1115)
            at weblogic.servlet.jsp.JspLexer.mXML_OPEN_USEBEAN(JspLexer.java, Compil
    ed Code)
            at weblogic.servlet.jsp.JspLexer.mXML_THING(JspLexer.java:1521)
            at weblogic.servlet.jsp.JspLexer.mTOKEN(JspLexer.java:1431)
            at weblogic.servlet.jsp.JspLexer.nextToken(JspLexer.java, 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?

    Thanks,
    Srinivas.J
  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.

    Thanks,
    Srinivas.J