https://issues.apache.org/bugzilla/show_bug.cgi?id=54472

            Bug ID: 54472
           Summary: JspcServletContext need to set ClassLoader
           Product: Tomcat 7
           Version: 7.0.35
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Jasper
          Assignee: dev@tomcat.apache.org
          Reporter: aceofm...@gmail.com
    Classification: Unclassified

Now, JspcServletContext

    @Override
    public ClassLoader getClassLoader() {
        return null;
    }
i.e. no classloader is set.

This maybe throw NPE.
Actually, by rev. 1431228, 

    private void init(ErrorDispatcher err) throws JasperException {
        if (initialized)
            return;

        tagPlugins = new HashMap<String, TagPlugin>();

        Enumeration<URL> urls = null;
        try {
            urls = ctxt.getClassLoader().getResources(
                    META_INF_JASPER_TAG_PLUGINS_XML);
        } catch (IOException ioe) {
            throw new JasperException(ioe);
        }

        ....
    }

threw NPE, because ctxt.getClassLoader() is null.

So, we need to set the classloader in JspServletContext.
I resolved this issue by adding setter of classloader in JspServletContext and
setting classloader in JspC like below.


    protected void processFile(String file)
        throws JasperException
    {

            ....
            originalClassLoader =
Thread.currentThread().getContextClassLoader();
            if( loader==null ) {
                initClassLoader( clctxt );
                context.setClassLoader(loader); <-- set classloader
            }

   }

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to