相关疑难解决方法(0)

客户端的@EJB注释

使用NetBeans,我在包含的类中执行以下操作main(),它可以工作:

import javax.ejb.EJB;

public class Master {
    @EJB
    TestBeanARemote x;

    public static void main(String[] args) {
        Master m = new Master();
        m.doStuff();
    }
//doStuff includes x, but it works, so who cares.
...
Run Code Online (Sandbox Code Playgroud)

但是,如果我在被调用的类中执行此操作,则会失败.似乎被调用的类要求我避免使用注释,而是使用整个InitialContext()设置.

String testRun(String arg) {
   InitialContext ic;
    try {
        ic = new InitialContext();
        x = (TestBeanARemote) ic.lookup("com.bnncpa.testing.TestBeanARemote");
        return x.testRun(arg);

    }
Run Code Online (Sandbox Code Playgroud)

完整的失败副本如下:

package enterpriseapplication1;
public class Main {

    private Secondary x = new Secondary();

    public static void main(String[] args) {
        Main m = new …
Run Code Online (Sandbox Code Playgroud)

java netbeans ejb java-ee

11
推荐指数
1
解决办法
2万
查看次数

标签 统计

ejb ×1

java ×1

java-ee ×1

netbeans ×1