Search in sources :

Example 1 with JspFactory

use of javax.servlet.jsp.JspFactory in project tomee by apache.

the class OpenEJBLifecycle method setJspELFactory.

/**
 * On Tomcat we need to sometimes force a class load to get our hands on the JspFactory
 */
private static void setJspELFactory(ServletContext startupObject, ELResolver resolver) {
    JspFactory factory = JspFactory.getDefaultFactory();
    if (factory == null) {
        try {
            try {
                Class.forName("org.apache.jasper.servlet.JasperInitializer");
            } catch (final Throwable th) {
                Class.forName("org.apache.jasper.compiler.JspRuntimeContext");
            }
            factory = JspFactory.getDefaultFactory();
        } catch (Exception e) {
        // ignore
        }
    }
    if (factory != null) {
        JspApplicationContext applicationCtx = factory.getJspApplicationContext(startupObject);
        applicationCtx.addELResolver(resolver);
    } else {
        logger.debug("Default JSPFactroy instance has not found. Skipping OWB JSP handling");
    }
}
Also used : JspApplicationContext(javax.servlet.jsp.JspApplicationContext) JspFactory(javax.servlet.jsp.JspFactory) ObjectStreamException(java.io.ObjectStreamException) OpenEJBRuntimeException(org.apache.openejb.OpenEJBRuntimeException)

Example 2 with JspFactory

use of javax.servlet.jsp.JspFactory in project jetty.project by eclipse.

the class ContainerTldBundleDiscoverer method fixJspFactory.

/**
     * 
     * Some versions of JspFactory do Class.forName, which probably won't work in an 
     * OSGi environment.
     */
public void fixJspFactory() {
    try {
        Class<javax.servlet.ServletContext> servletContextClass = javax.servlet.ServletContext.class;
        // bug #299733
        JspFactory fact = JspFactory.getDefaultFactory();
        if (fact == null) {
            // bug #299733
            // JspFactory does a simple
            // Class.getForName("org.apache.jasper.runtime.JspFactoryImpl")
            // however its bundles does not import the jasper package
            // so it fails. let's help things out:
            fact = (JspFactory) JettyBootstrapActivator.class.getClassLoader().loadClass(DEFAULT_JSP_FACTORY_IMPL_CLASS).newInstance();
            JspFactory.setDefaultFactory(fact);
        }
    } catch (Exception e) {
        LOG.warn("Unable to set the JspFactory: jsp support incomplete.", e);
    }
}
Also used : JspFactory(javax.servlet.jsp.JspFactory)

Aggregations

JspFactory (javax.servlet.jsp.JspFactory)2 ObjectStreamException (java.io.ObjectStreamException)1 JspApplicationContext (javax.servlet.jsp.JspApplicationContext)1 OpenEJBRuntimeException (org.apache.openejb.OpenEJBRuntimeException)1