当前位置: 技术问答>java相关
jboss中的jndi问题
来源: 互联网 发布时间:2017-05-02
本文导语: 我从jboss网站下载了jboss3.0的一个文档JBoss.3.0QuickStart.Draft3.pdf以及对应的代码JBoss.3.0TemplateAndExamples.zip,解压后,用按照文档的说明,用ant发布其模板工程template,显示"BUILD SUCCESSFUL",好像已经发布成功,并且,ejb-test.jar文件也...
我从jboss网站下载了jboss3.0的一个文档JBoss.3.0QuickStart.Draft3.pdf以及对应的代码JBoss.3.0TemplateAndExamples.zip,解压后,用按照文档的说明,用ant发布其模板工程template,显示"BUILD SUCCESSFUL",好像已经发布成功,并且,ejb-test.jar文件也已经copy到了serverdefaultdeploy(我配的jboss.configuration=deploy)目录下面,好像一切都很正常.但是当我运行buildbin下面的run-client.bat时,TestClient.java文件如下:
/*
* JBoss, the OpenSource J2EE webOS
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package test.client;
import javax.naming.InitialContext;
import javax.rmi.PortableRemoteObject;
import test.interfaces.TestSession;
import test.interfaces.TestSessionHome;
public class TestClient {
public static void main(String[] args){
try {
System.out.println("begin");
InitialContext lContext = new InitialContext();
System.out.println("before lookup");
TestSessionHome lHome = (TestSessionHome) lContext.lookup( "ejb/test/TestSession" );
System.out.println(lHome.getClass().getName());
TestSession lSession = lHome.create();
// Get a new Id of the Test Entity
int lId = lSession.getNewEntityId();
System.out.println( "New Entity Id is: " + lId );
lSession.remove();
} catch( Exception e ){
System.out.println("exception"+e.getMessage());
e.printStackTrace();
}
}
}
报错:
begin//我加的调试信息,进入main()
before lookup//查找HOME之前
exception test not bound//报错ejb/test/TestSession未绑定?
javax.naming.NameNotFoundException: test not bound
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(Stream
RemoteCall.java:245)
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:
220)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:122)
at org.jnp.server.NamingServer_Stub.lookup(Unknown Source)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:464)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:443)
at javax.naming.InitialContext.lookup(InitialContext.java:350)
at test.client.TestClient.main(TestClient.java:22)
那么怎样才能把ejb Home绑定到jndi呢?请jboss高手赐教,谢谢
/*
* JBoss, the OpenSource J2EE webOS
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package test.client;
import javax.naming.InitialContext;
import javax.rmi.PortableRemoteObject;
import test.interfaces.TestSession;
import test.interfaces.TestSessionHome;
public class TestClient {
public static void main(String[] args){
try {
System.out.println("begin");
InitialContext lContext = new InitialContext();
System.out.println("before lookup");
TestSessionHome lHome = (TestSessionHome) lContext.lookup( "ejb/test/TestSession" );
System.out.println(lHome.getClass().getName());
TestSession lSession = lHome.create();
// Get a new Id of the Test Entity
int lId = lSession.getNewEntityId();
System.out.println( "New Entity Id is: " + lId );
lSession.remove();
} catch( Exception e ){
System.out.println("exception"+e.getMessage());
e.printStackTrace();
}
}
}
报错:
begin//我加的调试信息,进入main()
before lookup//查找HOME之前
exception test not bound//报错ejb/test/TestSession未绑定?
javax.naming.NameNotFoundException: test not bound
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(Stream
RemoteCall.java:245)
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:
220)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:122)
at org.jnp.server.NamingServer_Stub.lookup(Unknown Source)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:464)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:443)
at javax.naming.InitialContext.lookup(InitialContext.java:350)
at test.client.TestClient.main(TestClient.java:22)
那么怎样才能把ejb Home绑定到jndi呢?请jboss高手赐教,谢谢
|
InitialContext lContext = new InitialContext(??);