title: Create Web Service (SOAP or REST) using Struts2 and hibernate
body: <p>i have the problem when calling web service using struts 2 and hibernate...</p>
  
  <blockquote>
    <p>HTTP Status 500 - Unable to instantiate Action, actions.events.rest.EventController, defined for 'event' in namespace '/'Error creating bean with name 'actions.events.rest.EventController': Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [actions.events.rest.EventController]: Constructor threw exception; nested exception is java.lang.NullPointerException</p>
  </blockquote>
  
  <p>this is my source:</p>
  
  <p>EventController :</p>
  
  <pre><code>public class EventController extends BaseAction implements ModelDriven&lt;Object&gt; {
  private static final long serialVersionUID = 1L;
  private String id;
  private Object model; 
  
  private static Map&lt;String, Event&gt; map;
  { 
      List&lt;Event&gt; events = services.getEvents();
      for(Event event : events){
          map.put(event.getId() + "", event);
      } 
  }
  
  public HttpHeaders index() {
      model = map;
      return new DefaultHttpHeaders("index").disableCaching();
  }
  
  public String add(){ 
      services.createEvent("Event1");
      return "SUCCESS";
  }
  
  public String getId() {
      return id;
  }
  public void setId(String id) {
      Integer iid = Integer.parseInt(id);
      model = services.getEventById(iid);
      this.id = id;
  }
  
  public Object getModel() {
      return model;
  } 
  </code></pre>
  
  <p>BaseAction:</p>
  
  <pre><code>public class BaseAction extends ActionSupport {
  // So that spring can inject the business singleton
  protected Services services;
  
  public void setServices(Services value) {
      services=value;
  }
  
  // For redirect results
  protected String redirectUrl;
  
  public String getRedirectUrl() {
      return redirectUrl;
  }
  
  public String redirect(String to) {
      redirectUrl = to;
      return "redirect";
  }
  </code></pre>
  
  <p>When I debug, I got error in <code>List&lt;Event&gt; events = services.getEvents();</code> in <code>EventController</code>. What can it be ?</p>