当前位置: 首页 > 知识库问答 >
问题:

wildfly 8-ejb客户端问题

田永春
2023-03-14

我正在遵循教程和:

将一个ejb部署到Wildfly 8-

Wildfly在部署ejb时返回此消息:

java:global/ejb/EmployeeManagementServiceImpl!staffmanagement.EmployeeManagementService
java:app/ejb/EmployeeManagementServiceImpl!staffmanagement.EmployeeManagementService
java:module/EmployeeManagementServiceImpl!staffmanagement.EmployeeManagementService
java:jboss/exported/ejb/EmployeeManagementServiceImpl!staffmanagement.EmployeeManagementService
java:global/ejb/EmployeeManagementServiceImpl
java:app/ejb/EmployeeManagementServiceImpl
java:module/EmployeeManagementServiceImpl

我的客户端尝试:

public class ClientApplicationTest {

public static void main( String[] args ) {
    System.out.println( "Hello World ClientApplicationTest!" );
    try {
        Context jndi = new InitialContext();
        String name = "java:module/EmployeeManagementServiceImpl";
        EmployeeManagementService service = (EmployeeManagementService) jndi.lookup(name);

        List<Employee> employees = service.getAllEmployees();
        for(Employee employee :employees ) {
            System.out.println(employee);
        }
    } catch (NamingException e) {
        e.printStackTrace();
    }
}

错误:

javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file:  java.naming.factory.initial
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:662)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:307)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:344)
at javax.naming.InitialContext.lookup(InitialContext.java:411)
at j2ee.staffmanagement.client.ClientApplicationTest.main(ClientApplicationTest.java:25)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)

我向客户端添加了以下库(除了ejb本身):/library/WildFly/modules/system/layers/base/org/jboss/as/appclient/main/WildFly-appclient-8.1.0。最终的jar(编译范围)

老实说,不确定出了什么问题:jndi名称,或者因为我从外部容器调用远程EJB,需要其他东西。

PS:EJB部署良好

是否有任何输入?

tnx

共有1个答案

闽康安
2023-03-14

我修改了:

    Properties jndiProperties = new Properties();
    jndiProperties.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
    jndiProperties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
    jndiProperties.put(Context.PROVIDER_URL, "http-remoting://localhost:8080");

    try {
        Context jndi = new InitialContext(jndiProperties);
        String appName = "";
        String moduleName = "staff";
        String distinctName = "";
        String beanName = "EmployeeManagementServiceImpl";
        String interfaceFullName = "staffmanagement.EmployeeManagementService";
        String jndiName = "ejb:" + appName + "/" + moduleName + "/" + distinctName + "/" + beanName + "!" + interfaceFullName;
        //ejb:{app-Name}/{module-Name}/{distinct-Name}/{bean-Name}!{fullPath-remote-Interface}
        EmployeeManagementService service = (EmployeeManagementService) jndi.lookup(jndiName);
        ...

并在类路径中添加了文件:jboss ejb client。属性

remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED=false
remote.connections=default
remote.connection.default.host=localhost 
remote.connection.default.port = 8080
remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false
 类似资料:
  • 我有几个通过EJB与“核心”项目交互的项目。这些项目大多使用相同的。然而,一个项目使用自己的,这是通过复制该项目所需的唯一EJB的文件来实现的。我有一个带有一个方法的EJB/接口: 它在方法中创建一个服务实例,并在服务中导入类“code”。包含weblogic创建的相关EJB/接口文件和应用程序类。另一个包含许多其他类,包括。 当我的项目调用时,我得到以下错误,但是中没有引用代码类。 null

  • 问题内容: 我目前正在将代码从Jboss7迁移到Wildfly10。 服务器本身完全可以启动。当尝试将我们的客户端与正在运行的新wildfly10服务器进行ejb-remote调用连接时,它将无法正常工作。 我唯一要使用的是以下错误: org.jboss.ejb.client.remoting.ConfigBasedEJBClientContextSelector setupEJBReceiver

  • 我目前正在将我们的代码从Jboss7迁移到Wildfly10。 服务器本身启动完全正常。当尝试将我们的客户端与正在工作的新Wildfly10服务器连接以进行ejb远程调用时,它就是不起作用。 我唯一可以处理的是以下错误: 组织。jboss。ejb。客户远程处理。ConfigBasedEJBClientContextSelector setupEJBReceivers警告:无法注册EJB接收器以连接

  • 就像https://docs.wildfly.org/14/developerguide.html所说的那样,我使用下面的代码配置了WebService客户端的超时: 只要我的WebService客户机运行在使用JDK8的WildFly8上,这就工作得很好。自从我将它迁移到WildFly14/JDK11之后,这个解决方案就不再起作用了。我试了几个地图键,比如: 有人知道吗? 你好,罗伯特

  • 我使用的是kafka-clients-0.10.1.1(单节点单代理) auto.create.topics.enable的默认值为true。 1.我正在使用以下方式向主题发送消息: 用于消费:

  • 1、MVC、MVP、MVVM的区别 MVC 模式将程序分为三个部分:模型 、视图(xml文件)、控制器(activity)。目的:将业务逻辑放在控制器里,把业务逻辑和视图层分离;缺点:Activity变得臃肿,Model 将新的数据发送到 View。 MVP 模式将程序分为三个部分:模型、视图(activity)、管理层(Presenter)。MVC模式的View 层和 Model 层存在耦合,M