From 451e27e7369e6d75088926ab753aa7d53e3d18b7 Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Wed, 31 Dec 2014 16:32:58 +0100 Subject: [PATCH 1/6] 454291 Added busy threads JMX attribute to QueuedThreadPool Also-by: Tomasz Nurkiewicz Signed-off-by: Greg Wilkins --- .../org/eclipse/jetty/util/thread/QueuedThreadPool.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/thread/QueuedThreadPool.java b/jetty-util/src/main/java/org/eclipse/jetty/util/thread/QueuedThreadPool.java index b395e725262..57cbc71ea46 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/thread/QueuedThreadPool.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/thread/QueuedThreadPool.java @@ -405,6 +405,15 @@ public class QueuedThreadPool extends AbstractLifeCycle implements SizedThreadPo return _threadsIdle.get(); } + /** + * @return The number of busy threads in the pool + */ + @ManagedAttribute("total number of busy threads in the pool") + public int getBusyThreads() + { + return getThreads() - getIdleThreads(); + } + /** * @return True if the pool is at maxThreads and there are not more idle threads than queued jobs */ From c92712779b8da4dd922eb20ac4a22b568656dde9 Mon Sep 17 00:00:00 2001 From: Jan Bartel Date: Thu, 1 Jan 2015 12:03:21 +0100 Subject: [PATCH 2/6] 456426 Exception on context undeploy from EnvConfiguration --- .../jetty/plus/webapp/EnvConfiguration.java | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/jetty-plus/src/main/java/org/eclipse/jetty/plus/webapp/EnvConfiguration.java b/jetty-plus/src/main/java/org/eclipse/jetty/plus/webapp/EnvConfiguration.java index 6db338eacc5..fc5b5ef380d 100644 --- a/jetty-plus/src/main/java/org/eclipse/jetty/plus/webapp/EnvConfiguration.java +++ b/jetty-plus/src/main/java/org/eclipse/jetty/plus/webapp/EnvConfiguration.java @@ -185,26 +185,20 @@ public class EnvConfiguration extends AbstractConfiguration @Override public void destroy (WebAppContext context) throws Exception { - ClassLoader old_loader = Thread.currentThread().getContextClassLoader(); - Thread.currentThread().setContextClassLoader(context.getClassLoader()); - ContextFactory.associateClassLoader(context.getClassLoader()); - try { - //unbind any NamingEntries that were configured in this webapp's name space - + //unbind any NamingEntries that were configured in this webapp's name space NamingContext scopeContext = (NamingContext)NamingEntryUtil.getContextForScope(context); scopeContext.getParent().destroySubcontext(scopeContext.getName()); } catch (NameNotFoundException e) { LOG.ignore(e); - LOG.debug("No naming entries configured in environment for webapp "+context); + LOG.debug("No jndi entries scoped to webapp {}", context); } - finally + catch (NamingException e) { - ContextFactory.disassociateClassLoader(); - Thread.currentThread().setContextClassLoader(old_loader); + LOG.debug("Error unbinding jndi entries scoped to webapp "+context, e); } } From b59782acf8d73d7d8e54880fbc9e430fd23799d2 Mon Sep 17 00:00:00 2001 From: Jan Bartel Date: Thu, 1 Jan 2015 15:53:33 +0100 Subject: [PATCH 3/6] 452201 Set the container classloader for osgi during webbundle undeploy --- .../eclipse/jetty/osgi/boot/OSGiDeployer.java | 31 +++++++++++++++++-- .../jetty/osgi/boot/OSGiUndeployer.java | 22 ++++++++++++- .../serverfactory/ServerInstanceWrapper.java | 4 +-- 3 files changed, 51 insertions(+), 6 deletions(-) diff --git a/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/OSGiDeployer.java b/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/OSGiDeployer.java index eab610f066e..46af4885d95 100644 --- a/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/OSGiDeployer.java +++ b/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/OSGiDeployer.java @@ -21,6 +21,7 @@ package org.eclipse.jetty.osgi.boot; import org.eclipse.jetty.deploy.App; import org.eclipse.jetty.deploy.bindings.StandardDeployer; import org.eclipse.jetty.deploy.graph.Node; +import org.eclipse.jetty.osgi.boot.internal.serverfactory.ServerInstanceWrapper; import org.eclipse.jetty.osgi.boot.utils.EventSender; @@ -34,6 +35,15 @@ import org.eclipse.jetty.osgi.boot.utils.EventSender; public class OSGiDeployer extends StandardDeployer { + private ServerInstanceWrapper _server; + + /* ------------------------------------------------------------ */ + public OSGiDeployer (ServerInstanceWrapper server) + { + _server = server; + } + + /* ------------------------------------------------------------ */ public void processBinding(Node node, App app) throws Exception { @@ -41,14 +51,14 @@ public class OSGiDeployer extends StandardDeployer //OSGi Enterprise Spec only wants an event sent if its a webapp bundle (ie not a ContextHandler) if (!(app instanceof AbstractOSGiApp)) { - super.processBinding(node,app); + doProcessBinding(node,app); } else { EventSender.getInstance().send(EventSender.DEPLOYING_EVENT, ((AbstractOSGiApp)app).getBundle(), app.getContextPath()); try { - super.processBinding(node,app); + doProcessBinding(node,app); ((AbstractOSGiApp)app).registerAsOSGiService(); EventSender.getInstance().send(EventSender.DEPLOYED_EVENT, ((AbstractOSGiApp)app).getBundle(), app.getContextPath()); } @@ -58,6 +68,21 @@ public class OSGiDeployer extends StandardDeployer throw e; } } - + } + + + /* ------------------------------------------------------------ */ + protected void doProcessBinding (Node node, App app) throws Exception + { + ClassLoader old = Thread.currentThread().getContextClassLoader(); + Thread.currentThread().setContextClassLoader(_server.getParentClassLoaderForWebapps()); + try + { + super.processBinding(node,app); + } + finally + { + Thread.currentThread().setContextClassLoader(old); + } } } diff --git a/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/OSGiUndeployer.java b/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/OSGiUndeployer.java index 314a87a0cea..645723af5ac 100644 --- a/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/OSGiUndeployer.java +++ b/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/OSGiUndeployer.java @@ -21,6 +21,7 @@ package org.eclipse.jetty.osgi.boot; import org.eclipse.jetty.deploy.App; import org.eclipse.jetty.deploy.bindings.StandardUndeployer; import org.eclipse.jetty.deploy.graph.Node; +import org.eclipse.jetty.osgi.boot.internal.serverfactory.ServerInstanceWrapper; import org.eclipse.jetty.osgi.boot.utils.EventSender; @@ -35,11 +36,30 @@ import org.eclipse.jetty.osgi.boot.utils.EventSender; */ public class OSGiUndeployer extends StandardUndeployer { + private ServerInstanceWrapper _server; + + + /* ------------------------------------------------------------ */ + public OSGiUndeployer (ServerInstanceWrapper server) + { + _server = server; + } + + /* ------------------------------------------------------------ */ public void processBinding(Node node, App app) throws Exception { EventSender.getInstance().send(EventSender.UNDEPLOYING_EVENT, ((AbstractOSGiApp)app).getBundle(), app.getContextPath()); - super.processBinding(node,app); + ClassLoader old = Thread.currentThread().getContextClassLoader(); + Thread.currentThread().setContextClassLoader(_server.getParentClassLoaderForWebapps()); + try + { + super.processBinding(node,app); + } + finally + { + Thread.currentThread().setContextClassLoader(old); + } EventSender.getInstance().send(EventSender.UNDEPLOYED_EVENT, ((AbstractOSGiApp)app).getBundle(), app.getContextPath()); ((AbstractOSGiApp)app).deregisterAsOSGiService(); } diff --git a/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/internal/serverfactory/ServerInstanceWrapper.java b/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/internal/serverfactory/ServerInstanceWrapper.java index c4bc8c529c5..94b0eec5090 100644 --- a/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/internal/serverfactory/ServerInstanceWrapper.java +++ b/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/internal/serverfactory/ServerInstanceWrapper.java @@ -382,10 +382,10 @@ public class ServerInstanceWrapper _deploymentManager.setUseStandardBindings(false); List deploymentLifeCycleBindings = new ArrayList(); - deploymentLifeCycleBindings.add(new OSGiDeployer()); + deploymentLifeCycleBindings.add(new OSGiDeployer(this)); deploymentLifeCycleBindings.add(new StandardStarter()); deploymentLifeCycleBindings.add(new StandardStopper()); - deploymentLifeCycleBindings.add(new OSGiUndeployer()); + deploymentLifeCycleBindings.add(new OSGiUndeployer(this)); _deploymentManager.setLifeCycleBindings(deploymentLifeCycleBindings); if (!providerClassNames.contains(BundleWebAppProvider.class.getName())) From 381227cd9d39d948cd097be893b8a0abb0c44187 Mon Sep 17 00:00:00 2001 From: Jan Bartel Date: Thu, 1 Jan 2015 17:25:10 +0100 Subject: [PATCH 4/6] 456486 Jar containing ServiceContainerInitializer impl not found in TCCL in osgi --- .../jetty/annotations/AnnotationConfiguration.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/AnnotationConfiguration.java b/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/AnnotationConfiguration.java index c0a742d2e14..b018deb25f8 100644 --- a/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/AnnotationConfiguration.java +++ b/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/AnnotationConfiguration.java @@ -21,6 +21,7 @@ package org.eclipse.jetty.annotations; import java.io.IOException; import java.net.MalformedURLException; import java.net.URI; +import java.net.URL; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; @@ -726,7 +727,15 @@ public class AnnotationConfiguration extends AbstractConfiguration public Resource getJarFor (ServletContainerInitializer service) throws MalformedURLException, IOException { - String loadingJarName = Thread.currentThread().getContextClassLoader().getResource(service.getClass().getName().replace('.','/')+".class").toString(); + //try the thread context classloader to get the jar that loaded the class + URL jarURL = Thread.currentThread().getContextClassLoader().getResource(service.getClass().getName().replace('.','/')+".class"); + + //if for some reason that failed (eg we're in osgi and the TCCL does not know about the service) try the classloader that + //loaded the class + if (jarURL == null) + jarURL = service.getClass().getClassLoader().getResource(service.getClass().getName().replace('.','/')+".class"); + + String loadingJarName = jarURL.toString(); int i = loadingJarName.indexOf(".jar"); if (i < 0) @@ -830,7 +839,6 @@ public class AnnotationConfiguration extends AbstractConfiguration { ArrayList nonExcludedInitializers = new ArrayList(); - //We use the ServiceLoader mechanism to find the ServletContainerInitializer classes to inspect long start = 0; From b1f1ebcc727d698054e619d9b89917961fcd38e9 Mon Sep 17 00:00:00 2001 From: Jan Bartel Date: Fri, 2 Jan 2015 18:29:52 +0100 Subject: [PATCH 5/6] 448944 Provide m2e lifecycle mapping metadata for jetty-jspc-maven-plugin --- .../m2e/lifecycle-mapping-metadata.xml | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 jetty-jspc-maven-plugin/src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml diff --git a/jetty-jspc-maven-plugin/src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml b/jetty-jspc-maven-plugin/src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml new file mode 100644 index 00000000000..dd49e822570 --- /dev/null +++ b/jetty-jspc-maven-plugin/src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + jspc + + + + + + + + From 3abfbe26b391a7486fd3eb68586dad981bf77de8 Mon Sep 17 00:00:00 2001 From: Simone Bordet Date: Tue, 6 Jan 2015 17:29:44 +0100 Subject: [PATCH 6/6] Using the provider string when creating the SSLContext in case of no keystore. --- .../java/org/eclipse/jetty/util/ssl/SslContextFactory.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/ssl/SslContextFactory.java b/jetty-util/src/main/java/org/eclipse/jetty/util/ssl/SslContextFactory.java index ec6eef17914..39bcc3164f2 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/ssl/SslContextFactory.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/ssl/SslContextFactory.java @@ -258,7 +258,7 @@ public class SslContextFactory extends AbstractLifeCycle } SecureRandom secureRandom = (_secureRandomAlgorithm == null)?null:SecureRandom.getInstance(_secureRandomAlgorithm); - SSLContext context = SSLContext.getInstance(_sslProtocol); + SSLContext context = _sslProvider == null ? SSLContext.getInstance(_sslProtocol) : SSLContext.getInstance(_sslProtocol, _sslProvider); context.init(null, trust_managers, secureRandom); _context = context; } @@ -299,7 +299,7 @@ public class SslContextFactory extends AbstractLifeCycle TrustManager[] trustManagers = getTrustManagers(trustStore,crls); SecureRandom secureRandom = (_secureRandomAlgorithm == null)?null:SecureRandom.getInstance(_secureRandomAlgorithm); - SSLContext context = _sslProvider == null ? SSLContext.getInstance(_sslProtocol) : SSLContext.getInstance(_sslProtocol,_sslProvider); + SSLContext context = _sslProvider == null ? SSLContext.getInstance(_sslProtocol) : SSLContext.getInstance(_sslProtocol, _sslProvider); context.init(keyManagers,trustManagers,secureRandom); _context = context; }