我正在试图找出为什么我需要实现这两个接口以避免部署问题。
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;
}
}
[#|.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|#]
如果我更改我的接口impl,不仅要实现ExtendedExamplePlanAssembler
接口,还要实现父ExamplePlanAssembler
接口,我的部署错误就会消失。
ExtendedExamplePlanAssemblerImpl.java(v2)
@Stateless
public class ExtendedExamplePlanAssemblerImpl
implements ExtendedExamplePlanAssembler, ExamplePlanAssembler{
/* Method impls removed */
}
为什么将父接口添加到我的implements
声明解决部署问题?
答案 0 :(得分:3)
EJB规则是这样说的,
作为示例,特定会话bean公开的客户端视图不会被子类继承 也恰好定义了会话bean。
@Stateless
public class A implements Foo { ... }
@Stateless
public class B extends A implements Bar { ... }
假设Foo和Bar是本地业务接口,并且没有关联的部署描述符, 会话bean公开本地业务接口Foo,会话bean B公开本地业务接口 吧,但不是Foo。
参考here。 EJB3.1规范的第4.9.2.1节
答案 1 :(得分:0)
您无法扩展界面 我需要你尝试实现接口(你可以在同一个bean类中实现这两个接口) 但是现在你需要替换关键字" extends"用"实现"
@Local
public interface ExtendedExamplePlanAssembler
extends ExamplePlanAssembler{
ExtExamplePlan toBO(ExamplePlanEntity entity, ExtExamplePlanEntity extEntity);
}