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

所选bean不在同一模块或企业应用程序中

鱼锦
2023-03-14

只是一个暗中的机会,但是我需要一个本地接口来调用远程无状态EJB吗?

当我尝试通过NetBeans远程调用bean时:

Netbeans不允许在此bean上进行远程调用或任何调用。为什么不呢?

INFO:   visiting unvisited references
INFO:   visiting unvisited references
INFO:   EJB5181:Portable JNDI names for EJB MyRemoteSessionClass: [java:global/RemoteSalutation-ejb/MyRemoteSessionClass!net.bounceme.dur.glassfish.MyRemoteSession, java:global/RemoteSalutation-ejb/MyRemoteSessionClass]
INFO:   RemoteSalutation-ejb was successfully deployed in 941 milliseconds.
run-deploy:
Copying 1 file to /home/thufir/NetBeansProjects/RemoteLookup/dist
Copying 2 files to /home/thufir/NetBeansProjects/RemoteLookup/dist/RemoteLookupClient
Warning: /home/thufir/NetBeansProjects/RemoteLookup/dist/gfdeploy/RemoteLookup does not exist.
Sep 13, 2014 1:35:41 AM net.bounceme.dur.remote.RemoteLookup run
INFO: java.naming.factory.initial   com.sun.enterprise.naming.impl.SerialInitContextFactory
Sep 13, 2014 1:35:41 AM net.bounceme.dur.remote.RemoteLookup run
INFO: java.naming.factory.url.pkgs  com.sun.enterprise.naming
Sep 13, 2014 1:35:41 AM net.bounceme.dur.remote.RemoteLookup run
INFO: java.naming.factory.state com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl
Sep 13, 2014 1:35:46 AM net.bounceme.dur.remote.RemoteLookup main
SEVERE: Lookup failed for ' java:comp/env//RemoteSalutation-ejb/MyRemoteSessionClass!net/bounceme/dur/glassfish/MyRemoteSession' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, remote=net.bounceme.ix.Foo, org.omg.CORBA.ORBInitialHost=localhost, java.naming.security.principal=user, org.omg.CORBA.ORBInitialPort=3700, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.provider.url=server.local:1199, java.naming.factory.url.pkgs=com.sun.enterprise.naming, java.naming.security.credentials=password}
javax.naming.NamingException: Lookup failed for ' java:comp/env//RemoteSalutation-ejb/MyRemoteSessionClass!net/bounceme/dur/glassfish/MyRemoteSession' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, remote=net.bounceme.ix.Foo, org.omg.CORBA.ORBInitialHost=localhost, java.naming.security.principal=user, org.omg.CORBA.ORBInitialPort=3700, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.provider.url=server.local:1199, java.naming.factory.url.pkgs=com.sun.enterprise.naming, java.naming.security.credentials=password} [Root exception is javax.naming.NameNotFoundException:  java:comp]
    at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:491)
    at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:438)
    at javax.naming.InitialContext.lookup(InitialContext.java:411)
    at net.bounceme.dur.remote.RemoteLookup.run(RemoteLookup.java:34)
    at net.bounceme.dur.remote.RemoteLookup.main(RemoteLookup.java:18)
    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 org.glassfish.appclient.client.acc.AppClientContainer.launch(AppClientContainer.java:446)
    at org.glassfish.appclient.client.AppClientFacade.main(AppClientFacade.java:166)
Caused by: javax.naming.NameNotFoundException:  java:comp
    at com.sun.enterprise.naming.impl.TransientContext.resolveContext(TransientContext.java:299)
    at com.sun.enterprise.naming.impl.TransientContext.lookup(TransientContext.java:207)
    at com.sun.enterprise.naming.impl.SerialContextProviderImpl.lookup(SerialContextProviderImpl.java:66)
    at com.sun.enterprise.naming.impl.RemoteSerialContextProviderImpl.lookup(RemoteSerialContextProviderImpl.java:109)
    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.sun.corba.ee.impl.presentation.rmi.ReflectiveTie.dispatchToMethod(ReflectiveTie.java:143)
    at com.sun.corba.ee.impl.presentation.rmi.ReflectiveTie._invoke(ReflectiveTie.java:173)
    at com.sun.corba.ee.impl.protocol.ServerRequestDispatcherImpl.dispatchToServant(ServerRequestDispatcherImpl.java:528)
    at com.sun.corba.ee.impl.protocol.ServerRequestDispatcherImpl.dispatch(ServerRequestDispatcherImpl.java:199)
    at com.sun.corba.ee.impl.protocol.MessageMediatorImpl.handleRequestRequest(MessageMediatorImpl.java:1549)
    at com.sun.corba.ee.impl.protocol.MessageMediatorImpl.handleRequest(MessageMediatorImpl.java:1425)
    at com.sun.corba.ee.impl.protocol.MessageMediatorImpl.handleInput(MessageMediatorImpl.java:930)
    at com.sun.corba.ee.impl.protocol.giopmsgheaders.RequestMessage_1_2.callback(RequestMessage_1_2.java:213)
    at com.sun.corba.ee.impl.protocol.MessageMediatorImpl.handleRequest(MessageMediatorImpl.java:694)
    at com.sun.corba.ee.impl.protocol.MessageMediatorImpl.dispatch(MessageMediatorImpl.java:496)
    at com.sun.corba.ee.impl.protocol.MessageMediatorImpl.doWork(MessageMediatorImpl.java:2222)
    at com.sun.corba.ee.impl.threadpool.ThreadPoolImpl$WorkerThread.performWork(ThreadPoolImpl.java:497)
    at com.sun.corba.ee.impl.threadpool.ThreadPoolImpl$WorkerThread.run(ThreadPoolImpl.java:540)

run:
BUILD SUCCESSFUL (total time: 17 seconds)
package net.bounceme.dur.remote;

import java.util.Enumeration;
import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

public class RemoteLookup {

    private static final Logger log = Logger.getLogger(RemoteLookup.class.getName());
    private final MyProps p = new MyProps();

    public static void main(String... args) {
        try {
            new RemoteLookup().run();
        } catch (NamingException ex) {
            Logger.getLogger(RemoteLookup.class.getName()).log(Level.SEVERE, ex.getExplanation(), ex);
        }
    }

    private void run() throws NamingException {
        Properties jndi = p.getJNDI();
        Enumeration e = jndi.propertyNames();
        while (e.hasMoreElements()) {
            String key = (String) e.nextElement();
            String val = jndi.getProperty(key);
            log.info(key + "\t" + val);
        }
        Context ic = new InitialContext();
        //    Object o = ic.lookup(" java:comp/env/RemoteSalutation-ejb/MyRemoteSessionClass");
        Object o = ic.lookup(" java:comp/env//RemoteSalutation-ejb/MyRemoteSessionClass!net/bounceme/dur/glassfish/MyRemoteSession");
    }
}
package net.bounceme.dur.glassfish;

import javax.ejb.Stateless;

//@LocalBean
@Stateless(mappedName = "salutationBean")
public class MyRemoteSessionClass implements MyRemoteSession {

    @Override
    public String SayHello() {
        return "hello from glassfish..";
    }

    @Override
    public String SayBye() {
        return "goodbye..";
    }
}

虽然我改了一些名字..否则应该和教程完全一样。

共有1个答案

钱飞翼
2023-03-14

尝试object o=ic.lookup(“salutationbean”);注意mappedName指定在JNDI中用于远程访问的名称。

 类似资料:
  • 问题内容: 如果我的Web应用程序和ejb应用程序在同一台机器上(在同一JVM上),并且所有ejb调用都是本地调用,那么在将信息从Web传递到ejb时,使用create会不会出现问题? 如果ejb呼叫是远程的,有什么解决方法?将信息可以从Web应用程序到EJB应用程序?在这种情况下建议使用吗? 问题答案: 对于第一个问题,只要在每次调用结束时都删除ThreadLocal变量,就没有问题。这很重要,

  • 我在多模块项目中工作。目前我面临以下问题: > 模块A 模块B 模块A依赖于B 模块A有以下方法@GetMapping(path=“/GetWorkspace”) } 模块B有以下方法,我需要使用模块A提到的endpoint 公共字符串consumeModuelAMethod(){ 当我从模块A通过RestTemboard调用“http://localhost:8080/getworkspaces

  • 我有1个应用程序和2个模块 框架结构 但我不能在MyApp中使用MyModule的文件。IDE显示我“无法访问”错误,我想扩展一个MyModule类的类。而且它不是从MyModule创建类的,有人对此有想法吗?怎么了?

  • 我使用Netbeans来了解JavaEE。我使用“插入代码”和“调用企业bean”来获取一个远程bean,其接口位于我的项目中包含的库中。如果我的项目是一个web应用程序netbeans,那么这样做会插入一个如下所示的函数。(这是一个jndi查找,对吗?) 当您在企业应用程序客户端中执行同样的操作时,netbeans只会给出 这是为什么? 如果我试图在web应用程序中手动创建第二个,服务器会出现如

  • 当我尝试使用向导(蚂蚁项目)创建企业应用程序时,我得到以下错误 当然,向导中的所有字段都已填充。但是,单独创建WAR和EJB时没有错误。该错误仅在创建EAR时发生,即使EAR为空。 使用 NetBeans 12.6 Windows 10 OS Glassfish服务器6.2.1 Java17 所有路径均正确拼写,并设置了对目录的读/写权限 屏幕

  • 企业授权应用流程 PDF版下载 企业的系统管理员从管理后台-应用市场发起授权安装第三方应用,安装后如流平台会将授权凭证、授权信息等推送给服务商后台。 详细步骤: 企业管理员授权安装应用 企业的系统管理员从管理后台应用市场发起授权安装第三方应用; 授权成功,回调临时授权码 a) 授权成功后,如流企业平台会回调应用开发信息中填写的安装事件回调地址,GET参数上带上临时授权码auth_code; b)