Getting Cannot resolve reference Local ejb-ref not implementing parent interface

12,801

EJB Spec says so,

As an example, the client views exposed by a particular session bean are not inherited by a subclass that also happens to define a session bean.

@Stateless
public class A implements Foo { ... }
@Stateless
public class B extends A implements Bar { ... }

Assuming Foo and Bar are local business interfaces and there is no associated deployment descriptor, session bean A exposes local business interface Foo and session bean B exposes local business interface Bar, but not Foo.

Reference here. Section 4.9.2.1 of EJB3.1 Spec

Share:
12,801
Snekse
Author by

Snekse

'Foodie for Life' is tattooed across my tummy. Oh, I also do some of that Java programming stuff. SOreadytohelp

Updated on June 05, 2022

Comments

  • Snekse
    Snekse almost 2 years

    I'm trying to figure out why I need to implement both of these interfaces in order to avoid deployment issues.

    Java Code

    ExamplePlanAssembler.java

    @Local
    public interface ExamplePlanAssembler {
       ExamplePlan toBO(ExamplePlanEntity entity);
    }
    

    ExtendedExamplePlanAssembler.java

    @Local
    public interface ExtendedExamplePlanAssembler 
    extends ExamplePlanAssembler{
       ExtExamplePlan toBO(ExamplePlanEntity entity, ExtExamplePlanEntity extEntity);
    }
    

    ExtendedExamplePlanAssemblerImpl.java

    @Stateless
    public class ExtendedExamplePlanAssemblerImpl 
    implements ExtendedExamplePlanAssembler {
       /* Method impls removed */
    }
    

    ExamplePlanServiceImpl.java

    @Stateless
    public class ExamplePlanServiceImpl 
    implements ExamplePlanService {
       private ExamplePlanAssembler examplePlanAssembler ;
       @EJB
       public void setAssembler(ExamplePlanAssembler examplePlanAssembler) {
           this.examplePlanAssembler = examplePlanAssembler;
        }
    }
    

    Deployment Error

    [#|.507-0500|SEVERE|gf3.1.2|javax.enterprise.system.tools.deployment.org.glassfish.deployment.common
    |_ThreadID=83;_ThreadName=Thread-7;|Cannot resolve reference Local ejb-ref name=
    com.myco.services.business.ExampleServiceImpl/examplePlanAssembler,Local 3.x interface =
    com.myco.services.assembly.ExamplePlanAssembler,ejb-link=null,lookup=,mappedName=,jndi-name=,refType=Session|#]
    
    [#|.508-0500|SEVERE|gf3.1.2|javax.enterprise.system.core.com.sun.enterprise.v3.server
    |_ThreadID=83;_ThreadName=Thread-7;|Exception while deploying the app [mycoservicesear]|#]
    
    [#|.508-0500|SEVERE|gf3.1.2|javax.enterprise.system.core.com.sun.enterprise.v3.server
    |_ThreadID=83;_ThreadName=Thread-7;|Cannot resolve reference Local ejb-ref name=
    com.myco.services.business.ExampleServiceImpl/examplePlanAssembler,Local 3.x interface =
    com.myco.services.assembly.ExamplePlanAssembler,ejb-link=null,lookup=,mappedName=,jndi-name=,refType=Session
    java.lang.RuntimeException: Cannot resolve reference Local ejb-ref name=
    com.myco.services.business.ExampleServiceImpl/examplePlanAssembler,Local 3.x interface =
    com.myco.services.assembly.ExamplePlanAssembler,ejb-link=null,lookup=,mappedName=,jndi-name=,refType=Session
    
    
    [#|.516-0500|SEVERE|gf3.1.2|javax...gf.deployment.admin
    |_ThreadID=83;_ThreadName=Thread-7;|Exception while deploying the app [mycoservicesear] : Cannot resolve reference Local ejb-ref name=
    com.myco.services.business.ExampleServiceImpl/examplePlanAssembler,Local 3.x interface =
    com.myco.services.assembly.ExamplePlanAssembler,ejb-link=null,lookup=,mappedName=,jndi-name=,refType=Session|#]
    

    The Fix?!

    If I change my interface impl to implement not only the ExtendedExamplePlanAssembler interface, but also the parent ExamplePlanAssembler interface, my deployment error disappears.

    ExtendedExamplePlanAssemblerImpl.java (v2)

    @Stateless
    public class ExtendedExamplePlanAssemblerImpl 
    implements ExtendedExamplePlanAssembler,  ExamplePlanAssembler{
       /* Method impls removed */
    }
    

    The Question

    Why does adding the parent interface to my implements declaration resolve deployment issues?

  • Snekse
    Snekse over 11 years
    Your reference link didn't really point to something directly that supports your claim. I'll leave this open for a couple of days. If no one provides a better answer or you can provide a deep link to the exact wording in the spec, I'll award the answer to you.
  • Maddy
    Maddy over 11 years
    well the above text is copy of ejb 3.1 spec. search for the text...may be searc afain:-)
  • Snekse
    Snekse over 11 years
    Thanks. This link also helped a bit. weblogs.java.net/blog/sekhar/archive/2009/02/…
  • Snekse
    Snekse over 11 years
    However.... the examples given don't really cover my case. The examples are of class inheritance with each class specifying a different interface. In my example, I have Interface inheritance with the class implementing the child interface. Minor difference.