Update GW to 3.0.0.RC3
diff --git a/build.gradle b/build.gradle
index fa1a448..6e2abaf 100644
--- a/build.gradle
+++ b/build.gradle
@@ -66,6 +66,7 @@
dependencies {
compile group: "org.eclipse.virgo.mirrored", name: "javax.servlet", version: javaxServletVersion, configuration: "compile", ext: "jar"
compile group: "org.eclipse.virgo.mirrored", name: "org.apache.catalina", version: apacheCatalinaVersion, configuration: "compile", ext: "jar"
+ compile group: "org.eclipse.virgo.mirrored", name: "org.apache.tomcat.api", version: apacheCatalinaVersion, configuration: "compile", ext: "jar"
compile group: "org.eclipse.virgo.mirrored", name: "org.eclipse.osgi", version: equinoxVersion, configuration: "compile", ext: "jar"
@@ -105,6 +106,7 @@
compile group: "org.eclipse.virgo.mirrored", name: "javax.validation", version: javaxValidationVersion, configuration: "compile", ext: "jar"
compile group: "org.eclipse.virgo.mirrored", name: "org.apache.catalina", version: apacheCatalinaVersion, configuration: "compile", ext: "jar"
+ compile group: "org.eclipse.virgo.mirrored", name: "org.apache.tomcat.util.scan", version: apacheCatalinaVersion, configuration: "compile", ext: "jar"
compile group: "org.eclipse.virgo.mirrored", name: "org.apache.openejb.core", version: apacheOpenejbCoreVersion, configuration: "compile", ext: "jar"
compile group: "org.eclipse.virgo.mirrored", name: "org.apache.openejb.jee", version: apacheOpenejbVersion, configuration: "compile", ext: "jar"
compile group: "org.eclipse.virgo.mirrored", name: "org.apache.openejb.loader", version: apacheOpenejbVersion, configuration: "compile", ext: "jar"
@@ -186,8 +188,9 @@
project(':web:org.eclipse.virgo.web.enterprise.openejb.tomcat.factory') {
dependencies {
testCompile group: "org.eclipse.virgo.mirrored", name: "javax.servlet", version: javaxServletVersion, configuration: "compile", ext: "jar"
- testCompile group: "org.eclipse.virgo.mirrored", name: "org.apache.juli.extras", version: apacheCatalinaVersion, configuration: "compile", ext: "jar"
+ testCompile group: "org.eclipse.virgo.mirrored", name: "org.apache.juli", version: apacheCatalinaVersion, configuration: "compile", ext: "jar"
testCompile group: "org.eclipse.virgo.mirrored", name: "org.apache.tomcat.util", version: apacheCatalinaVersion, configuration: "compile", ext: "jar"
+ testCompile group: "org.eclipse.virgo.mirrored", name: "org.apache.tomcat.util.scan", version: apacheCatalinaVersion, configuration: "compile", ext: "jar"
testCompile group: "org.eclipse.virgo.mirrored", name: "org.apache.coyote", version: apacheCatalinaVersion, configuration: "compile", ext: "jar"
testCompile group: "org.eclipse.virgo.mirrored", name: "org.apache.openejb.loader", version: apacheOpenejbVersion, configuration: "compile", ext: "jar"
@@ -224,9 +227,11 @@
testRuntime group: "commons-fileupload", name: "commons-fileupload", version: commonsFileuploadVersion, ext: "jar"
- testCompile group: "org.eclipse.virgo.mirrored", name: "org.apache.juli.extras", version: apacheCatalinaVersion, configuration: "compile", ext: "jar"
+ testCompile group: "org.eclipse.virgo.mirrored", name: "org.apache.juli", version: apacheCatalinaVersion, configuration: "compile", ext: "jar"
testCompile group: "org.eclipse.virgo.mirrored", name: "org.apache.tomcat.util", version: apacheCatalinaVersion, configuration: "compile", ext: "jar"
+ testCompile group: "org.eclipse.virgo.mirrored", name: "org.apache.tomcat.util.scan", version: apacheCatalinaVersion, configuration: "compile", ext: "jar"
+ testCompile group: "org.eclipse.virgo.mirrored", name: "org.apache.tomcat.api", version: apacheCatalinaVersion, configuration: "compile", ext: "jar"
testCompile group: "org.eclipse.virgo.mirrored", name: "org.apache.coyote", version: apacheCatalinaVersion, configuration: "compile", ext: "jar"
testCompile group: "org.eclipse.virgo.mirrored", name: "org.apache.openejb.loader", version: apacheOpenejbVersion, configuration: "compile", ext: "jar"
@@ -267,6 +272,7 @@
compile group: "org.eclipse.gemini", name: "org.eclipse.gemini.web.tomcat", version: geminiWebVersion, configuration: "compile", ext: "jar"
compile group: "org.eclipse.virgo.mirrored", name: "org.apache.tomcat.api", version: apacheCatalinaVersion, configuration: "compile", ext: "jar"
+ compile group: "org.eclipse.virgo.mirrored", name: "org.apache.tomcat.util.scan", version: apacheCatalinaVersion, configuration: "compile", ext: "jar"
compile group: "org.eclipse.virgo.mirrored", name: "org.apache.felix.gogo.runtime", version: gogoRuntimeVersion, configuration: "compile", ext: "jar"
diff --git a/org.eclipse.virgo.web.enterprise.appdeployer/src/main/java/org/eclipse/virgo/web/enterprise/openejb/deployer/VirgoDeployerEjb.java b/org.eclipse.virgo.web.enterprise.appdeployer/src/main/java/org/eclipse/virgo/web/enterprise/openejb/deployer/VirgoDeployerEjb.java
index b1ae1c1..ebe97b7 100755
--- a/org.eclipse.virgo.web.enterprise.appdeployer/src/main/java/org/eclipse/virgo/web/enterprise/openejb/deployer/VirgoDeployerEjb.java
+++ b/org.eclipse.virgo.web.enterprise.appdeployer/src/main/java/org/eclipse/virgo/web/enterprise/openejb/deployer/VirgoDeployerEjb.java
@@ -40,9 +40,9 @@
import javax.validation.ValidationException;
import org.apache.catalina.core.StandardContext;
-import org.apache.catalina.deploy.ContextResource;
-import org.apache.catalina.deploy.ContextResourceEnvRef;
-import org.apache.catalina.deploy.ResourceBase;
+import org.apache.tomcat.util.descriptor.web.ContextResource;
+import org.apache.tomcat.util.descriptor.web.ContextResourceEnvRef;
+import org.apache.tomcat.util.descriptor.web.ResourceBase;
import org.apache.naming.ContextAccessController;
import org.apache.openejb.AppContext;
import org.apache.openejb.ClassLoaderUtil;
@@ -345,12 +345,12 @@
JndiEncBuilder jndiBuilder = new JndiEncBuilder(webAppInfo.jndiEnc, null, webAppInfo.moduleId, TRANSACTION_TYPE_BEAN, null, webAppInfo.uniqueId, servletClassLoader);
appContext.getBindings().putAll(jndiBuilder.buildBindings(JndiEncBuilder.JndiScope.comp));
- ContextAccessController.setWritable(standardContext.getNamingContextListener().getName(), standardContext);
+ ContextAccessController.setWritable(standardContext.getNamingContextListener().getName(), standardContext.getNamingToken());
//TODO do nothing when there is nothing for binding
try {
- Context root = standardContext.getNamingContextListener().getNamingContext();
+ Context env = (Context) standardContext.getNamingContextListener().getEnvContext();
- bindRefInTomcat(appContext.getBindings(), root);
+ bindRefInTomcat(appContext.getBindings(), env);
} finally {
ContextAccessController.setReadOnly(standardContext.getNamingContextListener().getName());
}
diff --git a/org.eclipse.virgo.web.enterprise.applistener/src/main/java/org/eclipse/virgo/web/enterprise/applistener/internal/NamingResourcesListener.java b/org.eclipse.virgo.web.enterprise.applistener/src/main/java/org/eclipse/virgo/web/enterprise/applistener/internal/NamingResourcesListener.java
index 6ab67fa..806d621 100644
--- a/org.eclipse.virgo.web.enterprise.applistener/src/main/java/org/eclipse/virgo/web/enterprise/applistener/internal/NamingResourcesListener.java
+++ b/org.eclipse.virgo.web.enterprise.applistener/src/main/java/org/eclipse/virgo/web/enterprise/applistener/internal/NamingResourcesListener.java
@@ -15,9 +15,9 @@
import org.apache.catalina.Lifecycle;
import org.apache.catalina.LifecycleEvent;
import org.apache.catalina.LifecycleListener;
-import org.apache.catalina.deploy.ContextEjb;
-import org.apache.catalina.deploy.ContextLocalEjb;
-import org.apache.catalina.deploy.NamingResources;
+import org.apache.tomcat.util.descriptor.web.ContextEjb;
+import org.apache.tomcat.util.descriptor.web.ContextLocalEjb;
+import org.apache.catalina.deploy.NamingResourcesImpl;
public class NamingResourcesListener implements LifecycleListener {
@@ -30,7 +30,7 @@
}
if (Lifecycle.CONFIGURE_START_EVENT.equals(event.getType())) {
- NamingResources namingResources = ((Context) container).getNamingResources();
+ NamingResourcesImpl namingResources = ((Context) container).getNamingResources();
ContextEjb[] ejbs = namingResources.findEjbs();
for (int i = 0; ejbs != null && i < ejbs.length; i++) {
diff --git a/org.eclipse.virgo.web.enterprise.applistener/src/main/java/org/eclipse/virgo/web/enterprise/applistener/internal/OpenEjbApplicationListener.java b/org.eclipse.virgo.web.enterprise.applistener/src/main/java/org/eclipse/virgo/web/enterprise/applistener/internal/OpenEjbApplicationListener.java
index 4f0958d..eba86d4 100755
--- a/org.eclipse.virgo.web.enterprise.applistener/src/main/java/org/eclipse/virgo/web/enterprise/applistener/internal/OpenEjbApplicationListener.java
+++ b/org.eclipse.virgo.web.enterprise.applistener/src/main/java/org/eclipse/virgo/web/enterprise/applistener/internal/OpenEjbApplicationListener.java
@@ -15,7 +15,7 @@
import javax.servlet.ServletContext;
-import org.apache.catalina.Container;
+import org.apache.catalina.Context;
import org.apache.catalina.Lifecycle;
import org.apache.catalina.LifecycleEvent;
import org.apache.catalina.LifecycleListener;
@@ -111,14 +111,14 @@
// This event is very important
// It reorders the lifecycle listeners
// so that this listener appears after NamingContextListener
- Container container = ((Loader) source).getContainer();
- LifecycleListener[] listeners = container.findLifecycleListeners();
+ Context context = ((Loader) source).getContext();
+ LifecycleListener[] listeners = ((StandardContext) context).findLifecycleListeners();
for (int i = 0; listeners != null && i < listeners.length; i++) {
if (listeners[i].equals(this)) {
- container.removeLifecycleListener(this);// remove the listener from its current position
+ context.removeLifecycleListener(this);// remove the listener from its current position
}
}
- container.addLifecycleListener(this);// add the listener at the end
+ context.addLifecycleListener(this);// add the listener at the end
}
}
}
diff --git a/org.eclipse.virgo.web.enterprise.javax.persistence.extension/src/test/java/org/eclipse/virgo/web/enterprise/javax/persistence/extension/TestPersistenceProvider.java b/org.eclipse.virgo.web.enterprise.javax.persistence.extension/src/test/java/org/eclipse/virgo/web/enterprise/javax/persistence/extension/TestPersistenceProvider.java
index 3f14aef..2b16eea 100755
--- a/org.eclipse.virgo.web.enterprise.javax.persistence.extension/src/test/java/org/eclipse/virgo/web/enterprise/javax/persistence/extension/TestPersistenceProvider.java
+++ b/org.eclipse.virgo.web.enterprise.javax.persistence.extension/src/test/java/org/eclipse/virgo/web/enterprise/javax/persistence/extension/TestPersistenceProvider.java
@@ -36,4 +36,12 @@
return null;
}
+ @Override
+ public boolean generateSchema(String arg0, Map arg1) {
+ return false;
+ }
+
+ @Override
+ public void generateSchema(PersistenceUnitInfo arg0, Map arg1) {
+ }
}
diff --git a/org.eclipse.virgo.web.enterprise.openejb.initialiser/src/main/java/org/eclipse/virgo/web/enterprise/openejb/initialiser/VirgoThreadContextListener.java b/org.eclipse.virgo.web.enterprise.openejb.initialiser/src/main/java/org/eclipse/virgo/web/enterprise/openejb/initialiser/VirgoThreadContextListener.java
index 4696736..3733a2d 100755
--- a/org.eclipse.virgo.web.enterprise.openejb.initialiser/src/main/java/org/eclipse/virgo/web/enterprise/openejb/initialiser/VirgoThreadContextListener.java
+++ b/org.eclipse.virgo.web.enterprise.openejb.initialiser/src/main/java/org/eclipse/virgo/web/enterprise/openejb/initialiser/VirgoThreadContextListener.java
@@ -45,22 +45,22 @@
}
// set the new context
try {
- ContextBindings.bindThread(REDIRECTING_OPENEJB_CONTEXT);
+ ContextBindings.bindThread(REDIRECTING_OPENEJB_CONTEXT, null);
} catch (NamingException e) {
- ContextBindings.unbindContext(REDIRECTING_OPENEJB_CONTEXT);
+ ContextBindings.unbindContext(REDIRECTING_OPENEJB_CONTEXT, null);
throw new IllegalArgumentException("Unable to bind OpenEJB enc");
}
}
public void contextExited(ThreadContext exitedContext, ThreadContext reenteredContext) {
// unbind the new context
- ContextBindings.unbindThread(REDIRECTING_OPENEJB_CONTEXT);
+ ContextBindings.unbindThread(REDIRECTING_OPENEJB_CONTEXT, null);
// attempt to restore the old context
OldContextHolder data = exitedContext.get(OldContextHolder.class);
if (data != null && data.oldContextName != null) {
try {
- ContextBindings.bindThread(data.oldContextName);
+ ContextBindings.bindThread(data.oldContextName, null);
} catch (NamingException e) {
System.err.println("Exception in method contextExited");
e.printStackTrace();
diff --git a/org.eclipse.virgo.web.enterprise.openejb.tomcat.factory/src/main/java/org/eclipse/virgo/web/enterprise/openejb/tomcat/factory/TomcatResourceFactory.java b/org.eclipse.virgo.web.enterprise.openejb.tomcat.factory/src/main/java/org/eclipse/virgo/web/enterprise/openejb/tomcat/factory/TomcatResourceFactory.java
index 4617112..aaabdb5 100755
--- a/org.eclipse.virgo.web.enterprise.openejb.tomcat.factory/src/main/java/org/eclipse/virgo/web/enterprise/openejb/tomcat/factory/TomcatResourceFactory.java
+++ b/org.eclipse.virgo.web.enterprise.openejb.tomcat.factory/src/main/java/org/eclipse/virgo/web/enterprise/openejb/tomcat/factory/TomcatResourceFactory.java
@@ -11,16 +11,18 @@
public class TomcatResourceFactory {
private static final Logger LOGGER = Logger.getInstance(LogCategory.OPENEJB.createChild("tr"), TomcatResourceFactory.class);
- private static final String COMP_ENV_SUBCONTEXT = "comp/env/";
-
public static Object create(String jndiName, StandardContext standardContext) throws NamingException {
if (standardContext == null) {
return null;
}
- Context context = standardContext.getNamingContextListener().getNamingContext();
+ Context context = standardContext.getNamingContextListener().getEnvContext();
try {
- return context.lookup(COMP_ENV_SUBCONTEXT + jndiName);
+ if (context != null) {
+ return context.lookup(jndiName);
+ } else {
+ return null;
+ }
} catch (NamingException e) {
LOGGER.error("Error while looking up " + jndiName, e);
throw(e);
diff --git a/org.eclipse.virgo.web.enterprise.services.accessor/src/main/java/org/eclipse/virgo/web/enterprise/services/accessor/ClassLoaderJarScanner.java b/org.eclipse.virgo.web.enterprise.services.accessor/src/main/java/org/eclipse/virgo/web/enterprise/services/accessor/ClassLoaderJarScanner.java
index 57fe334..809b02f 100755
--- a/org.eclipse.virgo.web.enterprise.services.accessor/src/main/java/org/eclipse/virgo/web/enterprise/services/accessor/ClassLoaderJarScanner.java
+++ b/org.eclipse.virgo.web.enterprise.services.accessor/src/main/java/org/eclipse/virgo/web/enterprise/services/accessor/ClassLoaderJarScanner.java
@@ -15,6 +15,8 @@
import java.io.IOException;
import java.net.JarURLConnection;
import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
import java.net.URL;
import java.net.URLConnection;
import java.util.HashSet;
@@ -22,8 +24,12 @@
import javax.servlet.ServletContext;
+import org.apache.tomcat.Jar;
+import org.apache.tomcat.JarScanFilter;
+import org.apache.tomcat.JarScanType;
import org.apache.tomcat.JarScanner;
import org.apache.tomcat.JarScannerCallback;
+import org.apache.tomcat.util.scan.JarFactory;
import org.eclipse.osgi.baseadaptor.BaseData;
import org.eclipse.osgi.baseadaptor.bundlefile.BundleFile;
import org.eclipse.osgi.framework.adaptor.BundleData;
@@ -48,14 +54,32 @@
private Logger logger = LoggerFactory.getLogger(ClassLoaderJarScanner.class);
+ private JarScanFilter jarScanFilter;
+
public ClassLoaderJarScanner(Set<Bundle> bundles) {
this.bundles.addAll(bundles);
+ this.jarScanFilter = new JarScanFilter() {
+ @Override
+ public boolean check(JarScanType jarScanType, String bundleSymbolicName) {
+ return true;
+ }
+ };
}
@Override
- public void scan(ServletContext servletContext, ClassLoader classLoader, JarScannerCallback jarScannerCallback, Set<String> jarsToSkip) {
+ public JarScanFilter getJarScanFilter() {
+ return this.jarScanFilter;
+ }
+
+ @Override
+ public void setJarScanFilter(JarScanFilter jarScanFilter) {
+ this.jarScanFilter = jarScanFilter;
+ }
+
+ @Override
+ public void scan(JarScanType jarScanType, ServletContext context, JarScannerCallback callback) {
for (Bundle bundle : this.bundles) {
- scanBundle(bundle, jarScannerCallback);
+ scanBundle(bundle, callback);
}
}
@@ -74,11 +98,11 @@
try {
bundleUrl = new URL(bundleLocation);
if (REFERENCE_URL_PREFIX.equals(bundleUrl.getProtocol())) {
- bundleUrl = new URL(JAR_URL_PREFIX + bundleUrl.getFile() + JAR_URL_SUFFIX);
+ bundleUrl = new URL(JAR_URL_PREFIX + transformBundleLocation(bundleUrl.getFile()) + JAR_URL_SUFFIX);
} else {
- bundleUrl = new URL(JAR_URL_PREFIX + bundleLocation + JAR_URL_SUFFIX);
+ bundleUrl = new URL(JAR_URL_PREFIX + transformBundleLocation(bundleLocation) + JAR_URL_SUFFIX);
}
- } catch (MalformedURLException e) {
+ } catch (MalformedURLException | URISyntaxException e) {
logger.warn("Failed to create jar: url for bundle location " + bundleLocation, e);
return;
}
@@ -86,10 +110,19 @@
scanBundleUrl(bundleUrl, callback);
}
+ private String transformBundleLocation(String location) throws URISyntaxException {
+ URI url = new URI(location);
+ if (!url.isOpaque()) {
+ return location;
+ }
+ String scheme = url.getScheme();
+ return scheme + ":/" + location.substring(scheme.length() + 1);
+ }
+
private void scanBundleFile(File bundleFile, JarScannerCallback callback) {
if (bundleFile.isDirectory()) {
try {
- callback.scan(bundleFile);
+ callback.scan(bundleFile, null, true);
} catch (IOException e) {
logger.warn("Failure when attempting to scan bundle file '" + bundleFile + "':" + e.getMessage(), e);
}
@@ -106,14 +139,12 @@
}
private void scanBundleUrl(URL url, JarScannerCallback callback) {
- try {
- URLConnection connection = url.openConnection();
-
- if (connection instanceof JarURLConnection) {
- callback.scan((JarURLConnection) connection);
+ if ("jar".equals(url.getProtocol()) || url.getPath().endsWith(".jar")) {
+ try (Jar jar = JarFactory.newInstance(url)) {
+ callback.scan(jar, null, true);
+ } catch (IOException e) {
+ logger.warn("Failure when attempting to scan bundle via jar URL [" + url + "].", e);
}
- } catch (IOException e) {
- logger.warn("Failure when attempting to scan bundle via jar URL '" + url + "':" + e.getMessage(), e);
}
}
diff --git a/org.eclipse.virgo.web.test/src/test/resources/config/strict/tomcat-server.xml b/org.eclipse.virgo.web.test/src/test/resources/config/strict/tomcat-server.xml
index 51701fc..21e5586 100644
--- a/org.eclipse.virgo.web.test/src/test/resources/config/strict/tomcat-server.xml
+++ b/org.eclipse.virgo.web.test/src/test/resources/config/strict/tomcat-server.xml
@@ -23,7 +23,6 @@
<!--APR library loader. Documentation at /docs/apr.html -->
<Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
<!--Initialize Jasper prior to webapps are loaded. Documentation at /docs/jasper-howto.html -->
- <Listener className="org.apache.catalina.core.JasperListener" />
<!-- Prevent memory leaks due to use of particular java/javax APIs-->
<Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
<Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />
diff --git a/org.eclipse.virgo.web.test/src/test/resources/config/tomcat-server.xml b/org.eclipse.virgo.web.test/src/test/resources/config/tomcat-server.xml
index 51701fc..21e5586 100644
--- a/org.eclipse.virgo.web.test/src/test/resources/config/tomcat-server.xml
+++ b/org.eclipse.virgo.web.test/src/test/resources/config/tomcat-server.xml
@@ -23,7 +23,6 @@
<!--APR library loader. Documentation at /docs/apr.html -->
<Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
<!--Initialize Jasper prior to webapps are loaded. Documentation at /docs/jasper-howto.html -->
- <Listener className="org.apache.catalina.core.JasperListener" />
<!-- Prevent memory leaks due to use of particular java/javax APIs-->
<Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
<Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />