我有ejb和war模块的企业应用程序,因为我创建的本地接口Web模块不会部署。它建立得很好。 EJB项目在Web项目中引用。
当我从web.xml中删除<ejb-local-ref>
时,它会部署,但是查找方法失败。
Glassfish错误:
严重:部署应用程序时出现异常[Projekat-war]:错误:未解决&lt; ejb-link&gt;:Projekat-ejb.jar#ZaWebSessionBean
简单的界面:
@Local
public interface ZaWebSessionBeanLocal {
String vrati(String str);
}
@Stateless
public class ZaWebSessionBean implements ZaWebSessionBeanLocal {
@Override
public String vrati(String str) {
return "vrati";
}
// Add business logic below. (Right-click in editor and choose
// "Insert Code > Add Business Method")
}
和web.xml
<ejb-local-ref>
<ejb-ref-name>ZaWebSessionBean</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
<local>za_web.ZaWebSessionBeanLocal</local>
<ejb-link>Projekat-ejb.jar#ZaWebSessionBean</ejb-link>
</ejb-local-ref>
查找方法(生成):
public class HeaderBean {
ZaWebSessionBeanLocal zaWebSessionBean = lookupZaWebSessionBeanLocal();
private ZaWebSessionBeanLocal lookupZaWebSessionBeanLocal() {
try {
Context c = new InitialContext();
return (ZaWebSessionBeanLocal) c.lookup("java:global/Projekat/Projekat-ejb/ZaWebSessionBean!za_web.ZaWebSessionBeanLocal");
} catch (NamingException ne) {
Logger.getLogger(getClass().getName()).log(Level.SEVERE, "exception caught", ne);
throw new RuntimeException(ne);
}
}
完整日志:
SEVERE: Exception while deploying the app [Projekat-war] : Error: Unresolved <ejb-link>: Projekat-ejb.jar#ZaWebSessionBean
SEVERE: Unresolved <ejb-link>: Projekat-ejb.jar#ZaWebSessionBean
SEVERE: Exception while deploying the app [Projekat-war]
SEVERE: Error: Unresolved <ejb-link>: Projekat-ejb.jar#ZaWebSessionBean
java.lang.RuntimeException: Error: Unresolved <ejb-link>: Projekat-ejb.jar#ZaWebSessionBean
at com.sun.enterprise.deployment.util.EjbBundleValidator.accept(EjbBundleValidator.java:724)
at com.sun.enterprise.deployment.WebBundleDescriptor.visit(WebBundleDescriptor.java:2004)
at com.sun.enterprise.deployment.Application.visit(Application.java:1777)
at com.sun.enterprise.deployment.archivist.ApplicationFactory.openArchive(ApplicationFactory.java:195)
at org.glassfish.javaee.core.deployment.DolProvider.load(DolProvider.java:185)
at org.glassfish.javaee.core.deployment.DolProvider.load(DolProvider.java:94)
at com.sun.enterprise.v3.server.ApplicationLifecycle.loadDeployer(ApplicationLifecycle.java:827)
at com.sun.enterprise.v3.server.ApplicationLifecycle.setupContainerInfos(ApplicationLifecycle.java:769)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:368)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:240)
at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:389)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:348)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:363)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1085)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1200(CommandRunnerImpl.java:95)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1291)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1259)
at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:461)
at com.sun.enterprise.v3.admin.AdminAdapter.service(AdminAdapter.java:212)
at com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:179)
at com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:117)
at com.sun.enterprise.v3.services.impl.ContainerMapper$Hk2DispatcherCallable.call(ContainerMapper.java:354)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)
at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:849)
at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:746)
at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1045)
at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:228)
at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
at java.lang.Thread.run(Thread.java:619)
SEVERE: Exception while deploying the app [Projekat-war] : Error: Unresolved <ejb-link>: Projekat-ejb.jar#ZaWebSessionBean
答案 0 :(得分:8)
在尝试部署我的应用程序时遇到了同样的问题,NetBeans自己在我的web.xml中生成了这个代码。
你的web.xml中的可以轻松删除
<ejb-local-ref>
<ejb-ref-name>appName</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
<ejb-link>AppName#SomeClass</ejb-link>
</ejb-local-ref>
它应该在此之后部署。
答案 1 :(得分:0)
删除XML并使用可移植的JNDI名称(参见例如关于EJB的维基百科文章)。