Search code examples
jakarta-eewebsphereejbejb-3.0

EJBConfigurationException IBM websphere 9.0.11


so when i deployed my application in whebersphere 9.0.11 i have got this exception : is there any config that i need to add in ejb-jar.xml

com.ibm.ejs.container.ContainerException: Bean class xxxxxxxxxxx could not be found or loaded; nested exception is: 
    com.ibm.ejs.container.EJBConfigurationException: Configured xxxxxxxxx interface is not an interface : java.lang.Object of bean xxxxxxxxxxx

does anyone know what I am missing?

ps i have another exception at first :

[4/20/21 14:13:35:582 CET] 000000ab EJBWrapper    E   CNTR5011E: The java.lang.Object class has been configured as a business or component interface for the xxxxxxxx bean. However, the class is not an interface.

Solution

  • Most likely, you have an application with an enterprise bean coded something like this:

    @Stateless
    @Local
    public class MyBean {...)
    

    The problem is that the @Local annotation is present indicating there is a local business interface, but that interface is not specified anywhere. The local interface ends up defaulting to Object, which isn't a valid interface. A similar error would occur for @Remote.

    When starting the application, the server will detect the configuration error and first log the CNTR5011E error message in the logs. Then, the server will throw the EJBConfigurationException in response to an attempt to access the application, which is later wrapped in the ContainerException. Both the error message and the exception are for the same problem.

    The Enterprise Bean specification provides many ways to configure bean interfaces:

    No-interface view

    @Stateless
    public class MyBean {...)
    

    Simply remove the @Local annotation (or replace with @LocalBean) and the bean class (MyBean) will become the interface. Similar to a local business interface.

    Business Interface

    @Stateless
    @Local(Cart.class)
    public class MyBean {...)
    

    Add an interface as an attribute of the @Local annotation, and that becomes the local business interface. Similarly you may use @Remote, or both, but the same interface cannot be both local and remote. You may specify multiple local or remote interfaces if you would like.

    Business Interface - implemented

    @Stateless
    @Remote
    public class MyBean implements RemoteCart {...)
    

    Change the class to implement an interface, then that becomes the remote/local business interface, depending on the annotation. The implemented interface would default to a local business interface if neither annotation is present.

    Business Interface - annotated interface

    @Stateless
    public class MyBean implements RemoteCart {...)
    
    @Remote
    public interface RemoteCart {...)
    

    When an interface is annotated @Local or @Remote, then it becomes a local or remote business interface if the bean class implements it.

    Component Interface (EJB 2.x API)

    @Stateless
    @LocalHome(CartLocalHome.class)
    public class MyBean {...)
    

    Using the @LocalHome or @RemoteHome annotation provides an EJB 2.x API component interface. The EJBLoclHome/EJBHome interface class is specified on the annotation, and defines the component home interface, the component interface is then determined from the return value of the create method on the home interface.

    Interfaces declared in ejb-jar.xml

    <session>
        <ejb-name>MyBean</ejb-name>
        <remote-home>CartRemoteHome</remote-home>
        <remote>CartRemote</remote>
        <local-home>CartLocalHome</local-home>
        <local>CartLocal</local>
        <business-local>Cart</business-local>
        <business-remote>RemoteCart</business-remote>
        <local-bean/>
        <ejb-class>MyBean</ejb-class>
        <session-type>Stateless</session-type>
    </session>
    

    Everything that can be done with annotations can also be done in XML. Note that @Local corresponds to <business-local> and @Remote corresponds to <business-remtoe>. A bean may be visible through several different interfaces, as shown in the example; however, there needs to be at least one.