Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
b4aaeaac
Commit
b4aaeaac
authored
Jun 12, 2014
by
Dave Syer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Set Thread context class loader while Tomcat starts up
Fixes gh-1085
parent
c0efd3a2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
0 deletions
+14
-0
TomcatEmbeddedContext.java
...k/boot/context/embedded/tomcat/TomcatEmbeddedContext.java
+14
-0
No files found.
spring-boot/src/main/java/org/springframework/boot/context/embedded/tomcat/TomcatEmbeddedContext.java
View file @
b4aaeaac
...
@@ -18,6 +18,7 @@ package org.springframework.boot.context.embedded.tomcat;
...
@@ -18,6 +18,7 @@ package org.springframework.boot.context.embedded.tomcat;
import
org.apache.catalina.Container
;
import
org.apache.catalina.Container
;
import
org.apache.catalina.core.StandardContext
;
import
org.apache.catalina.core.StandardContext
;
import
org.springframework.util.ClassUtils
;
/**
/**
* Tomcat {@link StandardContext} used by {@link TomcatEmbeddedServletContainer} to
* Tomcat {@link StandardContext} used by {@link TomcatEmbeddedServletContainer} to
...
@@ -32,7 +33,20 @@ class TomcatEmbeddedContext extends StandardContext {
...
@@ -32,7 +33,20 @@ class TomcatEmbeddedContext extends StandardContext {
}
}
public
void
deferredLoadOnStartup
()
{
public
void
deferredLoadOnStartup
()
{
// Some older Servlet frameworks (e.g. Struts, BIRT) use the Thread context class
// loader to create servlet instances in this phase. If they do that and then try
// to initialize them later the class loader may have changed, so wrap the call to
// loadOnStartup in what we think its going to be the main webapp classloader at
// runtime.
ClassLoader
classLoader
=
getLoader
().
getClassLoader
();
ClassLoader
existingLoader
=
null
;
if
(
classLoader
!=
null
)
{
existingLoader
=
ClassUtils
.
overrideThreadContextClassLoader
(
classLoader
);
}
super
.
loadOnStartup
(
findChildren
());
super
.
loadOnStartup
(
findChildren
());
if
(
existingLoader
!=
null
)
{
ClassUtils
.
overrideThreadContextClassLoader
(
existingLoader
);
}
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment