[
https://issues.apache.org/jira/browse/AXIS2-5777?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Andreas Veithen resolved AXIS2-5777.
------------------------------------
Resolution: Invalid
The code is misusing the API. The default ServiceClient constructor will create
a new ConfigurationContext, and the lifecycle of that ConfigurationContext is
coupled to the lifecycle of the ServiceClient: when the ServiceClient is
cleaned up (or garbage collected), the ConfigurationContext is terminated. Your
code attempts to get the ConfigurationContext from the first created
ServiceClient and use it beyond the lifetime of that instance. That won't work.
If you want to use a single ConfigurationContext instance with multiple
ServiceClient instances, then create that ConfigurationContext instance
explicitly (using ConfigurationContextFactory) and use one of the ServiceClient
constructors that have a ConfigurationContext argument.
Please note that this is a bug tracker, not a Q&A forum. For questions about
how to use the Axis2 API correctly, please use the mailing list instead.
> AxisConfiguration is NULL
> -------------------------
>
> Key: AXIS2-5777
> URL: https://issues.apache.org/jira/browse/AXIS2-5777
> Project: Axis2
> Issue Type: Bug
> Components: kernel
> Affects Versions: 1.7.2
> Reporter: Rajesh
> Attachments: AxisClient.zip
>
>
> Hi,
> Am using the axis2 1.7.2
> I have deployed the axis2.war in the tomcat and started the service. The
> StockQuoteService can be listened via the below url
> http://localhost:8080/axis2/services/StockQuoteService
> I have created a client to request that service (Attached the complete
> project zip).
> To trigger multiple requests, I have invoked the client call method in the
> For loop from main method
> To avoid creating the multiple connections, am caching the http client and
> reusing it.
> When I run the program with this setup, around 46 requests are executed
> successfully and returning the response. After that NPE in thrown.
> After investigating about it, found that the JVM is expelling the
> ServiceClient object
> ==========================================================
> ServiceClient.java
> ==========================================================
> protected void finalize() throws Throwable {
> try {
> cleanup();
> } finally {
> super.finalize();
> }
> }
> public void cleanup() throws AxisFault {
> // if a configuration context was created for this client there'll
> also
> // be a service group, so discard that
> if (!createConfigCtx) {
> String serviceGroupName =
> axisService.getAxisServiceGroup().getServiceGroupName();
> AxisConfiguration axisConfiguration =
> configContext.getAxisConfiguration();
> AxisServiceGroup asg =
> axisConfiguration.getServiceGroup(serviceGroupName);
> if ((asg != null) && removeAxisService) {
> axisConfiguration.removeServiceGroup(serviceGroupName);
> }
> } else {
> configContext.terminate();
> }
> }
> ==========================================================
> When the finalize method is called, it is invoking the cleaup method
> which again calls the terminate method of ConfigurationContext. Because of
> this
> AxisConfiguration in the ConfigurationContext is becoming NULL.
> Once this cleanup is done, the subsequent requests are not able to
> process due to empty AxisConfiguration returned from ConfigurationContext.
> This whole issue is due to reusing the HttpClient. When the HttpClient is not
> reused, this error is not thrown.
> But as per our project requirement, we will be getting multiple requests from
> the end user and we need to reuse the HttpClient.
> Kindly advice at the earliest, as we are facing this issue in the production
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]