これが私のBeanクラスのソースです
@Stateless(mappedName="StringVal") public class NewSessionBean は NewSessionRemote を実装します {
String val = null;
public String stringChange(int parameter) {
while(parameter < 5){
switch (parameter){
case 1: System.out.println(val + "One" + ",");
case 2: System.out.println(val + "Two" + ",");
case 3: System.out.println(val + "Three" + ",");
case 4: System.out.println(val + "Four" + ",");
}
}
return val;
}
}
そして、これがこの Bean のクライアント クラスです (スタンドアロン クライアント)
endpoint.NewSessionRemote をインポートします。import javax.naming.InitialContext;
パブリック クラス TestLogicBean {
static String retVal = null;
public static void main(String[] args) {
try {
InitialContext ctx = new InitialContext();
NewSessionRemote br = (NewSessionRemote) ctx.lookup("StringVal");
for (int i = 0; i < 5; i++) {
String retVal1 = br.stringChange(i);
System.out.println("EJB message is:" + retVal1);
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
しかし、私はこの例外 "javax.naming.NoInitialContextException: クラス名を環境またはシステム プロパティ、またはアプレット パラメータとして、またはアプリケーション リソース ファイルで指定する必要があります: java.naming.factory.initial" を取得しています。
これを行うためにいくつかの方法を試しましたが、それでもこの例外が発生します。