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 2016/06/07 08:07:07 UTC

tomee git commit: TOMEE-1830 more alignment with tomcat scanning

Repository: tomee
Updated Branches:
  refs/heads/master e1be71c8a -> 16cc79b4d


TOMEE-1830 more alignment with tomcat scanning


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

Branch: refs/heads/master
Commit: 16cc79b4d26216d450763f5d9a9dd15a00817969
Parents: e1be71c
Author: Romain manni-Bucau <rm...@gmail.com>
Authored: Tue Jun 7 09:57:52 2016 +0200
Committer: Romain manni-Bucau <rm...@gmail.com>
Committed: Tue Jun 7 09:57:52 2016 +0200

----------------------------------------------------------------------
 .../arquillian/tests/tomcatscanning/E1.java     | 31 ++++++++++
 .../arquillian/tests/tomcatscanning/E2.java     | 31 ++++++++++
 .../arquillian/tests/tomcatscanning/E3.java     | 31 ++++++++++
 .../tomcatscanning/TomcatScanningTest.java      | 64 ++++++++++++++++++++
 .../src/test/resources/arquillian.xml           | 52 ++++++++++++++++
 .../apache/openejb/config/DeploymentLoader.java | 16 +++--
 .../apache/openejb/config/NewLoaderLogic.java   | 45 +++++++++++++-
 .../openejb/util/reflection/Reflections.java    |  6 +-
 .../org/apache/tomee/catalina/TomcatLoader.java | 54 ++++++++---------
 .../tomee/catalina/TomcatWebAppBuilder.java     |  2 +-
 .../apache/tomee/loader/TomEEJarScanner.java    |  4 ++
 11 files changed, 298 insertions(+), 38 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/16cc79b4/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/tomcatscanning/E1.java
----------------------------------------------------------------------
diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/tomcatscanning/E1.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/tomcatscanning/E1.java
new file mode 100644
index 0000000..374ca99
--- /dev/null
+++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/tomcatscanning/E1.java
@@ -0,0 +1,31 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.openejb.arquillian.tests.tomcatscanning;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+
+@Path("e1")
+public class E1 {
+    @GET
+    @Produces(MediaType.TEXT_PLAIN)
+    public String e1() {
+        return "1";
+    }
+}

http://git-wip-us.apache.org/repos/asf/tomee/blob/16cc79b4/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/tomcatscanning/E2.java
----------------------------------------------------------------------
diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/tomcatscanning/E2.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/tomcatscanning/E2.java
new file mode 100644
index 0000000..db8d53a
--- /dev/null
+++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/tomcatscanning/E2.java
@@ -0,0 +1,31 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.openejb.arquillian.tests.tomcatscanning;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+
+@Path("e2")
+public class E2 {
+    @GET
+    @Produces(MediaType.TEXT_PLAIN)
+    public String e2() {
+        return "2";
+    }
+}

http://git-wip-us.apache.org/repos/asf/tomee/blob/16cc79b4/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/tomcatscanning/E3.java
----------------------------------------------------------------------
diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/tomcatscanning/E3.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/tomcatscanning/E3.java
new file mode 100644
index 0000000..afcfebb
--- /dev/null
+++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/tomcatscanning/E3.java
@@ -0,0 +1,31 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.openejb.arquillian.tests.tomcatscanning;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+
+@Path("e3")
+public class E3 {
+    @GET
+    @Produces(MediaType.TEXT_PLAIN)
+    public String e3() {
+        return "3";
+    }
+}

http://git-wip-us.apache.org/repos/asf/tomee/blob/16cc79b4/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/tomcatscanning/TomcatScanningTest.java
----------------------------------------------------------------------
diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/tomcatscanning/TomcatScanningTest.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/tomcatscanning/TomcatScanningTest.java
new file mode 100644
index 0000000..be1fd4a
--- /dev/null
+++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/tomcatscanning/TomcatScanningTest.java
@@ -0,0 +1,64 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.openejb.arquillian.tests.tomcatscanning;
+
+import org.apache.ziplock.IO;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.arquillian.test.api.ArquillianResource;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import java.io.IOException;
+import java.net.URL;
+
+import static org.junit.Assert.assertEquals;
+
+@RunWith(Arquillian.class)
+public class TomcatScanningTest {
+    @Deployment(testable = false)
+    public static Archive<?> app() {
+        return ShrinkWrap.create(WebArchive.class, "TomcatScanningTest.war")
+                .addAsLibraries(
+                        ShrinkWrap.create(JavaArchive.class, "ant.jar"/*excluded by tomcat only*/).addClass(E1.class),
+                        ShrinkWrap.create(JavaArchive.class, "log4j-taglib-isincludedbytomcat.jar"/*excluded by tomee, included by tomcat*/).addClass(E2.class),
+                        ShrinkWrap.create(JavaArchive.class, "neethi-whatever.jar"/*excluded by tomee only*/).addClass(E3.class)
+                );
+    }
+
+    @ArquillianResource
+    private URL base;
+
+    @Test(expected = IOException.class)
+    public void antIsNotVisible() throws IOException {
+        IO.slurp(new URL(base.toExternalForm() + "e1"));
+    }
+
+    @Test
+    public void log4jTaglibIsVisible() throws IOException {
+        assertEquals("2", IO.slurp(new URL(base.toExternalForm() + "e2")).trim());
+    }
+
+    @Test(expected = IOException.class)
+    public void neethiIsNotVisible() throws IOException {
+        IO.slurp(new URL(base.toExternalForm() + "e3"));
+    }
+}

http://git-wip-us.apache.org/repos/asf/tomee/blob/16cc79b4/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/arquillian.xml
----------------------------------------------------------------------
diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/arquillian.xml b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/arquillian.xml
index 02980da..1e30def 100644
--- a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/arquillian.xml
+++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/arquillian.xml
@@ -32,6 +32,58 @@
         openejb.classloader.forced-load=org.apache.openejb.arquillian.tests
         openejb.ear.use-as-webcontext-base=true
         embedded = true
+
+
+        # Default list of JAR files that should not be scanned using the JarScanner
+        # functionality. This is typically used to scan JARs for configuration
+        # information. JARs that do not contain such information may be excluded from
+        # the scan to speed up the scanning process. This is the default list. JARs on
+        # this list are excluded from all scans. The list must be a comma separated list
+        # of JAR file names.
+        # The list of JARs to skip may be over-ridden at a Context level for individual
+        # scan types by configuring a JarScanner with a nested JarScanFilter.
+        # The JARs listed below include:
+        # - Tomcat Bootstrap JARs
+        # - Tomcat API JARs
+        # - Catalina JARs
+        # - Jasper JARs
+        # - Tomcat JARs
+        # - Common non-Tomcat JARs
+        # - Test JARs (JUnit, Cobertura and dependencies)
+        tomcat.util.scan.StandardJarScanFilter.jarsToSkip=\
+        bootstrap.jar,commons-daemon.jar,tomcat-juli.jar,\
+        annotations-api.jar,el-api.jar,jsp-api.jar,servlet-api.jar,websocket-api.jar,\
+        jaspic-api.jar,\
+        catalina.jar,catalina-ant.jar,catalina-ha.jar,catalina-storeconfig.jar,\
+        catalina-tribes.jar,\
+        jasper.jar,jasper-el.jar,ecj-*.jar,\
+        tomcat-api.jar,tomcat-util.jar,tomcat-util-scan.jar,tomcat-coyote.jar,\
+        tomcat-dbcp.jar,tomcat-jni.jar,tomcat-websocket.jar,\
+        tomcat-i18n-en.jar,tomcat-i18n-es.jar,tomcat-i18n-fr.jar,tomcat-i18n-ja.jar,\
+        tomcat-juli-adapters.jar,catalina-jmx-remote.jar,catalina-ws.jar,\
+        tomcat-jdbc.jar,\
+        tools.jar,\
+        commons-beanutils*.jar,commons-codec*.jar,commons-collections*.jar,\
+        commons-dbcp*.jar,commons-digester*.jar,commons-fileupload*.jar,\
+        commons-httpclient*.jar,commons-io*.jar,commons-lang*.jar,commons-logging*.jar,\
+        commons-math*.jar,commons-pool*.jar,\
+        jstl.jar,taglibs-standard-spec-*.jar,\
+        geronimo-spec-jaxrpc*.jar,wsdl4j*.jar,\
+        ant.jar,ant-junit*.jar,aspectj*.jar,jmx.jar,h2*.jar,hibernate*.jar,httpclient*.jar,\
+        jmx-tools.jar,jta*.jar,log4j*.jar,mail*.jar,slf4j*.jar,\
+        xercesImpl.jar,xmlParserAPIs.jar,xml-apis.jar,\
+        junit.jar,junit-*.jar,ant-launcher.jar,\
+        cobertura-*.jar,asm-*.jar,dom4j-*.jar,icu4j-*.jar,jaxen-*.jar,jdom-*.jar,\
+        jetty-*.jar,oro-*.jar,servlet-api-*.jar,tagsoup-*.jar,xmlParserAPIs-*.jar,\
+        xom-*.jar
+
+        # Default list of JAR files that should be scanned that overrides the default
+        # jarsToSkip list above. This is typically used to include a specific JAR that
+        # has been excluded by a broad file name pattern in the jarsToSkip list.
+        # The list of JARs to scan may be over-ridden at a Context level for individual
+        # scan types by configuring a JarScanner with a nested JarScanFilter.
+        tomcat.util.scan.StandardJarScanFilter.jarsToScan=\
+        log4j-core*.jar,log4j-taglib*.jar,log4javascript*.jar,slf4j-taglib*.jar
       </property>
     </configuration>
   </container>

http://git-wip-us.apache.org/repos/asf/tomee/blob/16cc79b4/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java b/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java
index b74e526..0611997 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java
@@ -1004,7 +1004,7 @@ public class DeploymentLoader implements DeploymentFilterable {
 
         // context.xml can define some additional libraries
         if (config != null) { // we don't test all !=null inline to show that config will get extra params in the future and that it is hierarchic
-            if (config.getClasspath() != null) {
+            if (config.getClasspath() != null && config.getClasspath().length > 0) {
                 final Set<URL> contextXmlUrls = new LinkedHashSet<>();
                 for (final String location : config.getClasspath()) {
                     try {
@@ -1034,7 +1034,7 @@ public class DeploymentLoader implements DeploymentFilterable {
         final ClassLoader warClassLoader = ClassLoaderUtil.createTempClassLoader(appId, webUrlsArray, parentClassLoader);
 
         // create web module
-        final List<URL> scannableUrls = filterWebappUrls(webUrlsArray, descriptors.get(NewLoaderLogic.EXCLUSION_FILE));
+        final List<URL> scannableUrls = filterWebappUrls(webUrlsArray, config == null ? null : config.customerFilter, descriptors.get(NewLoaderLogic.EXCLUSION_FILE));
         // executable war will add war in scannable urls, we don't want it since it will surely contain tomee, cxf, ...
         if (Boolean.parseBoolean(systemInstance.getProperty("openejb.core.skip-war-in-loader", "true"))) {
             File archive = warFile;
@@ -1130,7 +1130,7 @@ public class DeploymentLoader implements DeploymentFilterable {
         }
     }
 
-    public static List<URL> filterWebappUrls(final URL[] webUrls, final URL exclusions) {
+    public static List<URL> filterWebappUrls(final URL[] webUrls, final Filter filter, final URL exclusions) {
         Filter excludeFilter = null;
         if (exclusions != null) {
             try {
@@ -1143,7 +1143,7 @@ public class DeploymentLoader implements DeploymentFilterable {
 
         UrlSet urls = new UrlSet(webUrls);
         try {
-            urls = NewLoaderLogic.applyBuiltinExcludes(urls, null, excludeFilter);
+            urls = NewLoaderLogic.applyBuiltinExcludes(urls, filter, excludeFilter);
         } catch (final MalformedURLException e) {
             return Arrays.asList(webUrls);
         }
@@ -2142,9 +2142,15 @@ public class DeploymentLoader implements DeploymentFilterable {
 
     public static class ExternalConfiguration {
         private final String[] classpath;
+        private final Filter customerFilter;
 
-        public ExternalConfiguration(final String[] classpath) {
+        public ExternalConfiguration(final String[] classpath, final Filter customerFilter) {
             this.classpath = classpath;
+            this.customerFilter = customerFilter;
+        }
+
+        public Filter getCustomerFilter() {
+            return customerFilter;
         }
 
         public String[] getClasspath() {

http://git-wip-us.apache.org/repos/asf/tomee/blob/16cc79b4/container/openejb-core/src/main/java/org/apache/openejb/config/NewLoaderLogic.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/config/NewLoaderLogic.java b/container/openejb-core/src/main/java/org/apache/openejb/config/NewLoaderLogic.java
index d0feddb..0067e72 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/config/NewLoaderLogic.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/config/NewLoaderLogic.java
@@ -220,7 +220,6 @@ public class NewLoaderLogic {
     public static UrlSet applyBuiltinExcludes(final UrlSet urlSet, final Filter includeFilter, final Filter excludeFilter) throws MalformedURLException {
         getExclusions(); // force init
 
-        //filter = Filters.optimize(filter, new PatternFilter(".*/openejb-.*"));
         final List<URL> urls = urlSet.getUrls();
         final Iterator<URL> iterator = urls.iterator();
         while (iterator.hasNext()) {
@@ -233,6 +232,7 @@ public class NewLoaderLogic {
         return new UrlSet(urls);
     }
 
+    @Deprecated
     public static void setExclusions(final String[] exclusionArray) {
         exclusions = exclusionArray;
 
@@ -243,6 +243,49 @@ public class NewLoaderLogic {
         logExclusions(exclusionArray);
     }
 
+    /**
+     * @param excluded a filter returning true for filtered jars.
+     * @param included a filter returning true for included jars.
+     */
+    public static void addAdditionalCustomFilter(final Filter excluded, final Filter included) {
+        getExclusions();
+
+        // reinit the filter, we synchronized for consistency but there it should be thread safe anyway
+        if (excluded != null && included != null) {
+            synchronized (NewLoaderLogic.class) {
+                final Filter builtIn = new OptimizedExclusionFilter(getExclusions());
+                NewLoaderLogic.filter = new Filter() {
+                    @Override
+                    public boolean accept(final String name) {
+                        return !included.accept(name) && (builtIn.accept(name) || excluded.accept(name));
+                    }
+                };
+            }
+        } else if (excluded != null) {
+            synchronized (NewLoaderLogic.class) {
+                final Filter builtIn = new OptimizedExclusionFilter(getExclusions());
+                NewLoaderLogic.filter = new Filter() {
+                    @Override
+                    public boolean accept(final String name) {
+                        return builtIn.accept(name) || excluded.accept(name);
+                    }
+                };
+            }
+        } else if (included != null) {
+            synchronized (NewLoaderLogic.class) {
+                final Filter builtIn = new OptimizedExclusionFilter(getExclusions());
+                NewLoaderLogic.filter = new Filter() {
+                    @Override
+                    public boolean accept(final String name) {
+                        return !included.accept(name) && builtIn.accept(name);
+                    }
+                };
+            }
+        }
+
+        logExclusions(exclusions);
+    }
+
     private static void logExclusions(final String[] exclusionArray) {
         if (logger.isDebugEnabled()) {
             logger.debug("Exclusion prefixes: [");

http://git-wip-us.apache.org/repos/asf/tomee/blob/16cc79b4/container/openejb-core/src/main/java/org/apache/openejb/util/reflection/Reflections.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/util/reflection/Reflections.java b/container/openejb-core/src/main/java/org/apache/openejb/util/reflection/Reflections.java
index 02d7835..250749b 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/util/reflection/Reflections.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/util/reflection/Reflections.java
@@ -100,7 +100,11 @@ public final class Reflections {
     }
 
     public static Object get(final Object instance, final String field) {
-        Class<?> clazz = instance.getClass();
+        return get(instance.getClass(), instance, field);
+    }
+
+    public static Object get(final Class<?> aClass, final Object instance, final String field) {
+        Class<?> clazz = aClass;
         while (clazz != null) {
             try {
                 final Field f = clazz.getDeclaredField(field);

http://git-wip-us.apache.org/repos/asf/tomee/blob/16cc79b4/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/TomcatLoader.java
----------------------------------------------------------------------
diff --git a/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/TomcatLoader.java b/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/TomcatLoader.java
index e584ad0..8b066e5 100644
--- a/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/TomcatLoader.java
+++ b/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/TomcatLoader.java
@@ -23,7 +23,6 @@ import org.apache.catalina.core.StandardContext;
 import org.apache.catalina.core.StandardServer;
 import org.apache.catalina.startup.Bootstrap;
 import org.apache.catalina.startup.Catalina;
-import org.apache.catalina.startup.CatalinaProperties;
 import org.apache.openejb.OpenEJB;
 import org.apache.openejb.assembler.WebAppDeployer;
 import org.apache.openejb.assembler.classic.OpenEjbConfiguration;
@@ -44,22 +43,21 @@ import org.apache.openejb.server.ServiceException;
 import org.apache.openejb.server.ServiceManager;
 import org.apache.openejb.server.ejbd.EjbServer;
 import org.apache.openejb.spi.Service;
-import org.apache.openejb.util.Join;
 import org.apache.openejb.util.OptionsLog;
-import org.apache.tomcat.util.scan.Constants;
+import org.apache.openejb.util.reflection.Reflections;
+import org.apache.tomcat.util.file.Matcher;
 import org.apache.tomee.catalina.deployment.TomcatWebappDeployer;
 import org.apache.tomee.installer.Installer;
 import org.apache.tomee.installer.Paths;
 import org.apache.tomee.installer.Status;
 import org.apache.tomee.loader.TomcatHelper;
+import org.apache.xbean.finder.filter.Filter;
 
 import java.io.File;
 import java.lang.reflect.Field;
 import java.net.URL;
 import java.security.Security;
 import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashSet;
 import java.util.List;
 import java.util.Properties;
 import java.util.Set;
@@ -199,31 +197,14 @@ public class TomcatLoader implements Loader {
 
         // set ignorable libraries from a tomee property instead of using the standard openejb one
         // don't ignore standard openejb exclusions file
-        final Set<String> exclusions = new HashSet<String>(Arrays.asList(NewLoaderLogic.getExclusions()));
-        {
-            final String jarToSkipProp = CatalinaProperties.getProperty("tomcat.util.scan.DefaultJarScanner.jarsToSkip");
-            if (jarToSkipProp != null && !jarToSkipProp.isEmpty()) {
-                for (final String s : jarToSkipProp.split(",")) {
-                    final String sanitize = NewLoaderLogic.sanitize(s.trim());
-                    if (!sanitize.isEmpty()) {
-                        exclusions.add(sanitize);
-                    }
-                }
-            }
-        }
-        {
-            final String jarToSkipProp = CatalinaProperties.getProperty("org.apache.catalina.startup.ContextConfig.jarsToSkip");
-            if (jarToSkipProp != null && !jarToSkipProp.isEmpty()) {
-                for (final String s : jarToSkipProp.split(",")) {
-                    final String sanitize = NewLoaderLogic.sanitize(s.trim());
-                    if (!sanitize.isEmpty()) {
-                        exclusions.add(sanitize);
-                    }
-                }
-            }
-        }
-        NewLoaderLogic.setExclusions(exclusions.toArray(new String[exclusions.size()]));
-        System.setProperty(Constants.SKIP_JARS_PROPERTY, Join.join(",", exclusions)); // not sure we need it actually since we hook our scanner by default
+        final Class<?> scanner = Class.forName("org.apache.tomcat.util.scan.StandardJarScanFilter", true, TomcatLoader.class.getClassLoader());
+        final Set<String> forcedScanJar = Set.class.cast(Reflections.get(scanner, null, "defaultScanSet"));
+        final Set<String> forcedSkipJar = Set.class.cast(Reflections.get(scanner, null, "defaultSkipSet"));
+        NewLoaderLogic.addAdditionalCustomFilter(
+                forcedSkipJar.isEmpty() ? null : new TomcatToXbeanFilter(forcedSkipJar),
+                forcedScanJar.isEmpty() ? null : new TomcatToXbeanFilter(forcedScanJar));
+        // now we use the default tomcat filter so no need to do it
+        // System.setProperty(Constants.SKIP_JARS_PROPERTY, Join.join(",", exclusions));
 
         // Install tomcat war builder
         TomcatWebAppBuilder tomcatWebAppBuilder = (TomcatWebAppBuilder) SystemInstance.get().getComponent(WebAppBuilder.class);
@@ -467,4 +448,17 @@ public class TomcatLoader implements Loader {
             }
         }
     }
+
+    private static final class TomcatToXbeanFilter implements Filter {
+        private final Set<String> entries;
+
+        private TomcatToXbeanFilter(final Set<String> entries) {
+            this.entries = entries;
+        }
+
+        @Override
+        public boolean accept(final String name) {
+            return Matcher.matchName(entries, name);
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/tomee/blob/16cc79b4/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/TomcatWebAppBuilder.java
----------------------------------------------------------------------
diff --git a/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/TomcatWebAppBuilder.java b/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/TomcatWebAppBuilder.java
index 8a6aa73..f1095f3 100644
--- a/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/TomcatWebAppBuilder.java
+++ b/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/TomcatWebAppBuilder.java
@@ -2313,7 +2313,7 @@ public class TomcatWebAppBuilder implements WebAppBuilder, ContextListener, Pare
             }
 
             if (!cp.isEmpty()) {
-                return new DeploymentLoader.ExternalConfiguration(cp.toArray(new String[cp.size()]));
+                return new DeploymentLoader.ExternalConfiguration(cp.toArray(new String[cp.size()]), null /*for now doesnt make sense, todo: configure*/);
             }
         }
         return null;

http://git-wip-us.apache.org/repos/asf/tomee/blob/16cc79b4/tomee/tomee-loader/src/main/java/org/apache/tomee/loader/TomEEJarScanner.java
----------------------------------------------------------------------
diff --git a/tomee/tomee-loader/src/main/java/org/apache/tomee/loader/TomEEJarScanner.java b/tomee/tomee-loader/src/main/java/org/apache/tomee/loader/TomEEJarScanner.java
index 32e2f75..9624c34 100644
--- a/tomee/tomee-loader/src/main/java/org/apache/tomee/loader/TomEEJarScanner.java
+++ b/tomee/tomee-loader/src/main/java/org/apache/tomee/loader/TomEEJarScanner.java
@@ -120,5 +120,9 @@ public class TomEEJarScanner extends StandardJarScanner {
             }
             return !NewLoaderLogic.skip(jarName) && (delegate == null || delegate.check(jarScanType, jarName));
         }
+
+        public JarScanFilter getDelegate() {
+            return delegate;
+        }
     }
 }