tags:

views:

43

answers:

1

I'm using Spring's ContextLoaderListener to initialise a web services client, but if the wsdl document is not available during the application startup then part of my application is broken and I'm not sure how to fix it. The application starts successfully, just logging a big ol' stack trace at that point. The exception is:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'myWebService' defined in class path resource [spring-myapp-jaxws.xml]: Invocation of init method failed; nested exception is javax.xml.ws.WebServiceException: The following WSDL exception occurred... etc.

Couple of questions...

  • Can I catch the init exception so that I can show the state of the broken component appropriately in my application?
  • Can I tell Spring to try and reinitialise the myWebService bean on user request?
A: 

Try defining the bean as lazy="true", so that it is not initialized if it is not referenced.

Otherwise you will have to create a proxy that makes this checks. Proxies can be created by:

  • java.lang.reflect.Proxy
  • cglib
  • javassist
Bozho
I considered lazily initializing the ws bean, decided against it as doesn't solve the problem - the wsdl might not be available when the user first tries to use it. Re: creating a proxy - you mean create something to wrap the web service bean to do the exception handling and try a reinitialization if the service isn't correctly inited?
Brabster
about the proxy - yes.
Bozho