summaryrefslogtreecommitdiffstats
path: root/server/src
diff options
context:
space:
mode:
authorArtur Signell <artur@vaadin.com>2016-08-30 14:23:43 +0300
committerVaadin Code Review <review@vaadin.com>2016-08-30 15:46:09 +0000
commit1aed1bee96aac99ac0041aeb7a36d05dd6eff677 (patch)
tree65f2da15c49a01c55679c456c0e3febd894d25c9 /server/src
parent07325917588193e4911a1045810ad16140d06a8d (diff)
downloadvaadin-framework-1aed1bee96aac99ac0041aeb7a36d05dd6eff677.tar.gz
vaadin-framework-1aed1bee96aac99ac0041aeb7a36d05dd6eff677.zip
Use servlet context classloader when finding servlet class for websockets (#20024)
Change-Id: Ia885ecebe854c0aeda47be2bbc9a9d8a47a03d5c
Diffstat (limited to 'server/src')
-rw-r--r--server/src/main/java/com/vaadin/server/communication/JSR356WebsocketInitializer.java10
1 files changed, 7 insertions, 3 deletions
diff --git a/server/src/main/java/com/vaadin/server/communication/JSR356WebsocketInitializer.java b/server/src/main/java/com/vaadin/server/communication/JSR356WebsocketInitializer.java
index fdbb4b7deb..95b796a2c7 100644
--- a/server/src/main/java/com/vaadin/server/communication/JSR356WebsocketInitializer.java
+++ b/server/src/main/java/com/vaadin/server/communication/JSR356WebsocketInitializer.java
@@ -113,7 +113,7 @@ public class JSR356WebsocketInitializer implements ServletContextListener {
for (String servletName : regs.keySet()) {
ServletRegistration servletRegistration = regs.get(servletName);
- if (isVaadinServlet(servletRegistration)) {
+ if (isVaadinServlet(servletRegistration, servletContext)) {
try {
initAtmosphereForVaadinServlet(servletRegistration,
servletContext);
@@ -193,7 +193,8 @@ public class JSR356WebsocketInitializer implements ServletContextListener {
* @return false if the servlet is definitely not a Vaadin servlet, true
* otherwise
*/
- protected boolean isVaadinServlet(ServletRegistration servletRegistration) {
+ protected boolean isVaadinServlet(ServletRegistration servletRegistration,
+ ServletContext servletContext) {
try {
String servletClassName = servletRegistration.getClassName();
if (servletClassName.equals("com.ibm.ws.wsoc.WsocServlet")) {
@@ -201,7 +202,10 @@ public class JSR356WebsocketInitializer implements ServletContextListener {
// dynamically added
return false;
}
- Class<?> servletClass = Class.forName(servletClassName);
+ // Must use servletContext class loader to load servlet class to
+ // work correctly in an OSGi environment (#20024)
+ Class<?> servletClass = servletContext.getClassLoader()
+ .loadClass(servletClassName);
return VaadinServlet.class.isAssignableFrom(servletClass);
} catch (Exception e) {
// This will fail in OSGi environments, assume everything is a