You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cxf.apache.org by Eoghan Glynn <eg...@iona.com> on 2008/04/09 12:25:32 UTC
premature Endpoint.publish() during CXFServlet initialization
Folks,
I've tripped over a nasty issue when deploying a CXF application to
Tomcat, so I'm looking for some ideas from the collective big brain on
possible work-arounds.
The problem is that the process of init()ializing the CXFServlet
includes publishing the <jaxws:endpoint> defined in the cxf-servlet.xml.
However this publish() call is slightly premature, as Tomcat will not
deliver any incoming requests to the endpoint until *after* the servlet
init() returns (whereas the JAX-WS spec expects that "Published
endpoints are active and capable of receiving incoming requests and
dispatching them to their implementor"). So the endpoint is in limbo for
a short period and this is the root of my problem.
Now I'm using a CXF ServerLifecycleListener to trigger the handing out
of an EPR for the newly published endpoint. As a side-effect of this,
there are some call-backs on the endpoint (both a "?wsdl" style query
and a real invocation). These calls are failing on me as the publish()ed
endpoint is not yet fully active, and will not be so until after the
servlet init()ialization completes. And these failures cause the handing
out of the supposedly live EPR to fail.
So I'm looking for alternative trigger-points, so as to either delay the
Endpoint.publish(), or my ServerLifecycleListener.startServer() logic,
until *after* Tomcat starts dispatching incoming requests to the webapp.
Unfortunately registering a ServletContextListener with Tomcat is no
help, as contextInitialized() is triggered *before* the webapp is
started. Which is odd IMO, as the method name connotes initialization in
the past tense, but that's the way it's implemented in Tomcat 5.5.25 at
least.
If anyone has any other brain-waves, please shout.
Cheers,
Eoghan
----------------------------
IONA Technologies PLC (registered in Ireland)
Registered Number: 171387
Registered Address: The IONA Building, Shelbourne Road, Dublin 4, Ireland
Re: premature Endpoint.publish() during CXFServlet initialization
Posted by Daniel Kulp <dk...@apache.org>.
Eoghan,
Honestly, I'm not sure there IS a good solution to this one. There isn't
anything in the Servlet spec that really would provide a notification to
the servlet as to when the port might actually be connected. In
tomcat's case, at startup, it "deploys" all the web apps calling the
init methods and such and then starts up the port listeners. The ports
are not even being listened to at all while the apps are being initted.
The only thing I can think of is a ServletRequestListener that
initializes your stuff on the first request. However, you'll need to be
careful of that as well. If your init stuff takes too long, the
request could timeout on the client side.
Dan
On Wednesday 09 April 2008, Eoghan Glynn wrote:
> Folks,
>
> I've tripped over a nasty issue when deploying a CXF application to
> Tomcat, so I'm looking for some ideas from the collective big brain on
> possible work-arounds.
>
> The problem is that the process of init()ializing the CXFServlet
> includes publishing the <jaxws:endpoint> defined in the
> cxf-servlet.xml. However this publish() call is slightly premature, as
> Tomcat will not deliver any incoming requests to the endpoint until
> *after* the servlet init() returns (whereas the JAX-WS spec expects
> that "Published endpoints are active and capable of receiving incoming
> requests and dispatching them to their implementor"). So the endpoint
> is in limbo for a short period and this is the root of my problem.
>
> Now I'm using a CXF ServerLifecycleListener to trigger the handing out
> of an EPR for the newly published endpoint. As a side-effect of this,
> there are some call-backs on the endpoint (both a "?wsdl" style query
> and a real invocation). These calls are failing on me as the
> publish()ed endpoint is not yet fully active, and will not be so until
> after the servlet init()ialization completes. And these failures cause
> the handing out of the supposedly live EPR to fail.
>
> So I'm looking for alternative trigger-points, so as to either delay
> the Endpoint.publish(), or my ServerLifecycleListener.startServer()
> logic, until *after* Tomcat starts dispatching incoming requests to
> the webapp.
>
> Unfortunately registering a ServletContextListener with Tomcat is no
> help, as contextInitialized() is triggered *before* the webapp is
> started. Which is odd IMO, as the method name connotes initialization
> in the past tense, but that's the way it's implemented in Tomcat
> 5.5.25 at least.
>
> If anyone has any other brain-waves, please shout.
>
> Cheers,
> Eoghan
>
>
>
>
> ----------------------------
> IONA Technologies PLC (registered in Ireland)
> Registered Number: 171387
> Registered Address: The IONA Building, Shelbourne Road, Dublin 4,
> Ireland
--
J. Daniel Kulp
Principal Engineer, IONA
dkulp@apache.org
http://www.dankulp.com/blog