Results 1 to 2 of 2

Thread: ApplicationContextAware issue

  1. #1
    Join Date
    Feb 2008
    Posts
    27

    Default ApplicationContextAware issue

    Hi,
    I'm using spring ApplicationContextAware to set the Application context to my web services endpoint. There's no exception when I install and start the bundle. When I'm trying to call the service, I'getting a null pointer exception as the application context is showing up as "null". Here's the app context entry :
    Code:
    <jaxws:endpoint id="taxonomyquery"  implementor="com.test.taxonomy.soap.query.service.TaxonomySoapQueryServiceImpl"
      address="/taxonomyquery" />
    And here's my sample code:
    Code:
    @WebService(endpointInterface = "com.test.taxonomy.soap.query.service.ITaxonomySoapQueryService")
    public class TaxonomySoapQueryServiceImpl implements ITaxonomySoapQueryService, ApplicationContextAware {
    
     private static ApplicationContext ctx = null;
    
     private static Logger LOGGER = LoggerFactory.getLogger(TaxonomySoapQueryServiceImpl.class);
     
     @Override
     public void setApplicationContext(ApplicationContext ctx) throws BeansException {
      this.ctx = ctx;
     } 
    
     public ProductReleaseResponse queryProductRelease(ProductReleaseRequest req) {
      ProductReleaseResponse response = new ProductReleaseResponse ();
      try {
       req.status = RequestHelper.transformStatus(req.status);
       ITaxonomySoapPluginQuery tp = (ITaxonomySoapPluginQuery) ctx.getBean("taxonomyQueryPlugin");
       response = tp.queryProductRelease(req);
      }
      catch (Exception ex) {
       LOGGER.error(ex.getMessage());
       response.status = "ERROR";
      }
      return response;
     }
    The service is starting without any issues, which prompted me to believe that the Application Context should have been set correctly.

    I've also tried using BeanfactoryAware, but got the same exception.

    Any pointer will be appreciated.

    - Thanks

  2. #2
    Join Date
    Feb 2008
    Posts
    27

    Default

    My bad, I declared it wrong in the spring config.

    Code:
    <jaxws:endpoint id="taxonomyquery"
      implementor="#taxonomyqueryImpl"
      address="/taxonomyquery" />
    
    <bean id="taxonomyqueryImpl" class="com.test.taxonomy.soap.query.service.TaxonomySoapQueryServiceImpl"/>
    This resolved the issue

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •