You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by rm...@apache.org on 2014/12/24 16:27:21 UTC

tomee git commit: ugly hack to support CDI tck using jsf - also show more explicitely we have a 'design bug' in our http when it is not a 'flat classpath' webapp

Repository: tomee
Updated Branches:
  refs/heads/develop 97b720ed1 -> 2824f098a


ugly hack to support CDI tck using jsf - also show more explicitely we have a 'design bug' in our http when it is not a 'flat classpath' webapp


Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/2824f098
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/2824f098
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/2824f098

Branch: refs/heads/develop
Commit: 2824f098a853ccc8ec3c7791eb1b10db6a064226
Parents: 97b720e
Author: Romain Manni-Bucau <rm...@apache.org>
Authored: Wed Dec 24 16:15:29 2014 +0100
Committer: Romain Manni-Bucau <rm...@apache.org>
Committed: Wed Dec 24 16:15:29 2014 +0100

----------------------------------------------------------------------
 .../arquillian-openejb-embedded-5/pom.xml       |  2 +-
 .../arquillian/openejb/SWClassLoader.java       | 53 +++++++++++---
 .../http/WebArchiveResourceProvider.java        | 17 +++++
 ...ttpd.EmbeddedServletContext$ResourceProvider |  1 +
 .../apache/openejb/core/ivm/ContextHandler.java | 25 +++++++
 .../server/cxf/rs/CxfRsHttpListener.java        |  2 +-
 .../server/httpd/EmbeddedServletContext.java    | 51 ++++++++++++++
 .../openejb/server/httpd/FilterListener.java    |  2 +-
 .../openejb/server/httpd/HttpRequestImpl.java   | 13 +++-
 .../openejb/server/httpd/HttpResponseImpl.java  |  4 +-
 .../openejb/server/httpd/ServletListener.java   |  2 +-
 .../openejb/server/httpd/util/HttpUtil.java     | 72 ++++++++++++++++++--
 tck/cdi-embedded/pom.xml                        | 24 +++++++
 tck/cdi-embedded/src/test/resources/failing.xml |  4 +-
 14 files changed, 252 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/2824f098/arquillian/arquillian-openejb-embedded-5/pom.xml
----------------------------------------------------------------------
diff --git a/arquillian/arquillian-openejb-embedded-5/pom.xml b/arquillian/arquillian-openejb-embedded-5/pom.xml
index 55c25f5..8071da9 100644
--- a/arquillian/arquillian-openejb-embedded-5/pom.xml
+++ b/arquillian/arquillian-openejb-embedded-5/pom.xml
@@ -151,7 +151,7 @@
 
     <dependency> <!-- shouldn't be a compile/runtime dependency -->
       <groupId>org.apache.openejb</groupId>
-      <artifactId>openejb-server</artifactId>
+      <artifactId>openejb-http</artifactId>
       <version>${openejb.version}</version>
       <scope>provided</scope>
     </dependency>

http://git-wip-us.apache.org/repos/asf/tomee/blob/2824f098/arquillian/arquillian-openejb-embedded-5/src/main/java/org/apache/openejb/arquillian/openejb/SWClassLoader.java
----------------------------------------------------------------------
diff --git a/arquillian/arquillian-openejb-embedded-5/src/main/java/org/apache/openejb/arquillian/openejb/SWClassLoader.java b/arquillian/arquillian-openejb-embedded-5/src/main/java/org/apache/openejb/arquillian/openejb/SWClassLoader.java
index cbbd7d2..a75beee 100644
--- a/arquillian/arquillian-openejb-embedded-5/src/main/java/org/apache/openejb/arquillian/openejb/SWClassLoader.java
+++ b/arquillian/arquillian-openejb-embedded-5/src/main/java/org/apache/openejb/arquillian/openejb/SWClassLoader.java
@@ -81,31 +81,65 @@ public class SWClassLoader extends ClassLoader implements Closeable {
             if (!node.isEmpty()) {
                 final List<URL> urls = new ArrayList<>();
                 for (final Archive<?> i : node) {
-                    urls.add(new URL(null, "archive:" + i.getName() + "/" + name, new ArchiveStreamHandler()));
+                    urls.add(new URL(null, "archive:" + i.getName() + (!name.startsWith("/") ? "/" : "") + name, new ArchiveStreamHandler()));
+                }
+                if (cdiExtensions && !"true".equalsIgnoreCase(SystemInstance.get().getProperty("openejb.arquillian.cdi.extension.skip-externals", "false"))) {
+                    addContainerExtensions(name, urls);
                 }
                 return enumerator(urls);
             }
-            if (cdiExtensions && "true".equalsIgnoreCase(SystemInstance.get().getProperty("openejb.arquillian.cdi.extension.skip-externals", "true"))) {
-                return enumerator(Collections.<URL>emptyList());
+            if (cdiExtensions) {
+                if ("true".equalsIgnoreCase(SystemInstance.get().getProperty("openejb.arquillian.cdi.extension.skip-externals", "false"))) {
+                    return enumerator(Collections.<URL>emptyList());
+                }
+                return enumerator(addContainerExtensions(name, new ArrayList<URL>(2)));
             }
         }
         return super.getResources(name);
     }
 
+    private List<URL> addContainerExtensions(final String name, final List<URL> urls) throws IOException {
+        final Collection<URL> containerExtensions = Collections.list(getParent().getResources(name));
+        for (final URL u : containerExtensions) {
+            final String externalForm = u.toExternalForm();
+            if (externalForm.contains("myfaces-impl") || externalForm.contains("bval-jsr")) {
+                urls.add(u);
+            }
+        }
+        return urls;
+    }
+
     @Override
     protected Enumeration<URL> findResources(final String name) throws IOException {
         final List<Archive<?>> node = findNodes(name);
         if (!node.isEmpty()) {
             final List<URL> urls = new ArrayList<>();
             for (final Archive<?> i : node) {
-                urls.add(new URL(null, "archive:" + i.getName() + "/" + name, new ArchiveStreamHandler()));
+                urls.add(new URL(null, "archive:" + i.getName() + (!name.startsWith("/") ? "/" : "") + name, new ArchiveStreamHandler()));
             }
             return enumerator(urls);
         }
         return super.findResources(name);
     }
 
-    private LinkedList<Archive<?>> findNodes(final String name) {
+    public URL getWebResource(final String name) {
+        for (final Archive<?> a : archives) {
+            if (!WebArchive.class.isInstance(a)) {
+                continue;
+            }
+            final Node node = a.get(name);
+            if (node != null) {
+                try {
+                    return new URL(null, "archive:" + a.getName() + (!name.startsWith("/") ? "/" : "") + name, new ArchiveStreamHandler());
+                } catch (final MalformedURLException e) {
+                    // no-op
+                }
+            }
+        }
+        return null;
+    }
+
+    public LinkedList<Archive<?>> findNodes(final String name) {
         final LinkedList<Archive<?>> items = new LinkedList<>();
         for (final Archive<?> a : archives) {
             final Node node = a.get(ArchivePaths.create((WebArchive.class.isInstance(a) ? "/WEB-INF/classes/" : "") + name));
@@ -126,7 +160,7 @@ public class SWClassLoader extends ClassLoader implements Closeable {
         if (!node.isEmpty()) {
             final Archive<?> i = node.getLast();
             try {
-                return new URL(null, "archive:" + i.getName() + "/" + name, new ArchiveStreamHandler());
+                return new URL(null, "archive:" + i.getName() + (!name.startsWith("/") ? "/" : "") + name, new ArchiveStreamHandler());
             } catch (final MalformedURLException e) {
                 throw new IllegalArgumentException(e);
             }
@@ -155,9 +189,12 @@ public class SWClassLoader extends ClassLoader implements Closeable {
 
             final Archive<?> archive = archives.get(arName);
             final String path = path(archive.getName(), WebArchive.class.isInstance(archive) ? "/WEB-INF/classes/" : "", u);
-            final Node node = archive.get(path);
+            Node node = archive.get(path);
             if (node == null) {
-                throw new IOException(u.toExternalForm() + " not found");
+                node = archive.get(path(archive.getName(), "", u)); // web resources
+                if (node == null) {
+                    throw new IOException(u.toExternalForm() + " not found");
+                }
             }
 
             final Asset asset = node.getAsset();

http://git-wip-us.apache.org/repos/asf/tomee/blob/2824f098/arquillian/arquillian-openejb-embedded-5/src/main/java/org/apache/openejb/arquillian/openejb/http/WebArchiveResourceProvider.java
----------------------------------------------------------------------
diff --git a/arquillian/arquillian-openejb-embedded-5/src/main/java/org/apache/openejb/arquillian/openejb/http/WebArchiveResourceProvider.java b/arquillian/arquillian-openejb-embedded-5/src/main/java/org/apache/openejb/arquillian/openejb/http/WebArchiveResourceProvider.java
new file mode 100644
index 0000000..2f1f731
--- /dev/null
+++ b/arquillian/arquillian-openejb-embedded-5/src/main/java/org/apache/openejb/arquillian/openejb/http/WebArchiveResourceProvider.java
@@ -0,0 +1,17 @@
+package org.apache.openejb.arquillian.openejb.http;
+
+import org.apache.openejb.arquillian.openejb.SWClassLoader;
+import org.apache.openejb.server.httpd.EmbeddedServletContext;
+
+import java.net.URL;
+
+public class WebArchiveResourceProvider implements EmbeddedServletContext.ResourceProvider {
+    @Override
+    public URL getResource(final String s) {
+        final ClassLoader tccl = Thread.currentThread().getContextClassLoader();
+        if (SWClassLoader.class.isInstance(tccl)) {
+            return SWClassLoader.class.cast(tccl).getWebResource(s);
+        }
+        return null;
+    }
+}

http://git-wip-us.apache.org/repos/asf/tomee/blob/2824f098/arquillian/arquillian-openejb-embedded-5/src/main/resources/META-INF/services/org.apache.openejb.server.httpd.EmbeddedServletContext$ResourceProvider
----------------------------------------------------------------------
diff --git a/arquillian/arquillian-openejb-embedded-5/src/main/resources/META-INF/services/org.apache.openejb.server.httpd.EmbeddedServletContext$ResourceProvider b/arquillian/arquillian-openejb-embedded-5/src/main/resources/META-INF/services/org.apache.openejb.server.httpd.EmbeddedServletContext$ResourceProvider
new file mode 100644
index 0000000..a145f42
--- /dev/null
+++ b/arquillian/arquillian-openejb-embedded-5/src/main/resources/META-INF/services/org.apache.openejb.server.httpd.EmbeddedServletContext$ResourceProvider
@@ -0,0 +1 @@
+org.apache.openejb.arquillian.openejb.http.WebArchiveResourceProvider

http://git-wip-us.apache.org/repos/asf/tomee/blob/2824f098/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/ContextHandler.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/ContextHandler.java b/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/ContextHandler.java
index 55097b3..d62c592 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/ContextHandler.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/ContextHandler.java
@@ -25,6 +25,8 @@ import javax.naming.Context;
 import javax.naming.Name;
 import javax.naming.NameNotFoundException;
 import javax.naming.NamingException;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.UndeclaredThrowableException;
 
 public class ContextHandler extends ContextWrapper {
     public ContextHandler(final Context jndiContext) {
@@ -49,6 +51,29 @@ public class ContextHandler extends ContextWrapper {
     public Object lookup(final String name) throws NamingException {
         try {
             return context.lookup(name);
+        } catch (final UndeclaredThrowableException ute) {
+            Throwable e = ute.getUndeclaredThrowable();
+            while (e != null) {
+                if (InvocationTargetException.class.isInstance(e)) {
+                    final Throwable unwrap = InvocationTargetException.class.cast(e).getCause();
+                    if (e == unwrap) {
+                        throw new NameNotFoundException(name);
+                    }
+                    e = unwrap;
+                } else if (UndeclaredThrowableException.class.isInstance(e)) {
+                    final Throwable unwrap = UndeclaredThrowableException.class.cast(e).getUndeclaredThrowable();
+                    if (e == unwrap) {
+                        throw new NameNotFoundException(name);
+                    }
+                    e = unwrap;
+                } else {
+                    break;
+                }
+                if (NameNotFoundException.class.isInstance(e)) {
+                    throw NameNotFoundException.class.cast(e);
+                }
+            }
+            throw new NameNotFoundException(name);
         } catch (final NameNotFoundException nnfe) {
             try {
                 return SystemInstance.get().getComponent(ContainerSystem.class).getJNDIContext().lookup(name);

http://git-wip-us.apache.org/repos/asf/tomee/blob/2824f098/server/openejb-cxf-rs/src/main/java/org/apache/openejb/server/cxf/rs/CxfRsHttpListener.java
----------------------------------------------------------------------
diff --git a/server/openejb-cxf-rs/src/main/java/org/apache/openejb/server/cxf/rs/CxfRsHttpListener.java b/server/openejb-cxf-rs/src/main/java/org/apache/openejb/server/cxf/rs/CxfRsHttpListener.java
index a54db21..80ba49a 100644
--- a/server/openejb-cxf-rs/src/main/java/org/apache/openejb/server/cxf/rs/CxfRsHttpListener.java
+++ b/server/openejb-cxf-rs/src/main/java/org/apache/openejb/server/cxf/rs/CxfRsHttpListener.java
@@ -180,7 +180,7 @@ public class CxfRsHttpListener implements RsHttpListener {
         // fix the address (to manage multiple connectors)
         if (HttpRequestImpl.class.isInstance(httpRequest)) {
             final HttpRequestImpl requestImpl = HttpRequestImpl.class.cast(httpRequest);
-            requestImpl.initPathFromContext(context);
+            requestImpl.initPathFromContext((!context.startsWith("/") ? "/" : "") + context);
             requestImpl.initServletPath(servlet);
         }
 

http://git-wip-us.apache.org/repos/asf/tomee/blob/2824f098/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/EmbeddedServletContext.java
----------------------------------------------------------------------
diff --git a/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/EmbeddedServletContext.java b/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/EmbeddedServletContext.java
index 10a7490..f8ac643 100644
--- a/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/EmbeddedServletContext.java
+++ b/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/EmbeddedServletContext.java
@@ -18,14 +18,61 @@ package org.apache.openejb.server.httpd;
 
 import org.apache.webbeans.web.lifecycle.test.MockServletContext;
 
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
 import java.util.Collections;
 import java.util.Enumeration;
 import java.util.Map;
+import java.util.ServiceLoader;
 import java.util.concurrent.ConcurrentHashMap;
 
 public class EmbeddedServletContext extends MockServletContext {
     private final Map<String, Object> attributes = new ConcurrentHashMap<>();
 
+    private Collection<ResourceProvider> resourceProviders = new ArrayList<>();
+
+    public EmbeddedServletContext() {
+        for (final ResourceProvider rp : ServiceLoader.load(ResourceProvider.class, EmbeddedServletContext.class.getClassLoader())) {
+            resourceProviders.add(rp);
+        }
+    }
+
+    @Override
+    public URL getResource(final String path) throws MalformedURLException {
+        if (resourceProviders.isEmpty()) {
+            return super.getResource(path);
+        }
+        for (final ResourceProvider provider : resourceProviders) {
+            final URL resource = provider.getResource(path);
+            if (resource != null) {
+                return resource;
+            }
+        }
+        return super.getResource(path);
+    }
+
+    @Override
+    public InputStream getResourceAsStream(final String path) {
+        if (resourceProviders.isEmpty()) {
+            return super.getResourceAsStream(path);
+        }
+        for (final ResourceProvider provider : resourceProviders) {
+            final URL resource = provider.getResource(path);
+            if (resource != null) {
+                try {
+                    return resource.openStream();
+                } catch (final IOException e) {
+                    // no-op
+                }
+            }
+        }
+        return super.getResourceAsStream(path);
+    }
+
     @Override
     public int getMajorVersion() {
         return 3;
@@ -55,4 +102,8 @@ public class EmbeddedServletContext extends MockServletContext {
     public Enumeration<String> getAttributeNames() {
         return Collections.enumeration(attributes.keySet());
     }
+
+    public static interface ResourceProvider {
+        URL getResource(String path);
+    }
 }

http://git-wip-us.apache.org/repos/asf/tomee/blob/2824f098/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/FilterListener.java
----------------------------------------------------------------------
diff --git a/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/FilterListener.java b/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/FilterListener.java
index bd3565a..79f2c1f 100644
--- a/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/FilterListener.java
+++ b/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/FilterListener.java
@@ -47,7 +47,7 @@ public class FilterListener implements HttpListener {
             }
         }
         if (req != null) {
-            req.initPathFromContext(context);
+            req.initPathFromContext((!context.startsWith("/") ? "/" : "") + context);
         }
         delegate.doFilter(request, response, new SimpleFilterChain(this));
     }

http://git-wip-us.apache.org/repos/asf/tomee/blob/2824f098/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/HttpRequestImpl.java
----------------------------------------------------------------------
diff --git a/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/HttpRequestImpl.java b/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/HttpRequestImpl.java
index 8106485..ef94cfd 100644
--- a/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/HttpRequestImpl.java
+++ b/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/HttpRequestImpl.java
@@ -221,6 +221,11 @@ public class HttpRequestImpl implements HttpRequest {
 
     @Override
     public String getPathInfo() {
+        // hack for jsf, would need to rething all our getpathInfo() to get rid of it
+        // Note: if you tackle it ensure to not break CXF integrations
+        if (path != null && path.endsWith(".jsf")) {
+            return null;
+        }
         if (servletPath != null) {
             return path.substring(servletPath.length());
         }
@@ -275,6 +280,12 @@ public class HttpRequestImpl implements HttpRequest {
         if (servletPath != null) {
             return servletPath;
         }
+        if (path != null && path.endsWith(".jsf")) { // see getPathInfo()
+            if (contextPath != null && path.startsWith('/' + contextPath)) { // weird case with encoded url in forms, still this missing router surely
+                return path.substring(contextPath.length() + 1);
+            }
+            return path;
+        }
         return getPathInfo();
     }
 
@@ -1098,7 +1109,7 @@ public class HttpRequestImpl implements HttpRequest {
                 path = rawPath.substring(endIndex, rawPath.length());
                 contextPath = context.substring(0, endIndex);
             } else {
-                path = rawPath.substring(context.length(), rawPath.length()); // 1 because of the first /
+                path = rawPath.substring(context.length(), rawPath.length());
                 contextPath = context;
             }
         }

http://git-wip-us.apache.org/repos/asf/tomee/blob/2824f098/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/HttpResponseImpl.java
----------------------------------------------------------------------
diff --git a/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/HttpResponseImpl.java b/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/HttpResponseImpl.java
index c875f7b..24ea4e0 100644
--- a/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/HttpResponseImpl.java
+++ b/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/HttpResponseImpl.java
@@ -501,7 +501,9 @@ public class HttpResponseImpl implements HttpResponse {
         out.writeBytes(SP);
         out.writeBytes(code + "");
         out.writeBytes(SP);
-        out.writeBytes(responseString);
+        if (responseString != null) {
+            out.writeBytes(responseString);
+        }
         out.writeBytes(CRLF);
     }
 

http://git-wip-us.apache.org/repos/asf/tomee/blob/2824f098/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/ServletListener.java
----------------------------------------------------------------------
diff --git a/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/ServletListener.java b/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/ServletListener.java
index e5105c1..4e4d432 100644
--- a/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/ServletListener.java
+++ b/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/ServletListener.java
@@ -31,7 +31,7 @@ public class ServletListener implements HttpListener {
     public void onMessage(final HttpRequest request, final HttpResponse response) throws Exception {
         if (request instanceof HttpRequestImpl) {
             final HttpRequestImpl req = (HttpRequestImpl) request;
-            req.initPathFromContext(context);
+            req.initPathFromContext((!context.startsWith("/") ? "/" : "") + context);
         }
         delegate.service(request, response);
     }

http://git-wip-us.apache.org/repos/asf/tomee/blob/2824f098/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/util/HttpUtil.java
----------------------------------------------------------------------
diff --git a/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/util/HttpUtil.java b/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/util/HttpUtil.java
index 36227df..fff57b2 100644
--- a/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/util/HttpUtil.java
+++ b/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/util/HttpUtil.java
@@ -23,12 +23,19 @@ import org.apache.openejb.server.httpd.FilterListener;
 import org.apache.openejb.server.httpd.HttpListener;
 import org.apache.openejb.server.httpd.HttpListenerRegistry;
 import org.apache.openejb.server.httpd.ServletListener;
+import org.apache.webbeans.container.InjectableBeanManager;
 
 import javax.servlet.Filter;
 import javax.servlet.FilterConfig;
 import javax.servlet.Servlet;
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletContextEvent;
+import javax.servlet.ServletContextListener;
 import java.util.Collection;
+import java.util.Enumeration;
 import java.util.List;
+import java.util.regex.Pattern;
 
 public final class HttpUtil {
     private static final String WILDCARD = SystemInstance.get().getProperty("openejb.http.wildcard", ".*");
@@ -66,9 +73,60 @@ public final class HttpUtil {
 
         final ServletListener listener;
         try {
-            listener = new ServletListener((Servlet) wc.newInstance(wc.getClassLoader().loadClass(classname)), wc.getContextRoot());
-            listener.getDelegate().init(null);
-        } catch (Exception e) {
+            final ServletContext servletContext = SystemInstance.get().getComponent(ServletContext.class);
+            if ("javax.faces.webapp.FacesServlet".equals(classname)) {
+                try {
+                    // faking it to let the FacesServlet starting
+                    // NOTE: needs myfaces-impl + tomcat-jasper (JspFactory)
+                    // TODO: handle the whole lifecycle (cleanup mainly) + use myfaces SPI to make scanning really faster (take care should work in tomee were we already have it impl)
+                    final Class<?> mfListenerClass = wc.getClassLoader().loadClass("org.apache.myfaces.webapp.StartupServletContextListener");
+                    final Class<?> jspFactory = wc.getClassLoader().loadClass("org.apache.jasper.runtime.JspFactoryImpl");
+                    final Class<?> jspFactoryApi = wc.getClassLoader().loadClass("javax.servlet.jsp.JspFactory");
+                    jspFactoryApi.getMethod("setDefaultFactory", jspFactoryApi).invoke(null, jspFactory.newInstance());
+
+                    final ServletContextListener servletContextListener = ServletContextListener.class.cast(mfListenerClass.newInstance());
+                    servletContext.setAttribute("javax.enterprise.inject.spi.BeanManager", new InjectableBeanManager(wc.getWebBeansContext().getBeanManagerImpl()));
+                    final Thread thread = Thread.currentThread();
+                    final ClassLoader old = setClassLoader(wc, thread);
+                    try {
+                        servletContextListener.contextInitialized(new ServletContextEvent(servletContext));
+                    } finally {
+                        thread.setContextClassLoader(old);
+                    }
+                    servletContext.removeAttribute("javax.enterprise.inject.spi.BeanManager");
+                } catch (final Exception e) {
+                    // no-op
+                }
+            }
+            final Thread thread = Thread.currentThread();
+            final ClassLoader old = setClassLoader(wc, thread);
+            try {
+                listener = new ServletListener((Servlet) wc.newInstance(wc.getClassLoader().loadClass(classname)), wc.getContextRoot());
+                listener.getDelegate().init(new ServletConfig() {
+                    @Override
+                    public String getServletName() {
+                        return classname;
+                    }
+
+                    @Override
+                    public ServletContext getServletContext() {
+                        return servletContext;
+                    }
+
+                    @Override
+                    public String getInitParameter(final String s) {
+                        return servletContext.getInitParameter(s);
+                    }
+
+                    @Override
+                    public Enumeration<String> getInitParameterNames() {
+                        return servletContext.getInitParameterNames();
+                    }
+                });
+            } finally {
+                thread.setContextClassLoader(old);
+            }
+        } catch (final Exception e) {
             throw new OpenEJBRuntimeException(e);
         }
 
@@ -76,6 +134,12 @@ public final class HttpUtil {
         return true;
     }
 
+    private static ClassLoader setClassLoader(final WebContext wc, final Thread thread) {
+        final ClassLoader old = thread.getContextClassLoader();
+        thread.setContextClassLoader(wc.getClassLoader() == null ? wc.getAppContext().getClassLoader() : wc.getClassLoader());
+        return old;
+    }
+
     public static void removeServlet(final String mapping, final WebContext wc) {
         final HttpListenerRegistry registry = SystemInstance.get().getComponent(HttpListenerRegistry.class);
         if (registry == null || mapping == null) {
@@ -133,7 +197,7 @@ public final class HttpUtil {
         if (!mapping.startsWith("/") && !path.endsWith("/")) {
             path += '/';
         }
-        path += mapping;
+        path += mapping.startsWith("*.") ? WILDCARD + "\\" + mapping.substring(1) : mapping;
 
         if (path.endsWith("*")) {
             path = path.substring(0, path.length()) + WILDCARD;

http://git-wip-us.apache.org/repos/asf/tomee/blob/2824f098/tck/cdi-embedded/pom.xml
----------------------------------------------------------------------
diff --git a/tck/cdi-embedded/pom.xml b/tck/cdi-embedded/pom.xml
index 9229a50..a276d3e 100644
--- a/tck/cdi-embedded/pom.xml
+++ b/tck/cdi-embedded/pom.xml
@@ -39,6 +39,30 @@
       <version>${myfaces.version}</version>
       <scope>provided</scope>
     </dependency>
+    <dependency>
+      <groupId>org.apache.myfaces.core</groupId>
+      <artifactId>myfaces-impl</artifactId>
+      <version>${myfaces.version}</version>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.tomcat</groupId>
+      <artifactId>tomcat-jasper</artifactId>
+      <version>${tomcat.version}</version>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.tomcat</groupId>
+      <artifactId>tomcat-jasper-el</artifactId>
+      <version>${tomcat.version}</version>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.openejb.patch</groupId>
+      <artifactId>openejb-jstl</artifactId>
+      <version>1.2</version>
+      <scope>provided</scope>
+    </dependency>
 
     <dependency>
       <groupId>junit</groupId>

http://git-wip-us.apache.org/repos/asf/tomee/blob/2824f098/tck/cdi-embedded/src/test/resources/failing.xml
----------------------------------------------------------------------
diff --git a/tck/cdi-embedded/src/test/resources/failing.xml b/tck/cdi-embedded/src/test/resources/failing.xml
index 954932d..384c1b8 100644
--- a/tck/cdi-embedded/src/test/resources/failing.xml
+++ b/tck/cdi-embedded/src/test/resources/failing.xml
@@ -20,9 +20,9 @@
     <!-- runner helping properties
     -Dopenejb.cdi.filter.classloader=false -Dorg.apache.openejb.assembler.classic.WebAppBuilder=org.apache.openejb.web.LightweightWebAppBuilder -Dopenejb.cdi.debug=true -Dopenejb.http.mock-request=true
     -->
-    <classes><!-- org.jboss.cdi.tck.tests.context.conversation.ClientConversationContextTest, org.jboss.cdi.tck.tests.context.application.ApplicationContextTest, org.jboss.cdi.tck.tests.extensions.beanManager.beanAttributes.CreateBeanAttributesTest, org.jboss.cdi.tck.tests.event.fires.FireEventTest, org.jboss.cdi.tck.tests.extensions.lifecycle.processInjectionPoint.ProcessInjectionPointFiredTest -->
+    <classes><!--  org.jboss.cdi.tck.tests.context.application.ApplicationContextTest, org.jboss.cdi.tck.tests.extensions.beanManager.beanAttributes.CreateBeanAttributesTest, org.jboss.cdi.tck.tests.event.fires.FireEventTest, org.jboss.cdi.tck.tests.extensions.lifecycle.processInjectionPoint.ProcessInjectionPointFiredTest -->
       <!--<class name="org.jboss.cdi.tck.tests.context.application.async.ApplicationContextAsyncListenerTest" />-->
-      <class name="org.jboss.cdi.tck.tests.deployment.shutdown.ApplicationShutdownLifecycleTest" />
+      <class name="org.jboss.cdi.tck.tests.context.conversation.ClientConversationContextTest" />
     </classes>
   </test>
 </suite>