0

我在 websphere 8.5.5 中部署了一个远程接口,我想在 Spring Boot 应用程序中查找它。我在我的spring boot中做了类似的接口,因为RMI我也使用了通用接口,SimpleRemoteStatelessSessionProxyFactoryBean但是返回的代理是null并且它正在抛出null指针proxy.invokeMethod()

@Configuration
public class Config {

    private static final String INITIAL_CONTEXT_FACTORY = "com.ibm.websphere.naming.WsnInitialContextFactory";
    private static final String PROVIDER_URL = "corbaname:iiop:localhost:2809/NameServiceServerRoot";

    @Primary
    @Bean
    public static AdminService adminService() {

        Properties jndiProps = new Properties();
        Properties properties = new Properties();
        properties.put(Context.INITIAL_CONTEXT_FACTORY, INITIAL_CONTEXT_FACTORY);
        properties.put(Context.PROVIDER_URL, PROVIDER_URL);

        SimpleRemoteStatelessSessionProxyFactoryBean factory = new SimpleRemoteStatelessSessionProxyFactoryBean();
        factory.setJndiEnvironment(jndiProps);
        factory.setJndiName("java:global/[AppName]/[ModuleName]/ejb/[BeanName]![RemoteInterface]");
        factory.setBusinessInterface(AdminService.class);
        factory.setResourceRef(true);
        AdminService proxy = (AdminService) factory.getObject();
        try {
            proxy.invokeMethod();
        }catch(RemoteException e) {
            e.printStackTrace();
        }

        return proxy;       
    }
}

现在它抛出这个错误:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'AdminService' defined in class path resource [...Config.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [...AdminService]: Factory method 'adminEJBService' threw exception; nested exception is javax.naming.NameNotFoundException: Name [global/[AppName]/[ModuleName]/ejb/[BeanName]![RemoteInterface] is not bound in this Context. Unable to find [global].
4

1 回答 1

0

您必须用[]实际名称替换其中的所有内容,因此 not [AppName],butMyApp等。如果不确定,您可以通过在SystemOut.logWebSphere 8.5.5 服务器的文件中查找 message来确定确切的查找字符串CNTR0167I。例如,实际的消息如下所示:

CNTR0167I: The server is binding the javax.management.j2ee.ManagementHome interface of the Management enterprise bean in the mejb.jar module of the ManagementEJB application.  The binding location is: java:global/ManagementEJB/mejb/Management!javax.management.j2ee.ManagementHome
于 2019-10-28T17:59:48.893 回答