启动时EJB查找失败,但在服务器启动后进行调用时可以正常

时间:2018-02-02 10:08:57

标签: jboss7.x ejb-3.1

我正在使用Jboss EAP 7.1。我成功地部署了无状态EJBbean。在服务器成功启动后,我也能够访问部署EJB

    final Hashtable jndiProperties = new Hashtable();

    jndiProperties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");

    jndiProperties.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");

    jndiProperties.put("jboss.naming.client.ejb.context", true);

    Context context;

    try {

        context = new InitialContext(jndiProperties);

        String appName = "";

        if ("FlowControllerBean/remote".equalsIgnoreCase(jndiName)) {

            appName = "";


        } else {

            appName = "upm-0.1";

        }

        final String distinctName = "";

        String beanName = "";

        final String viewClassName = FlowController.class.getName();

        System.out.println(
                "ejb:" + appName + "/" + moduleName + "/" + distinctName + "/" + beanName + "!" + viewClassName);

        if ("".equalsIgnoreCase(interfacename)) {

            context = new InitialContext();

            return context.lookup(jndiName);

        } else {

            beanName = jndiName.substring(0, jndiName.indexOf("/"));

            return context.lookup("ejb:" + appName + "/" + moduleName + "/" + distinctName + "/" + beanName + "!"
                    + interfacename);

        }

    } catch (NamingException e) {

        // TODO Auto-generated catch block

        e.printStackTrace();

    }

    return null;

但是,当我想在服务器启动期间访问相同的EJB时,我真正的问题出现了。服务bean内部的一个方法在服务器启动期间调用此EJB Bean。但它失败了消息

  

" EJBCLIENT000079:无法发现EJB请求的目的地

     

StatelessEJBLocator for" / ejb-remote-server / FlowControllerBean",view

     

是com.hexaware.framework.flowcontroller.FlowController接口,

     

亲和力是无"。

在执行查找之前,将部署实际的EJB bean。在启动期间进行查找之前,请在下面找到服务器的日志。

  

14:36:25,971 INFO [org.jboss.weld.deployer](MSC服务主题1-4)

     

WFLYWELD0003:处理焊接部署ejb-remote-server.jar

     

14:36:26,373 INFO [org.jboss.as.ejb3.deployment](MSC服务主题)    1-4)WFLYEJB0473:名为

的会话bean的JNDI绑定      

' FlowControllerBean'在部署单元&部署

     

" EJB-远程的server.jar"'如下:

     

的java:全球/ EJB-远程服务器/ FlowControllerBean com.hexaware.framework.flowcontroller.FlowController

     

的java:应用程序/ EJB-远程服务器/ FlowControllerBean com.hexaware.framework.flowcontroller.FlowController     Java的:模块/ FlowControllerBean com.hexaware.framework.flowcontroller.FlowController     Java的:JBoss的/导出/ EJB的远程服务器/ FlowControllerBean com.hexaware.framework.flowcontroller.FlowController     Java的:全球/ EJB远程服务器/ FlowControllerBean     的java:应用程序/ EJB-远程服务器/ FlowControllerBean     的java:模块/ FlowControllerBean

     

[org.apache.cxf.endpoint.ServerImpl](MSC服务线程1-4)设置   服务器的发布地址   http://localhost:8080/ejb-remote-server/EventManagerService   14:36:29,409 INFO [org.jboss.ws.cxf.deployment](MSC服务主题)   1-4)JBWS024074:WSDL发布到:   文件:/ d:/Magesh/Softwares/Jboss-eap-7.1/standalone/data/wsdl/ejb-remote-server.jar/EventManagerServiceService.wsdl   14:36:29,643 INFO [org.jboss.as.webservices](MSC服务主题1-4)   WFLYWS0003:启动服务   jboss.ws.endpoint" EJB-远程的server.jar" .EventStatusService   14:36:29,650 INFO [org.jboss.as.webservices](MSC服务主题1-2)   WFLYWS0003:启动服务   jboss.ws.endpoint" EJB-远程的server.jar" .EventManagerService   14:36:30,197 INFO [org.wildfly.extension.undertow](ServerService   线程池 - 72)WFLYUT0021:已注册的Web上下文:' / ejb-remote-server'对于服务器'默认服务器'

但是如果我在服务器完全启动后调用它,相同的代码就可以工作。

下面是我用于从客户端连接到远程服务器的属性文件。服务器和客户端都在我本地计算机的同一个Jboss服务器实例中。

  

remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED =假

     

remote.connections =默认

     

remote.connection.default.host =本地主机

     

remote.connection.default.port = 8080

     

remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS =假

注意:在启动或任何其他时间查找是成功的。但是当我尝试在bean中调用一个方法时,会遇到错误消息。但是,在服务器启动后,同样的bean方法调用可以正常工作

0 个答案:

没有答案