4

我有带有 ejb 和 war 模块的企业应用程序,并且由于我创建了本地界面 web 模块,因此不会部署。它构建良好。EJB 项目在 Web 项目中被引用。

此外,当我从 web.xml 中删除它时<ejb-local-ref>,它会部署,但随后查找方法失败。

玻璃鱼错误:

严重:部署应用程序 [Projekat-war] 时出现异常:错误:未解决 <ejb-link>: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
4

2 回答 2

9

我在尝试部署我的应用程序时遇到了同样的问题,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>

它应该在此之后部署。

于 2014-10-02T17:07:29.337 回答
0

删除 XML 并使用可移植的 JNDI 名称(参见例如关于 EJB 的维基百科文章)。

于 2012-10-14T09:32:08.843 回答