title: could not initialize proxy - no Session in jax-ws + hibernate
body: <p>I stuck in exposing web service using JAX-WS. Problem occur due to JAXB tries to serialize object after hibernate closing the session. I Google during last two days but couldn't come up with proper answer. Following are some sort of solutions given by others.</p>
  
  <ul>
  <li>Eager load objects </li>
  <li>Use @XmlTransient</li>
  <li>SOAPHandler but it's not completed answer</li>
  </ul>
  
  <p>Here is the scenario in detail. I wrote one model class which has number of @OneTOMany relationships, @ManyToOne relationship and @OneToOne relationship. Web service returning object of that class as a result. When I call the service through SOAP UI it gives me the following error message.</p>
  
  <pre><code>&lt;S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"&gt;
     &lt;S:Body&gt;
        &lt;S:Fault xmlns:ns4="http://www.w3.org/2003/05/soap-envelope"&gt;
           &lt;faultcode&gt;S:Server&lt;/faultcode&gt;
           &lt;faultstring&gt;could not initialize proxy - no Session&lt;/faultstring&gt;
        &lt;/S:Fault&gt;
     &lt;/S:Body&gt;
  &lt;/S:Envelope&gt; 
  </code></pre>
  
  <p>Model class (without getters and setters)</p>
  
  <pre><code>@XmlAccessorType(XmlAccessType.FIELD)
  @XmlRootElement
  @Entity
  @AttributeOverrides({ @AttributeOverride(name = "id", column = @Column(name = "mas_form_id")),
          @AttributeOverride(name = "tenantId", column = @Column(name = "mas_form_tenant_id")) })
  @FilterDef(name = "tenantFilter", parameters = @ParamDef(name = "tenantIdParam", type = "string"))
  @Filters(@Filter(name = "tenantFilter", condition = "mas_form_tenant_id = :tenantIdParam"))
  @Table(name = "mas_form")
  public class Form extends BaseRevolution {
  
      @Column(name = "mas_form_action")
      private String formAction;
      @Column(name = "mas_form_is_active")
      private boolean isActive;
      @Column(name = "mas_form_is_lock")
      private boolean isLock;
      @ManyToOne
      @JoinColumn(name = "mas_ft_id")
      private FormType formType;
      @OneToMany(fetch = FetchType.LAZY, mappedBy = FORM)
      private List&lt;FormQuestion&gt; formQuestions = new ArrayList&lt;FormQuestion&gt;(0);
      @OneToMany(fetch = FetchType.LAZY, mappedBy = FORM)
      @LazyCollection(LazyCollectionOption.FALSE)
      private Set&lt;DocumentRequired&gt; documentRequiredSet = new HashSet&lt;DocumentRequired&gt;(0);
      @OneToMany(fetch = FetchType.LAZY, mappedBy = FORM)
      private List&lt;Application&gt; applications = new ArrayList&lt;Application&gt;(0);
      @OneToMany(fetch = FetchType.LAZY, mappedBy = FORM)
      @LazyCollection(LazyCollectionOption.FALSE)
      private List&lt;FormField&gt; formFields = new ArrayList&lt;FormField&gt;(0);
      @OneToMany(fetch = FetchType.LAZY, mappedBy = FORM)
      private List&lt;FormCharge&gt; formCharges = new ArrayList&lt;FormCharge&gt;(0);
      @Column(name = "mas_form_method")
      private String formMethod;
      @OneToMany(fetch = FetchType.LAZY, mappedBy = FORM)
      private List&lt;FormFieldGroup&gt; formFieldGroup;
      @Column(name = "mas_form_name_en")
      private String formNameEn;
      @Column(name = "mas_form_name_si")
      private String formNameSi;
      @Column(name = "mas_form_name_ta")
      private String formNameTa;
      @OneToOne(fetch = FetchType.EAGER)
      @JoinColumn(name = "activity")
      private ElgActivity elgActivity;
      @Column(name = "description", nullable = true, length = 1000)
      private String description;
  
      //getters and setters
  
  }
  </code></pre>
  
  <p>Web service interface</p>
  
  <pre><code>@WebService(name = "formWebServicePort", targetNamespace = "http://lk.gov.elg/core/ws/form/")
  public interface FormWebService {
  
      @WebMethod(operationName = "getAllFormsWithDocumentReferences", action = "urn:GetAllFormsWithDocumentReferences")
      @SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.WRAPPED)
      @WebResult(name = "formsWithDocumentReferences")
      List&lt;Form&gt; getAllFormsWithDocumentReferences(
              @WebParam(name = "tenantId", targetNamespace = "http://lk.gov.elg/core/ws/form/") String tenantId,
              @WebParam(name = "categoryName", targetNamespace = "http://lk.gov.elg/core/ws/form/") String categoryName);
  }
  </code></pre>
  
  <p>Web service implementation</p>
  
  <pre><code>@SchemaValidation
  @WebService(targetNamespace = "http://lk.gov.elg/core/ws/form/", endpointInterface = "lk.gov.elg.core.ws.citizen.FormWebService")
  public class FormWebServiceImpl extends SpringBeanAutowiringSupport implements FormWebService {
  
      private static final Logger logger = LoggerFactory.getLogger(FormWebServiceImpl.class);
      @Autowired
      private FormService formService;
  
      @Override
      public List&lt;Form&gt; getAllFormsWithDocumentReferences(
              @WebParam(name = "tenantId", targetNamespace = "http://lk.gov.elg/core/ws/form/") String tenantId,
              @WebParam(name = "categoryName", targetNamespace = "http://lk.gov.elg/core/ws/form/") String categoryName) {
  
          List&lt;Form&gt; formList = formService.getAllFormsWithDocRefs(tenantId, categoryName);
          return formList;
      }
  }
  </code></pre>
  
  <p>Help me to overcome this problem. Thanks in advance.</p>