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 2015/08/18 06:18:51 UTC
tomee git commit: TOMEE-1545 using tomcat version in context info id
Repository: tomee
Updated Branches:
refs/heads/master 01808df26 -> 97cee7124
TOMEE-1545 using tomcat version in context info id
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/97cee712
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/97cee712
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/97cee712
Branch: refs/heads/master
Commit: 97cee71249562f1df48ed41f21101d5cce1923c9
Parents: 01808df
Author: Romain Manni-Bucau <rm...@gmail.com>
Authored: Mon Aug 17 21:18:43 2015 -0700
Committer: Romain Manni-Bucau <rm...@gmail.com>
Committed: Mon Aug 17 21:18:43 2015 -0700
----------------------------------------------------------------------
.../apache/openejb/server/rest/RESTService.java | 34 +++++-----
.../apache/openejb/server/rest/RsRegistry.java | 2 +-
.../openejb/server/rest/RsRegistryImpl.java | 2 +-
.../tomee/catalina/TomcatWebAppBuilder.java | 67 +++++++++++++-------
.../tomee/webservices/TomcatRsRegistry.java | 15 +++--
5 files changed, 76 insertions(+), 44 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tomee/blob/97cee712/server/openejb-rest/src/main/java/org/apache/openejb/server/rest/RESTService.java
----------------------------------------------------------------------
diff --git a/server/openejb-rest/src/main/java/org/apache/openejb/server/rest/RESTService.java b/server/openejb-rest/src/main/java/org/apache/openejb/server/rest/RESTService.java
index e249e4c..df2eadb 100644
--- a/server/openejb-rest/src/main/java/org/apache/openejb/server/rest/RESTService.java
+++ b/server/openejb-rest/src/main/java/org/apache/openejb/server/rest/RESTService.java
@@ -369,10 +369,10 @@ public abstract class RESTService implements ServerService, SelfManaging {
if (hasEjbAndIsNotAManagedBean(restEjbs, o.getClass().getName())) {
// no more a singleton if the ejb is not a singleton...but it is a weird case
- deployEJB(webApp.contextRoot, appPrefix, restEjbs.get(o.getClass().getName()).context, additionalProviders, appInfo.services);
+ deployEJB(appInfo.appId, webApp.contextRoot, appPrefix, restEjbs.get(o.getClass().getName()).context, additionalProviders, appInfo.services);
} else {
pojoConfigurations = PojoUtil.findPojoConfig(pojoConfigurations, appInfo, webApp);
- deploySingleton(webApp.contextRoot, appPrefix, o, appInstance, classLoader, additionalProviders,
+ deploySingleton(appInfo.appId, webApp.contextRoot, appPrefix, o, appInstance, classLoader, additionalProviders,
new ServiceConfiguration(PojoUtil.findConfiguration(pojoConfigurations, o.getClass().getName()), appInfo.services));
}
}
@@ -383,10 +383,10 @@ public abstract class RESTService implements ServerService, SelfManaging {
}
if (hasEjbAndIsNotAManagedBean(restEjbs, clazz.getName())) {
- deployEJB(webApp.contextRoot, appPrefix, restEjbs.get(clazz.getName()).context, additionalProviders, appInfo.services);
+ deployEJB(appInfo.appId, webApp.contextRoot, appPrefix, restEjbs.get(clazz.getName()).context, additionalProviders, appInfo.services);
} else {
pojoConfigurations = PojoUtil.findPojoConfig(pojoConfigurations, appInfo, webApp);
- deployPojo(webApp.contextRoot, appPrefix, clazz, appInstance, classLoader, injections, context, owbCtx, additionalProviders,
+ deployPojo(appInfo.appId, webApp.contextRoot, appPrefix, clazz, appInstance, classLoader, injections, context, owbCtx, additionalProviders,
new ServiceConfiguration(PojoUtil.findConfiguration(pojoConfigurations, clazz.getName()), appInfo.services));
}
}
@@ -407,16 +407,16 @@ public abstract class RESTService implements ServerService, SelfManaging {
if (restEjbs.containsKey(clazz)) {
final BeanContext ctx = restEjbs.get(clazz).context;
if (hasEjbAndIsNotAManagedBean(restEjbs, clazz)) {
- deployEJB(webApp.contextRoot, appPrefix, restEjbs.get(clazz).context, additionalProviders, appInfo.services);
+ deployEJB(appInfo.appId, webApp.contextRoot, appPrefix, restEjbs.get(clazz).context, additionalProviders, appInfo.services);
} else {
- deployPojo(webApp.contextRoot, appPrefix, ctx.getBeanClass(), null, ctx.getClassLoader(), ctx.getInjections(), context,
+ deployPojo(appInfo.appId, webApp.contextRoot, appPrefix, ctx.getBeanClass(), null, ctx.getClassLoader(), ctx.getInjections(), context,
owbCtx, additionalProviders, new ServiceConfiguration(ctx.getProperties(), appInfo.services));
}
} else {
try {
final Class<?> loadedClazz = classLoader.loadClass(clazz);
pojoConfigurations = PojoUtil.findPojoConfig(pojoConfigurations, appInfo, webApp);
- deployPojo(webApp.contextRoot, appPrefix, loadedClazz, null, classLoader, injections, context, owbCtx,
+ deployPojo(appInfo.appId, webApp.contextRoot, appPrefix, loadedClazz, null, classLoader, injections, context, owbCtx,
additionalProviders,
new ServiceConfiguration(PojoUtil.findConfiguration(pojoConfigurations, loadedClazz.getName()), appInfo.services));
} catch (final ClassNotFoundException e) {
@@ -458,7 +458,7 @@ public abstract class RESTService implements ServerService, SelfManaging {
final RsHttpListener listener = createHttpListener();
final String host = findHost(contextRoot, appInfo.webApps);
- final RsRegistry.AddressInfo address = rsRegistry.createRsHttpListener(contextRoot, listener, classLoader, nopath.substring(NOPATH_PREFIX.length() - 1), host, auth, realm);
+ final RsRegistry.AddressInfo address = rsRegistry.createRsHttpListener(appInfo.appId, contextRoot, listener, classLoader, nopath.substring(NOPATH_PREFIX.length() - 1), host, auth, realm);
services.add(new DeployedService(address.complete, contextRoot, application.getClass().getName()));
listener.deployApplication(application, address.complete.substring(0, address.complete.length() - wildcard.length()), nopath.substring(NOPATH_PREFIX.length(), nopath.length() - wildcard.length()), additionalProviders, restEjbs, // app config
@@ -638,12 +638,12 @@ public abstract class RESTService implements ServerService, SelfManaging {
for (final Map.Entry<String, EJBRestServiceInfo> ejb : restEjbs.entrySet()) {
final BeanContext ctx = ejb.getValue().context;
if (BeanType.MANAGED.equals(ctx.getComponentType())) {
- deployPojo("", ejb.getValue().path, ctx.getBeanClass(), null, ctx.getClassLoader(), ctx.getInjections(),
+ deployPojo(appInfo.appId, "", ejb.getValue().path, ctx.getBeanClass(), null, ctx.getClassLoader(), ctx.getInjections(),
ctx.getJndiContext(),
containerSystem.getAppContext(appInfo.appId).getWebBeansContext(),
providers, new ServiceConfiguration(ctx.getProperties(), appInfo.services));
} else {
- deployEJB("", ejb.getValue().path, ctx, providers, appInfo.services);
+ deployEJB(appInfo.appId, "", ejb.getValue().path, ctx, providers, appInfo.services);
}
}
}
@@ -731,11 +731,11 @@ public abstract class RESTService implements ServerService, SelfManaging {
return restEjbs;
}
- private void deploySingleton(final String web, final String contextRoot, final Object o, final Application appInstance, final ClassLoader classLoader,
+ private void deploySingleton(final String appId, final String web, final String contextRoot, final Object o, final Application appInstance, final ClassLoader classLoader,
final Collection<Object> additionalProviders, final ServiceConfiguration configuration) {
final String nopath = getAddress(contextRoot, o.getClass());
final RsHttpListener listener = createHttpListener();
- final RsRegistry.AddressInfo address = rsRegistry.createRsHttpListener(web, listener, classLoader, nopath.substring(NOPATH_PREFIX.length() - 1), virtualHost, auth, realm);
+ final RsRegistry.AddressInfo address = rsRegistry.createRsHttpListener(appId, web, listener, classLoader, nopath.substring(NOPATH_PREFIX.length() - 1), virtualHost, auth, realm);
services.add(new DeployedService(address.complete, web, o.getClass().getName()));
listener.deploySingleton(contextRoot, getFullContext(address.base, contextRoot), o, appInstance, additionalProviders, configuration);
@@ -743,7 +743,8 @@ public abstract class RESTService implements ServerService, SelfManaging {
LOGGER.info("deployed REST singleton: " + o);
}
- private void deployPojo(final String web, final String contextRoot, final Class<?> loadedClazz, final Application app, final ClassLoader classLoader, final Collection<Injection> injections,
+ private void deployPojo(final String appId, final String web, final String contextRoot, final Class<?> loadedClazz, final Application app,
+ final ClassLoader classLoader, final Collection<Injection> injections,
final Context context, final WebBeansContext owbCtx, final Collection<Object> additionalProviders, final ServiceConfiguration config) {
if (loadedClazz.isInterface()) {
return;
@@ -751,7 +752,7 @@ public abstract class RESTService implements ServerService, SelfManaging {
final String nopath = getAddress(contextRoot, loadedClazz);
final RsHttpListener listener = createHttpListener();
- final RsRegistry.AddressInfo address = rsRegistry.createRsHttpListener(web, listener, classLoader, nopath.substring(NOPATH_PREFIX.length() - 1), virtualHost, auth, realm);
+ final RsRegistry.AddressInfo address = rsRegistry.createRsHttpListener(appId, web, listener, classLoader, nopath.substring(NOPATH_PREFIX.length() - 1), virtualHost, auth, realm);
services.add(new DeployedService(address.complete, contextRoot, loadedClazz.getName()));
listener.deployPojo(classLoader, contextRoot, getFullContext(address.base, contextRoot), loadedClazz, app, injections, context, owbCtx,
@@ -760,10 +761,11 @@ public abstract class RESTService implements ServerService, SelfManaging {
LOGGER.info("REST Service: " + address.complete + " -> Pojo " + loadedClazz.getName());
}
- private void deployEJB(final String web, final String context, final BeanContext beanContext, final Collection<Object> additionalProviders, final Collection<ServiceInfo> serviceInfos) {
+ private void deployEJB(final String appId, final String web, final String context, final BeanContext beanContext, final Collection<Object> additionalProviders,
+ final Collection<ServiceInfo> serviceInfos) {
final String nopath = getAddress(context, beanContext.getBeanClass());
final RsHttpListener listener = createHttpListener();
- final RsRegistry.AddressInfo address = rsRegistry.createRsHttpListener(web, listener, beanContext.getClassLoader(), nopath.substring(NOPATH_PREFIX.length() - 1), virtualHost, auth, realm);
+ final RsRegistry.AddressInfo address = rsRegistry.createRsHttpListener(appId, web, listener, beanContext.getClassLoader(), nopath.substring(NOPATH_PREFIX.length() - 1), virtualHost, auth, realm);
services.add(new DeployedService(address.complete, context, beanContext.getBeanClass().getName()));
listener.deployEJB(context, getFullContext(address.base, context), beanContext,
http://git-wip-us.apache.org/repos/asf/tomee/blob/97cee712/server/openejb-rest/src/main/java/org/apache/openejb/server/rest/RsRegistry.java
----------------------------------------------------------------------
diff --git a/server/openejb-rest/src/main/java/org/apache/openejb/server/rest/RsRegistry.java b/server/openejb-rest/src/main/java/org/apache/openejb/server/rest/RsRegistry.java
index d75dc04..f3041e2 100644
--- a/server/openejb-rest/src/main/java/org/apache/openejb/server/rest/RsRegistry.java
+++ b/server/openejb-rest/src/main/java/org/apache/openejb/server/rest/RsRegistry.java
@@ -22,7 +22,7 @@ import org.apache.openejb.server.httpd.HttpListener;
import java.util.List;
public interface RsRegistry {
- AddressInfo createRsHttpListener(String webContext, HttpListener listener, ClassLoader classLoader, String path, String virtualHost, String auth, String realm);
+ AddressInfo createRsHttpListener(String appId, String webContext, HttpListener listener, ClassLoader classLoader, String path, String virtualHost, String auth, String realm);
HttpListener removeListener(String context);
http://git-wip-us.apache.org/repos/asf/tomee/blob/97cee712/server/openejb-rest/src/main/java/org/apache/openejb/server/rest/RsRegistryImpl.java
----------------------------------------------------------------------
diff --git a/server/openejb-rest/src/main/java/org/apache/openejb/server/rest/RsRegistryImpl.java b/server/openejb-rest/src/main/java/org/apache/openejb/server/rest/RsRegistryImpl.java
index f6db204..4e71fd3 100644
--- a/server/openejb-rest/src/main/java/org/apache/openejb/server/rest/RsRegistryImpl.java
+++ b/server/openejb-rest/src/main/java/org/apache/openejb/server/rest/RsRegistryImpl.java
@@ -29,7 +29,7 @@ public class RsRegistryImpl extends OpenEJBHttpRegistry implements RsRegistry {
private Map<String, String> addresses = new HashMap<String, String>();
@Override
- public AddressInfo createRsHttpListener(String webContext, HttpListener listener, ClassLoader classLoader, String path, String virtualHost, String auth, String realm) {
+ public AddressInfo createRsHttpListener(String appId, String webContext, HttpListener listener, ClassLoader classLoader, String path, String virtualHost, String auth, String realm) {
final String address = HttpUtil.selectSingleAddress(getResolvedAddresses(path));
if ("BASIC".equals(auth)) { // important to wrap with basic wrapper before classloader wrapping
http://git-wip-us.apache.org/repos/asf/tomee/blob/97cee712/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 329106c..95b40cf 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
@@ -466,7 +466,7 @@ public class TomcatWebAppBuilder implements WebAppBuilder, ContextListener, Pare
}
}
- if (isAlreadyDeployed(webApp)) {
+ if (isAlreadyDeployed(appInfo, webApp)) {
continue;
}
@@ -515,7 +515,7 @@ public class TomcatWebAppBuilder implements WebAppBuilder, ContextListener, Pare
appParam.setValue(webApp.moduleId);
standardContext.addApplicationParameter(appParam);
- if (!isAlreadyDeployed(webApp)) {
+ if (!isAlreadyDeployed(appInfo, webApp)) {
if (standardContext.getPath() == null) {
if (webApp.contextRoot != null && webApp.contextRoot.startsWith("/")) {
standardContext.setPath(webApp.contextRoot);
@@ -542,7 +542,7 @@ public class TomcatWebAppBuilder implements WebAppBuilder, ContextListener, Pare
webApp.contextRoot = "";
}
- if (isAlreadyDeployed(webApp)) { // possible because of the previous renaming
+ if (isAlreadyDeployed(appInfo, webApp)) { // possible because of the previous renaming
continue;
}
@@ -580,11 +580,12 @@ public class TomcatWebAppBuilder implements WebAppBuilder, ContextListener, Pare
}
}
- private boolean isAlreadyDeployed(final WebAppInfo webApp) {
- final ContextInfo contextInfo = getContextInfo(webApp.host, webApp.contextRoot);
+ private boolean isAlreadyDeployed(final AppInfo appInfo, final WebAppInfo webApp) {
+ final String version = appVersion(appInfo);
+ final ContextInfo contextInfo = getContextInfo(webApp.host, webApp.contextRoot, version);
if (contextInfo != null && contextInfo.standardContext != null && contextInfo.standardContext.getState() == LifecycleState.FAILED) {
- synchronized (this) {
- infos.remove(getId(webApp.host, webApp.contextRoot));
+ synchronized (infos) {
+ infos.remove(getId(webApp.host, webApp.contextRoot, version));
}
return false;
}
@@ -718,8 +719,9 @@ public class TomcatWebAppBuilder implements WebAppBuilder, ContextListener, Pare
*/
@Override
public void undeployWebApps(final AppInfo appInfo) throws Exception {
+ final String version = appVersion(appInfo);
for (final WebAppInfo webApp : appInfo.webApps) {
- final ContextInfo contextInfo = getContextInfo(webApp.host, webApp.contextRoot);
+ final ContextInfo contextInfo = getContextInfo(webApp.host, webApp.contextRoot, version);
if (contextInfo != null) {
final StandardContext standardContext = contextInfo.standardContext;
@@ -956,7 +958,7 @@ public class TomcatWebAppBuilder implements WebAppBuilder, ContextListener, Pare
continue;
}
- final String wId = getId(webApp.host, webApp.contextRoot);
+ final String wId = getId(webApp.host, webApp.contextRoot, contextInfo.version);
if (id.equals(wId)) {
return webApp;
}
@@ -1228,7 +1230,7 @@ public class TomcatWebAppBuilder implements WebAppBuilder, ContextListener, Pare
// appInfo is null when deployment fails
if (contextInfo.appInfo != null) {
for (final WebAppInfo w : contextInfo.appInfo.webApps) {
- if (id.equals(getId(w.host, w.contextRoot)) || id.equals(getId(w.host, w.moduleId))) {
+ if (id.equals(getId(w.host, w.contextRoot, contextInfo.version)) || id.equals(getId(w.host, w.moduleId, contextInfo.version))) {
if (webAppInfo == null) {
webAppInfo = w;
} else if (w.host != null && w.host.equals(Contexts.getHostname(standardContext))) {
@@ -1516,7 +1518,7 @@ public class TomcatWebAppBuilder implements WebAppBuilder, ContextListener, Pare
// skip undeployment if restarting
final TomEEWebappClassLoader tomEEWebappClassLoader = lazyClassLoader(
- org.apache.catalina.Context.class.isInstance(child) ? org.apache.catalina.Context.class.cast(child) : null);
+ org.apache.catalina.Context.class.isInstance(child) ? org.apache.catalina.Context.class.cast(child) : null);
if (tomEEWebappClassLoader != null && tomEEWebappClassLoader.isRestarting()) {
return true;
}
@@ -1583,7 +1585,7 @@ public class TomcatWebAppBuilder implements WebAppBuilder, ContextListener, Pare
final String id = getId(standardContext);
WebAppInfo currentWebAppInfo = null;
for (final WebAppInfo webAppInfo : contextInfo.appInfo.webApps) {
- final String wId = getId(webAppInfo.host, webAppInfo.contextRoot);
+ final String wId = getId(webAppInfo.host, webAppInfo.contextRoot, contextInfo.version);
if (id.equals(wId)) {
currentWebAppInfo = webAppInfo;
break;
@@ -1750,6 +1752,14 @@ public class TomcatWebAppBuilder implements WebAppBuilder, ContextListener, Pare
addConfiguredDocBases(standardContext, contextInfo);
}
+ private static String appVersion(final AppInfo appInfo) {
+ if (appInfo != null && appInfo.webAppAlone && appInfo.appId != null) {
+ final int versionIndex = appInfo.appId.indexOf("##");
+ return versionIndex >= 0 ? appInfo.appId.substring(versionIndex) : "";
+ }
+ return "";
+ }
+
private void addConfiguredDocBases(final StandardContext standardContext, final ContextInfo contextInfo) {
if (contextInfo.appInfo.path != null) { // add external web resources
final String contextPath = standardContext.getServletContext().getContextPath();
@@ -2342,10 +2352,10 @@ public class TomcatWebAppBuilder implements WebAppBuilder, ContextListener, Pare
* @return id of the context
*/
private String getId(final StandardContext standardContext) {
- return getId(Contexts.getHostname(standardContext), standardContext.getName());
+ return getId(Contexts.getHostname(standardContext), standardContext.getPath(), standardContext.getWebappVersion());
}
- private String getId(final String host, final String context) {
+ private String getId(final String host, final String context, final String version) {
String contextRoot = context;
if (isRoot(contextRoot)) {
contextRoot = "";
@@ -2353,10 +2363,7 @@ public class TomcatWebAppBuilder implements WebAppBuilder, ContextListener, Pare
if (!contextRoot.startsWith("/")) {
contextRoot = "/" + contextRoot;
}
- if (host != null) {
- return host + contextRoot;
- }
- return hosts.getDefaultHost() + contextRoot;
+ return (host == null ? hosts.getDefaultHost() : host) + contextRoot + (version == null || version.isEmpty() ? "" : (version.startsWith("##") ? version : "##" + version));
}
/**
@@ -2379,13 +2386,13 @@ public class TomcatWebAppBuilder implements WebAppBuilder, ContextListener, Pare
*
* @return context info
*/
- private synchronized ContextInfo getContextInfo(final String webAppHost, final String webAppContextRoot) {
+ private synchronized ContextInfo getContextInfo(final String webAppHost, final String webAppContextRoot, final String version) {
String host = webAppHost;
if (host == null) {
host = hosts.getDefaultHost();
}
- final String id = getId(host, webAppContextRoot);
+ final String id = getId(host, webAppContextRoot, version);
final ContextInfo value;
synchronized (infos) {
@@ -2414,6 +2421,8 @@ public class TomcatWebAppBuilder implements WebAppBuilder, ContextListener, Pare
contextInfo = infos.get(id);
if (contextInfo == null) {
contextInfo = new ContextInfo();
+ final String webappVersion = standardContext.getWebappVersion();
+ contextInfo.version = webappVersion != null && !webappVersion.isEmpty() ? "##" + webappVersion : webappVersion;
contextInfo.standardContext = standardContext;
infos.put(id, contextInfo);
}
@@ -2427,9 +2436,22 @@ public class TomcatWebAppBuilder implements WebAppBuilder, ContextListener, Pare
* @param standardContext context
*/
private void removeContextInfo(final StandardContext standardContext) {
- final String id = getId(standardContext);
+ boolean found = false;
synchronized (infos) {
- infos.remove(id);
+ final Iterator<Map.Entry<String, ContextInfo>> info = infos.entrySet().iterator();
+ while (info.hasNext()) {
+ if (info.next().getValue().standardContext == standardContext) {
+ info.remove();
+ found = true;
+ break;
+ }
+ }
+ }
+ if (!found) { // unlikely
+ final String id = getId(standardContext);
+ synchronized (infos) {
+ infos.remove(id);
+ }
}
}
@@ -2439,6 +2461,7 @@ public class TomcatWebAppBuilder implements WebAppBuilder, ContextListener, Pare
public StandardContext standardContext;
public HostConfig deployer;
public Host host;
+ public String version;
public Collection<String> resourceNames = Collections.emptyList();
@Override
http://git-wip-us.apache.org/repos/asf/tomee/blob/97cee712/tomee/tomee-jaxrs/src/main/java/org/apache/tomee/webservices/TomcatRsRegistry.java
----------------------------------------------------------------------
diff --git a/tomee/tomee-jaxrs/src/main/java/org/apache/tomee/webservices/TomcatRsRegistry.java b/tomee/tomee-jaxrs/src/main/java/org/apache/tomee/webservices/TomcatRsRegistry.java
index 2f3d549..5475ff2 100644
--- a/tomee/tomee-jaxrs/src/main/java/org/apache/tomee/webservices/TomcatRsRegistry.java
+++ b/tomee/tomee-jaxrs/src/main/java/org/apache/tomee/webservices/TomcatRsRegistry.java
@@ -62,7 +62,7 @@ public class TomcatRsRegistry implements RsRegistry {
}
@Override
- public AddressInfo createRsHttpListener(final String webContext, final HttpListener listener, final ClassLoader classLoader, final String completePath, final String virtualHost, final String auth, final String realm) {
+ public AddressInfo createRsHttpListener(final String appId, final String webContext, final HttpListener listener, final ClassLoader classLoader, final String completePath, final String virtualHost, final String auth, final String realm) {
String path = webContext;
if (path == null) {
throw new NullPointerException("contextRoot is null");
@@ -82,7 +82,7 @@ public class TomcatRsRegistry implements RsRegistry {
if (host == null) {
for (final Host h : hosts) {
- context = findContext(h, webContext);
+ context = findContext(h, appId, webContext);
if (context != null) {
host = h;
if (classLoader != null && classLoader.equals(context.getLoader().getClassLoader())) {
@@ -95,7 +95,7 @@ public class TomcatRsRegistry implements RsRegistry {
throw new IllegalArgumentException("Invalid virtual host '" + virtualHost + "'. Do you have a matching Host entry in the server.xml?");
}
} else {
- context = findContext(host, webContext);
+ context = findContext(host, appId, webContext);
}
if (context == null) {
@@ -155,7 +155,14 @@ public class TomcatRsRegistry implements RsRegistry {
return completePath.substring((webContext.length() > 0 && !webContext.startsWith("/") ? 1 : 0) + webContext.length());
}
- private static Context findContext(final Container host, final String webContext) {
+ private static Context findContext(final Container host, final String appId, final String webContext) {
+ if (appId != null) { // when using versioning appId is like context#1235 but not the context itself so ensure to test appId first
+ final Context ctx = Context.class.cast(host.findChild('/' + appId));
+ if (ctx != null) {
+ return ctx;
+ }
+ }
+
Context webapp = Context.class.cast(host.findChild(webContext));
if (webapp == null && "/".equals(webContext)) { // ROOT
webapp = Context.class.cast(host.findChild(""));