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

Manuel Hartl <manuelha...@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEEDINFO                    |NEW

--- Comment #2 from Manuel Hartl <manuelha...@gmail.com> ---
The code snippet for starting:

        Tomcat tomcat = new Tomcat();
        tomcat.setPort(9000);
        tomcat.setBaseDir(".");
        tomcat.enableNaming();


        Context ctx = tomcat.addWebapp("/", docBase.getAbsolutePath());
        ctx.setConfigFile(new File("/META-INF/context.xml").toURI().toURL());
        tomcat.start();
        tomcat.getServer().await();

the web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
    xmlns="http://java.sun.com/xml/ns/javaee";
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd";
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd";
    version="3.0" metadata-complete="false">
    <display-name>ssms configuration app</display-name>

    <!-- Change to "Production" when you are ready to deploy -->
    <context-param>
        <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
        <param-value>.xhtml</param-value>
    </context-param>
    <context-param>
        <param-name>javax.faces.PROJECT_STAGE</param-name>
        <param-value>Development</param-value>
    </context-param>

    <context-param>
        <param-name>org.richfaces.skin</param-name>
        <param-value>classic</param-value>
    </context-param>

    <context-param>
        <param-name>javax.faces.FACELETS_SKIP_COMMENTS</param-name>
        <param-value>true</param-value>
    </context-param>

    <context-param>
        <param-name>createTempFiles</param-name>
        <param-value>false</param-value>
    </context-param>

    <context-param>
        <param-name>maxRequestSize</param-name>
        <param-value>1000000</param-value>
    </context-param>

    <context-param>
       
<param-name>javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL</param-name>
        <param-value>true</param-value>
    </context-param>

    <!-- Welcome page -->
    <welcome-file-list>
        <welcome-file>resources/index.xhtml</welcome-file>
    </welcome-file-list>

    <!-- JSF mapping -->
    <servlet>
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <!-- Map these files with JSF -->
    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>*.xhtml</url-pattern>
    </servlet-mapping>

    <error-page> 
        <exception-type>java.lang.Throwable</exception-type> 
        <location>/resources/error.xhtml</location> 
    </error-page>

    <error-page> 
        <error-code>500</error-code> 
        <location>/resources/error.xhtml</location> 
    </error-page>

    <error-page> 
        <error-code>503</error-code> 
        <location>/resources/error.xhtml</location> 
    </error-page>
    <listener>
       
<listener-class>org.jboss.weld.environment.servlet.Listener</listener-class>
    </listener>
    <resource-env-ref>
        <resource-env-ref-name>BeanManager</resource-env-ref-name>
       
<resource-env-ref-type>javax.enterprise.inject.spi.BeanManager</resource-env-ref-type>
    </resource-env-ref>    
</web-app>

An example ContextListener (that should throw an exception during
webapp-startup):
package de.flexsecure.test.tomcat.embedded;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;

@WebListener
public class ContextListener implements ServletContextListener {

    @Override
    public final void contextInitialized(ServletContextEvent event) {
        throw new RuntimeException("must happen");
    }

    @Override
    public void contextDestroyed(ServletContextEvent sce) {

    }

}

-- 
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