我试图弄清楚为什么我需要实现这两个接口以避免部署问题。
Java 代码
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
声明中可以解决部署问题?