IBM Support

WebSphere Application Server incorrectly sets local-bean element for annotation only singleton beans

Troubleshooting


Problem

The processing of a singleton bean which is defined through annotations incorrectly marks the singleton bean as a local bean.

Symptom

Incorrect processing relating to a singleton bean occurs.

Diagnosing The Problem

The problem can be be detected by reviewing the metadata generated for the bean. Metadata for an EJB JAR file, including metadata which is obtained from annotations, is written to the META-INF/ejb-jar_merged.xml file. This file is stored in a profile specific folder for the EJB JAR file.

The following example can help you diagnose the problem:

The file contains the metadata:
WAS_HOME/profiles/PROFILE_NAME/config/cells/CELL_NAME/applications/APPLICATION_NAME.ear/deployments/APPLICATION_NAME/EJBJAR_NAME.jar/META-INF/ejb-jar_merged.xml

The code is for the AnnotationSingletonBean bean:

@Singleton
@Local(LocalBusinessInterface.class)
@Remote(RemoteBusinessInterface.class)
public class AnnotationSingletonBean {
  @PostConstruct
  public void postConstruct() {
  }
  @PreDestroy
  public void preDestroy() {
  }
}

The metadata for this singleton bean is written to the META-INF/ejb-jar_merged.xml file:

<session>
    <ejb-name>AnnotationSingletonBean</ejb-name>
    <business-local>suite.r90.ejb32.ejbendpoints.content.ejb.LocalBusinessInterface</business-local>
    <business-remote>suite.r90.ejb32.ejbendpoints.content.ejb.RemoteBusinessInterface</business-remote>
    <ejb-class>suite.r90.ejb32.ejbendpoints.content.ejb.AnnotationSingletonBean</ejb-class>
    <session-type>Singleton</session-type>
    <concurrency-management-type>Container</concurrency-management-type>
    <local-bean/>
    <post-construct>
      <lifecycle-callback-class>suite.r90.ejb32.ejbendpoints.content.ejb.AnnotationSingletonBean</lifecycle-callback-class>
      <lifecycle-callback-method>postConstruct</lifecycle-callback-method>
    </post-construct>
    <pre-destroy>
      <lifecycle-callback-class>suite.r90.ejb32.ejbendpoints.content.ejb.AnnotationSingletonBean</lifecycle-callback-class>
      <lifecycle-callback-method>preDestroy</lifecycle-callback-method>
    </pre-destroy>
  </session>

The metadata is correct except for the <local-bean/> element. The <local-bean/> element should not be present for this bean.

Because this singleton bean does not have an @LocalBean annotation and does have @Local and @Remote annotations, the <local-bean/> element should not have been added. The <local-bean/> element should only be added when the bean has no other endpoint.

A bean should not be marked as a local bean if at least one endpoint is specified for the bean.

An endpoint for a bean can be specified through a deployment descriptor, by using an annotation supplied directly on the bean class, or specified by using an annotation supplied on an interface implemented by the bean class.

An endpoint for a bean is specified as a local endpoint, as a remote endpoint, as a local home endpoint, as a remote home endpoint, or as a web service endpoint.

More than one type of endpoint can be specified.

Resolving The Problem

No workaround exists.

You can optionally install a fix pack for Version 9 to resolve this issue. Refer to the Recommended Updates page for delivery information: http://www.ibm.com/support/docview.wss?uid=swg27004980

[{"Product":{"code":"SSEQTP","label":"WebSphere Application Server"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Component":"--","Platform":[{"code":"PF002","label":"AIX"},{"code":"PF010","label":"HP-UX"},{"code":"PF012","label":"IBM i"},{"code":"PF016","label":"Linux"},{"code":"PF014","label":"iOS"},{"code":"PF027","label":"Solaris"},{"code":"PF033","label":"Windows"},{"code":"PF035","label":"z\/OS"},{"code":"PF022","label":"OS X"}],"Version":"9.0.0.0","Edition":"Base;Network Deployment","Line of Business":{"code":"LOB45","label":"Automation"}},{"Product":{"code":"SS7K4U","label":"WebSphere Application Server for z\/OS"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Component":" ","Platform":[{"code":"PF035","label":"z\/OS"}],"Version":"9.0.0.0","Edition":"","Line of Business":{"code":"LOB45","label":"Automation"}}]

Document Information

Modified date:
15 June 2018

UID

swg21985119