You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cxf.apache.org by "William (BJ) Blackburn (JIRA)" <ji...@apache.org> on 2010/01/15 21:50:54 UTC

[jira] Created: (CXF-2620) CXFServlet fails to init with NPE at line 125 (updateContext) when run with embedded Jetty and Spring3 - works with Spring 2.5.6

CXFServlet fails to init with NPE at line 125 (updateContext) when run with embedded Jetty and Spring3 - works with Spring 2.5.6
--------------------------------------------------------------------------------------------------------------------------------

                 Key: CXF-2620
                 URL: https://issues.apache.org/jira/browse/CXF-2620
             Project: CXF
          Issue Type: Bug
          Components: Transports
    Affects Versions: 2.2.5
         Environment: Spring 3.0.0.RELEASE / Jetty 6.1.8 (embedded)
            Reporter: William (BJ) Blackburn


I have been using CXF 2.2.3 (also tested with 2.2.5) with Spring 2.5.6 and an embedded Jetty instance successfully for several months. After the release of Spring 3.0, I have tried migrating to the new Spring version. Now the CXF Servlet is failing with a nullpointerexception on the 'updateContext' method:

Caused by: java.lang.NullPointerException
	at org.apache.cxf.transport.servlet.CXFServlet.updateContext(CXFServlet.java:125)
	at org.apache.cxf.transport.servlet.CXFServlet.onApplicationEvent(CXFServlet.java:182)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:97)
	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:294)
	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:296)
	at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:858)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:419)

The line that is failing is:

   resourceManager.addResourceResolver(new ServletContextResourceResolver(servletConfig.getServletContext()));

I can only reproduce this issue using an 'embedded' jetty instance, I have attached a test case. By switching between spring 2.5.6 and spring 3.0, you can see from the log output that the servlet successfully initialized under 2.5.6, but fails under 3.0.

I understand this may be a very narrow case involving only this method of loading the servlet, so if no fix is required in CXF, some advice as to a workaround would be very welcome. Thank you.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (CXF-2620) CXFServlet fails to init with NPE at line 125 (updateContext) when run with embedded Jetty and Spring3 - works with Spring 2.5.6

Posted by "Daniel Kulp (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CXF-2620?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Daniel Kulp resolved CXF-2620.
------------------------------

       Resolution: Fixed
    Fix Version/s: 2.2.6
                   2.1.9


Added some NPE guards and "inRefresh" guards to guard against this.

> CXFServlet fails to init with NPE at line 125 (updateContext) when run with embedded Jetty and Spring3 - works with Spring 2.5.6
> --------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: CXF-2620
>                 URL: https://issues.apache.org/jira/browse/CXF-2620
>             Project: CXF
>          Issue Type: Bug
>          Components: Transports
>    Affects Versions: 2.2.5
>         Environment: Spring 3.0.0.RELEASE / Jetty 6.1.8 (embedded)
>            Reporter: William (BJ) Blackburn
>            Assignee: Daniel Kulp
>             Fix For: 2.1.9, 2.2.6
>
>         Attachments: embedded-jetty-tests.zip
>
>
> I have been using CXF 2.2.3 (also tested with 2.2.5) with Spring 2.5.6 and an embedded Jetty instance successfully for several months. After the release of Spring 3.0, I have tried migrating to the new Spring version. Now the CXF Servlet is failing with a nullpointerexception on the 'updateContext' method:
> Caused by: java.lang.NullPointerException
> 	at org.apache.cxf.transport.servlet.CXFServlet.updateContext(CXFServlet.java:125)
> 	at org.apache.cxf.transport.servlet.CXFServlet.onApplicationEvent(CXFServlet.java:182)
> 	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:97)
> 	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:294)
> 	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:296)
> 	at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:858)
> 	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:419)
> The line that is failing is:
>    resourceManager.addResourceResolver(new ServletContextResourceResolver(servletConfig.getServletContext()));
> I can only reproduce this issue using an 'embedded' jetty instance, I have attached a test case. By switching between spring 2.5.6 and spring 3.0, you can see from the log output that the servlet successfully initialized under 2.5.6, but fails under 3.0.
> I understand this may be a very narrow case involving only this method of loading the servlet, so if no fix is required in CXF, some advice as to a workaround would be very welcome. Thank you.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (CXF-2620) CXFServlet fails to init with NPE at line 125 (updateContext) when run with embedded Jetty and Spring3 - works with Spring 2.5.6

Posted by "William (BJ) Blackburn (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CXF-2620?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12801931#action_12801931 ] 

William (BJ) Blackburn commented on CXF-2620:
---------------------------------------------

I've been working on this more - and it now appears to me to have more to do with some mysterious change in Spring between 2.5.6 and 3.0 - I do not think CXF is involved and this issue can probably be closed (although any additional info anyone has is appreciated).

The code that fails in CXFServlet under Spring 3.0 is at line 125:

    resourceManager.addResourceResolver(new ServletContextResourceResolver(
                                               servletConfig.getServletContext()));

specifically 'servletConfig' is null when the sample code is run under Spring 3.0 and is valid when run with 2.5.6. I have been unable to determine what Spring would even have to do with the servlet config.

> CXFServlet fails to init with NPE at line 125 (updateContext) when run with embedded Jetty and Spring3 - works with Spring 2.5.6
> --------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: CXF-2620
>                 URL: https://issues.apache.org/jira/browse/CXF-2620
>             Project: CXF
>          Issue Type: Bug
>          Components: Transports
>    Affects Versions: 2.2.5
>         Environment: Spring 3.0.0.RELEASE / Jetty 6.1.8 (embedded)
>            Reporter: William (BJ) Blackburn
>         Attachments: embedded-jetty-tests.zip
>
>
> I have been using CXF 2.2.3 (also tested with 2.2.5) with Spring 2.5.6 and an embedded Jetty instance successfully for several months. After the release of Spring 3.0, I have tried migrating to the new Spring version. Now the CXF Servlet is failing with a nullpointerexception on the 'updateContext' method:
> Caused by: java.lang.NullPointerException
> 	at org.apache.cxf.transport.servlet.CXFServlet.updateContext(CXFServlet.java:125)
> 	at org.apache.cxf.transport.servlet.CXFServlet.onApplicationEvent(CXFServlet.java:182)
> 	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:97)
> 	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:294)
> 	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:296)
> 	at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:858)
> 	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:419)
> The line that is failing is:
>    resourceManager.addResourceResolver(new ServletContextResourceResolver(servletConfig.getServletContext()));
> I can only reproduce this issue using an 'embedded' jetty instance, I have attached a test case. By switching between spring 2.5.6 and spring 3.0, you can see from the log output that the servlet successfully initialized under 2.5.6, but fails under 3.0.
> I understand this may be a very narrow case involving only this method of loading the servlet, so if no fix is required in CXF, some advice as to a workaround would be very welcome. Thank you.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (CXF-2620) CXFServlet fails to init with NPE at line 125 (updateContext) when run with embedded Jetty and Spring3 - works with Spring 2.5.6

Posted by "William (BJ) Blackburn (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CXF-2620?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

William (BJ) Blackburn updated CXF-2620:
----------------------------------------

    Attachment: embedded-jetty-tests.zip

switch between spring 3.0 and 2.5.6 and note output

> CXFServlet fails to init with NPE at line 125 (updateContext) when run with embedded Jetty and Spring3 - works with Spring 2.5.6
> --------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: CXF-2620
>                 URL: https://issues.apache.org/jira/browse/CXF-2620
>             Project: CXF
>          Issue Type: Bug
>          Components: Transports
>    Affects Versions: 2.2.5
>         Environment: Spring 3.0.0.RELEASE / Jetty 6.1.8 (embedded)
>            Reporter: William (BJ) Blackburn
>         Attachments: embedded-jetty-tests.zip
>
>
> I have been using CXF 2.2.3 (also tested with 2.2.5) with Spring 2.5.6 and an embedded Jetty instance successfully for several months. After the release of Spring 3.0, I have tried migrating to the new Spring version. Now the CXF Servlet is failing with a nullpointerexception on the 'updateContext' method:
> Caused by: java.lang.NullPointerException
> 	at org.apache.cxf.transport.servlet.CXFServlet.updateContext(CXFServlet.java:125)
> 	at org.apache.cxf.transport.servlet.CXFServlet.onApplicationEvent(CXFServlet.java:182)
> 	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:97)
> 	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:294)
> 	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:296)
> 	at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:858)
> 	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:419)
> The line that is failing is:
>    resourceManager.addResourceResolver(new ServletContextResourceResolver(servletConfig.getServletContext()));
> I can only reproduce this issue using an 'embedded' jetty instance, I have attached a test case. By switching between spring 2.5.6 and spring 3.0, you can see from the log output that the servlet successfully initialized under 2.5.6, but fails under 3.0.
> I understand this may be a very narrow case involving only this method of loading the servlet, so if no fix is required in CXF, some advice as to a workaround would be very welcome. Thank you.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (CXF-2620) CXFServlet fails to init with NPE at line 125 (updateContext) when run with embedded Jetty and Spring3 - works with Spring 2.5.6

Posted by "William (BJ) Blackburn (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CXF-2620?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12801952#action_12801952 ] 

William (BJ) Blackburn commented on CXF-2620:
---------------------------------------------

Please forgive this piecemeal narrative. It now appears that something could be done in CXFServlet to insulate against this issue. I have discovered that the problem is with the implementation of 'onApplicationEvent' in CXFServlet. 

I added some tracing to this code. Under Spring 2.5.6 - I saw no evidence that this method was ever called at all. When running under Spring 3.0 this method was called multiple times - the first call happening BEFORE  servletConfig was actually available, and subsequently two more times, resulting in unnecessary context updates that resulted in this information log entry:

    INFO: Servlet transport factory already registered

It seems that at minimum, the execution of updateContext should only happen if the ServletConfig is non-null. It also appears that the use of the 'inRefresh' flag is insufficient to guard against rapid fire repeat events as seem to be raised in Spring 3.0.

> CXFServlet fails to init with NPE at line 125 (updateContext) when run with embedded Jetty and Spring3 - works with Spring 2.5.6
> --------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: CXF-2620
>                 URL: https://issues.apache.org/jira/browse/CXF-2620
>             Project: CXF
>          Issue Type: Bug
>          Components: Transports
>    Affects Versions: 2.2.5
>         Environment: Spring 3.0.0.RELEASE / Jetty 6.1.8 (embedded)
>            Reporter: William (BJ) Blackburn
>         Attachments: embedded-jetty-tests.zip
>
>
> I have been using CXF 2.2.3 (also tested with 2.2.5) with Spring 2.5.6 and an embedded Jetty instance successfully for several months. After the release of Spring 3.0, I have tried migrating to the new Spring version. Now the CXF Servlet is failing with a nullpointerexception on the 'updateContext' method:
> Caused by: java.lang.NullPointerException
> 	at org.apache.cxf.transport.servlet.CXFServlet.updateContext(CXFServlet.java:125)
> 	at org.apache.cxf.transport.servlet.CXFServlet.onApplicationEvent(CXFServlet.java:182)
> 	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:97)
> 	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:294)
> 	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:296)
> 	at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:858)
> 	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:419)
> The line that is failing is:
>    resourceManager.addResourceResolver(new ServletContextResourceResolver(servletConfig.getServletContext()));
> I can only reproduce this issue using an 'embedded' jetty instance, I have attached a test case. By switching between spring 2.5.6 and spring 3.0, you can see from the log output that the servlet successfully initialized under 2.5.6, but fails under 3.0.
> I understand this may be a very narrow case involving only this method of loading the servlet, so if no fix is required in CXF, some advice as to a workaround would be very welcome. Thank you.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Assigned: (CXF-2620) CXFServlet fails to init with NPE at line 125 (updateContext) when run with embedded Jetty and Spring3 - works with Spring 2.5.6

Posted by "Daniel Kulp (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CXF-2620?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Daniel Kulp reassigned CXF-2620:
--------------------------------

    Assignee: Daniel Kulp

> CXFServlet fails to init with NPE at line 125 (updateContext) when run with embedded Jetty and Spring3 - works with Spring 2.5.6
> --------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: CXF-2620
>                 URL: https://issues.apache.org/jira/browse/CXF-2620
>             Project: CXF
>          Issue Type: Bug
>          Components: Transports
>    Affects Versions: 2.2.5
>         Environment: Spring 3.0.0.RELEASE / Jetty 6.1.8 (embedded)
>            Reporter: William (BJ) Blackburn
>            Assignee: Daniel Kulp
>         Attachments: embedded-jetty-tests.zip
>
>
> I have been using CXF 2.2.3 (also tested with 2.2.5) with Spring 2.5.6 and an embedded Jetty instance successfully for several months. After the release of Spring 3.0, I have tried migrating to the new Spring version. Now the CXF Servlet is failing with a nullpointerexception on the 'updateContext' method:
> Caused by: java.lang.NullPointerException
> 	at org.apache.cxf.transport.servlet.CXFServlet.updateContext(CXFServlet.java:125)
> 	at org.apache.cxf.transport.servlet.CXFServlet.onApplicationEvent(CXFServlet.java:182)
> 	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:97)
> 	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:294)
> 	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:296)
> 	at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:858)
> 	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:419)
> The line that is failing is:
>    resourceManager.addResourceResolver(new ServletContextResourceResolver(servletConfig.getServletContext()));
> I can only reproduce this issue using an 'embedded' jetty instance, I have attached a test case. By switching between spring 2.5.6 and spring 3.0, you can see from the log output that the servlet successfully initialized under 2.5.6, but fails under 3.0.
> I understand this may be a very narrow case involving only this method of loading the servlet, so if no fix is required in CXF, some advice as to a workaround would be very welcome. Thank you.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.