Hi Jim,

Thanks for the update,

I was concerned about

>> java.lang.NullPointerException: null
>>      at
>> org.apache.cxf.jaxrs.impl.tl.ThreadLocalProviders.getContextResolver(ThreadLocalProviders.java:50)

should we still investigate it ? I'm just not exactly sure how a thread local cache can be affected such that NPE is thrown, even though there were issues with Bus references before your fix.

May the following sequence can explain: the thread creates a context, two tests are started, the thread finishes one test, clears a context, and now finishes the 2nd test, but the context has gone. This can explain it. If you think it does not then please create a test project for me to investigate it further

Thanks, Sergey

On 29/11/13 10:55, Jim Talbut wrote:
On 29/11/2013 09:04, Jim Talbut wrote:
Hi,

In my JUnit tests I have two Spring-based tests that declare JAX-RS
providers (on different local ports)

The tests both work when run independently, but when I run them both
together (which will mean Spring keeps the contexts around after the
test finishes) I get this error:
08:58:12.285 [qtp842577946-28] ERROR u.c.s.s.a.s.CatchAllExceptionMapper
- Exception caught:
java.lang.NullPointerException: null
     at
org.apache.cxf.jaxrs.impl.tl.ThreadLocalProviders.getContextResolver(ThreadLocalProviders.java:50)

~[cxf-rt-frontend-jaxrs-2.7.7.jar:2.7.7]
     at
com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider._locateMapperViaProvider(JacksonJsonProvider.java:203)


Ahah!

Why do I always spend ages looking for a solution then find it soon
after mailing this group? :)
I found the answer courtesy of this:
http://camel.465427.n5.nabble.com/Problem-using-unit-test-spring-cxf-td5725603.html


In my case clearing the bus worked sometimes, but some tests still
failed, so I set it to the correct bus too.
Putting the following in the base class that all the tests derive from
makes the problem go away:

     @Autowired
     protected Bus cxf;

     @Before
     public void prepare() {
         BusFactory.setDefaultBus(cxf);
     }

     @After
     public void cleanup() {
         BusFactory.setDefaultBus(null);
     }

Jim



--
Sergey Beryozkin

Talend Community Coders
http://coders.talend.com/

Blog: http://sberyozkin.blogspot.com

Reply via email to