Bug 999570 - Client side CXF bus incorrectly caches service endpoint information
Summary: Client side CXF bus incorrectly caches service endpoint information
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: JBoss Enterprise Application Platform 6
Classification: JBoss
Component: Web Services
Version: 6.1.1
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ER3
: ---
Assignee: Alessio Soldano
QA Contact: Rostislav Svoboda
Russell Dickenson
URL:
Whiteboard:
Depends On: 1006789
Blocks:
TreeView+ depends on / blocked
 
Reported: 2013-08-21 15:11 UTC by Petr Sakař
Modified: 2014-06-18 07:20 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: Enhancement
Doc Text:
This version of JBoss EAP 6 includes new functionality that allows users to create a JAXWS client within a new Bus, whose WSDL definition cache would be empty. As WSDL definitions are cached within the Apache CXF Bus that is used for serving the JAXWS client being created, a stale definition could be used if a different WSDL is served at the specified URL and the same Bus is in use. This enhancement provides a means to avoid that scenario. The new functionality is used as follows through the new *org.jboss.wsf.stack.cxf.client.UseNewBusFeature* JBossWS JAXWS Feature: Service service = Service.create(new URL(wsdlLocation), new QName(...), new org.jboss.wsf.stack.cxf.client.UseNewBusFeature());
Clone Of:
Environment:
Last Closed: 2013-12-15 16:23:17 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
failing test is testClientSideBusDoNotCacheWebServiceHost (27.73 KB, text/x-java)
2013-08-21 15:11 UTC, Petr Sakař
no flags Details

Description Petr Sakař 2013-08-21 15:11:07 UTC
Created attachment 788919 [details]
failing test is testClientSideBusDoNotCacheWebServiceHost

Description of problem:

Client side CXF bus incorrectly caches service endpoint information

Version-Release number of selected component (if applicable):
EAP 6.1.1.ER7
jbossws-cxf 4.1.4.Final-redhat-7

How reproducible:
always

Steps to Reproduce:
see test testClientSideBusDoNotCacheWebServiceHost in attached test case JBWS2150TestCaseForked (originally part of jbossws shared testsuite)


Actual results:
test failure

Expected results:
passing test

Additional info:
workaround is to reset the bus before the service creation
      BusFactory.getDefaultBus().shutdown(true);
      Service service = Service.create(new URL(wsdlLocation), new QName(NAMESPACE, serviceName));

or set the correct address parsed from wsdl manually
      ((BindingProvider)endpoint).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, address);

Comment 1 Alessio Soldano 2013-08-28 14:52:18 UTC
OK, I've gone through this a bit; the reason for the issue here is basically that each CXF bus has a WSDLManager that caches WSDL definitions for each address. So, when building up for the second time a client against the same wsdl address, the wsdl definition is retrieved from the cache. Stopping the current bus (which forces a new one to be created at next client build time) or -better- creating a new bus just before building the second client ensures a fresh WSDLManager is in place.
The described WSDLManager related behaviour is by design, so I decided to give users an option for asking a given JAXWS service to be automatically built up in a new bus: https://issues.jboss.org/browse/JBWS-3699
As a consequence, the current issue could be solved by creating the JAXWS Service as follows:

Service service = Service.create(new URL(wsdlLocation), new QName(NAMESPACE, serviceName), new org.jboss.wsf.stack.cxf.client.UseNewBusFeature());

Comment 5 Petr Sakař 2013-10-09 12:43:18 UTC
The test case is fixed. WSDLManager in the CXF Bus is still caching the wsdl and related information. The service has to be created using new bus

//To we need to avoid caching issues related to the WSDLManager in the CXF Bus.
Service service = Service.create(new URL(wsdlLocation), new QName(NAMESPACE, serviceName), new UseNewBusFeature())

Comment 6 Petr Sakař 2013-10-09 12:44:02 UTC
verified for EAP version 6.2.0.ER5

Comment 7 Scott Mumford 2013-12-01 23:46:40 UTC
Added draft Release Note text and marked for inclusion in the 6.2 Release Notes document.

I'm not exactly sure how the code supplied in comment 1 is to be utilized, so if anyone can provide info on how to actually use it (I suspect it's added to a file somewhere?) I'll add that to the release note (which currently suffers from not having that useful information).

Comment 8 Alessio Soldano 2013-12-02 13:57:48 UTC
Scott,
this ticket was originally created by QA because of a failing test that suggested we had a bug. It actually turned out that the observed behavior was the expected one, while the testcase needed to be fixed. For fixing the test, I created a new functionality for creating a JAXWS Service into a new Bus, created just for serving that Service (see comment 1). This prevents problems with cached values, like references to WSDL definitions that changed after the cache entry was saved.
The new functionality can be used in user code, if the user feels the wsdl he's creating a JAXWS Service against might have changed (which is not that common anyway for production environments).

Please let me comment on the proposed release notes:

"It was found that having each CXF bus cache WSDL definitions for each address could be problematic if the cached data is superceded in a later deployment scenario."

The reference to a "later deployment scenario" does not make a lot of sense. Why mentioning deployments? Deployments on which target / containers btw? The referenced wsdl might be hosted anywhere. It's just that we reproduced the scenario by deploying / undeploying proper test apps in our testsuite.

In any case, I'd rather write something like: "Users should be careful when building up JAXWS clients against previously used WSDL URLs. As a matter of fact, WSDL definitions are cached within the Apache CXF Bus that's used for serving the JAXWS client being created; a stale definition could be used if a different wsdl is now served at the specified URL and the same Bus is in use. To allow better control on cache usage, EAP 6.2 comes with a new functionality allowing creating a JAXWS client within a new Bus, whose WSDL definition cache would be empty. The new functionality is used as follows through the new "org.jboss.wsf.stack.cxf.client.UseNewBusFeature" JBossWS JAXWS Feature:

Service service = Service.create(new URL(wsdlLocation), new QName(...), new org.jboss.wsf.stack.cxf.client.UseNewBusFeature());
"

Comment 9 Scott Mumford 2013-12-03 02:29:24 UTC
Thanks Alessio.

I've slightly modified the content you provided and have updated the Doc Text field and changed the Doc Type to 'Enhancement'.

Your timely input is greatly appreciated.


Note You need to log in before you can comment on or make changes to this bug.