You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cxf.apache.org by "Karl Goldstein (JIRA)" <ji...@apache.org> on 2007/08/11 20:47:43 UTC
[jira] Created: (CXF-906) ClassCastException in
CXFServlet.loadSpringBus when context initialization fails
ClassCastException in CXFServlet.loadSpringBus when context initialization fails
--------------------------------------------------------------------------------
Key: CXF-906
URL: https://issues.apache.org/jira/browse/CXF-906
Project: CXF
Issue Type: Bug
Components: Core
Affects Versions: 2.0
Environment: using Spring Framework 2.1 m2
Reporter: Karl Goldstein
Priority: Minor
CXFServlet.java line 136 obtains the Spring application context from the servlet context:
if (ctx == null) {
ctx = (ApplicationContext)svCtx
.getAttribute("org.springframework.web.context.WebApplicationContext.ROOT");
}
If the Spring application context failed to load however, Spring (somewhat inexplicably) sets this attribute to be the exception rather than the context. See org/springframework/web/context/ContextLoader.java line 202:
catch (RuntimeException ex) {
logger.error("Context initialization failed", ex);
servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, ex);
throw ex;
}
To avoid repeated ClassCastExceptions that obscure the underlying problem with the Spring application context, CXFServlet should check the type of the attribute before attempting to cast to ApplicationContext:
if (ctx == null) {
Object ctxObject = svCtx
.getAttribute("org.springframework.web.context.WebApplicationContext.ROOT");
if (ctxObject instanceof ApplicationContext) {
ctx = (ApplicationContext) ctxObject;
}
}
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (CXF-906) ClassCastException in
CXFServlet.loadSpringBus when context initialization fails
Posted by "Karl Goldstein (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CXF-906?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12519263 ]
Karl Goldstein commented on CXF-906:
------------------------------------
On second thought, I suppose it would be even better to check this attribute in CXFServlet.init() and stop initialization if the ApplicationContext is invalid (an exception).
> ClassCastException in CXFServlet.loadSpringBus when context initialization fails
> --------------------------------------------------------------------------------
>
> Key: CXF-906
> URL: https://issues.apache.org/jira/browse/CXF-906
> Project: CXF
> Issue Type: Bug
> Components: Core
> Affects Versions: 2.0
> Environment: using Spring Framework 2.1 m2
> Reporter: Karl Goldstein
> Priority: Minor
>
> CXFServlet.java line 136 obtains the Spring application context from the servlet context:
> if (ctx == null) {
> ctx = (ApplicationContext)svCtx
> .getAttribute("org.springframework.web.context.WebApplicationContext.ROOT");
> }
> If the Spring application context failed to load however, Spring (somewhat inexplicably) sets this attribute to be the exception rather than the context. See org/springframework/web/context/ContextLoader.java line 202:
> catch (RuntimeException ex) {
> logger.error("Context initialization failed", ex);
> servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, ex);
> throw ex;
> }
> To avoid repeated ClassCastExceptions that obscure the underlying problem with the Spring application context, CXFServlet should check the type of the attribute before attempting to cast to ApplicationContext:
> if (ctx == null) {
> Object ctxObject = svCtx
> .getAttribute("org.springframework.web.context.WebApplicationContext.ROOT");
> if (ctxObject instanceof ApplicationContext) {
> ctx = (ApplicationContext) ctxObject;
> }
> }
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Assigned: (CXF-906) ClassCastException in
CXFServlet.loadSpringBus when context initialization fails
Posted by "willem Jiang (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CXF-906?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
willem Jiang reassigned CXF-906:
--------------------------------
Assignee: willem Jiang
> ClassCastException in CXFServlet.loadSpringBus when context initialization fails
> --------------------------------------------------------------------------------
>
> Key: CXF-906
> URL: https://issues.apache.org/jira/browse/CXF-906
> Project: CXF
> Issue Type: Bug
> Components: Core
> Affects Versions: 2.0
> Environment: using Spring Framework 2.1 m2
> Reporter: Karl Goldstein
> Assignee: willem Jiang
> Priority: Minor
>
> CXFServlet.java line 136 obtains the Spring application context from the servlet context:
> if (ctx == null) {
> ctx = (ApplicationContext)svCtx
> .getAttribute("org.springframework.web.context.WebApplicationContext.ROOT");
> }
> If the Spring application context failed to load however, Spring (somewhat inexplicably) sets this attribute to be the exception rather than the context. See org/springframework/web/context/ContextLoader.java line 202:
> catch (RuntimeException ex) {
> logger.error("Context initialization failed", ex);
> servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, ex);
> throw ex;
> }
> To avoid repeated ClassCastExceptions that obscure the underlying problem with the Spring application context, CXFServlet should check the type of the attribute before attempting to cast to ApplicationContext:
> if (ctx == null) {
> Object ctxObject = svCtx
> .getAttribute("org.springframework.web.context.WebApplicationContext.ROOT");
> if (ctxObject instanceof ApplicationContext) {
> ctx = (ApplicationContext) ctxObject;
> }
> }
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Resolved: (CXF-906) ClassCastException in
CXFServlet.loadSpringBus when context initialization fails
Posted by "willem Jiang (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CXF-906?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
willem Jiang resolved CXF-906.
------------------------------
Resolution: Fixed
Fix Version/s: 2.1
The patch code has been applied into the SVN
> ClassCastException in CXFServlet.loadSpringBus when context initialization fails
> --------------------------------------------------------------------------------
>
> Key: CXF-906
> URL: https://issues.apache.org/jira/browse/CXF-906
> Project: CXF
> Issue Type: Bug
> Components: Core
> Affects Versions: 2.0
> Environment: using Spring Framework 2.1 m2
> Reporter: Karl Goldstein
> Assignee: willem Jiang
> Priority: Minor
> Fix For: 2.1
>
>
> CXFServlet.java line 136 obtains the Spring application context from the servlet context:
> if (ctx == null) {
> ctx = (ApplicationContext)svCtx
> .getAttribute("org.springframework.web.context.WebApplicationContext.ROOT");
> }
> If the Spring application context failed to load however, Spring (somewhat inexplicably) sets this attribute to be the exception rather than the context. See org/springframework/web/context/ContextLoader.java line 202:
> catch (RuntimeException ex) {
> logger.error("Context initialization failed", ex);
> servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, ex);
> throw ex;
> }
> To avoid repeated ClassCastExceptions that obscure the underlying problem with the Spring application context, CXFServlet should check the type of the attribute before attempting to cast to ApplicationContext:
> if (ctx == null) {
> Object ctxObject = svCtx
> .getAttribute("org.springframework.web.context.WebApplicationContext.ROOT");
> if (ctxObject instanceof ApplicationContext) {
> ctx = (ApplicationContext) ctxObject;
> }
> }
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.