• Post Reply Bookmark Topic Watch Topic
  • New Topic

what is the reason? please help me  RSS feed

 
ang yin
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I write a Entity bean by Jbuilder6, it insert database table 4 rows,the table has two columns: name,balance
and I deploy it in the weblogic6.1.
I write a client program under below:
package jb6entity1;
import javax.naming.*;
import java.util.Properties;
import javax.rmi.PortableRemoteObject;
public class AccountTestClient1 {
private AccountHome accountHome = null;
//Construct the EJB test client
public AccountTestClient1() {
try {
//get naming context
Context ctx = getInitialContext();
//look up jndi name
Object ref = ctx.lookup("Account");
//cast to Home interface
accountHome = (AccountHome) PortableRemoteObject.narrow(ref, AccountHome.class);

Account ac1=accountHome.create("John","150");
Account ac2=accountHome.create("Paul","150");
Account ac3=accountHome.create("George","150");
Account ac4=accountHome.create("Ringo","150");

}
catch(Exception e) {
e.printStackTrace();
}
}
private Context getInitialContext() throws Exception {
String url = "t3://localhost:7001";
String user = null;
String password = null;
Properties properties = null;
try {
properties = new Properties();
properties.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
properties.put(Context.PROVIDER_URL, url);
if (user != null) {
properties.put(Context.SECURITY_PRINCIPAL, user);
properties.put(Context.SECURITY_CREDENTIALS, password == null ? "" : password);
}
return new InitialContext(properties);
}
catch(Exception e) {
System.out.println("Unable to connect to WebLogic server at " + url);
System.out.println("Please make sure that the server is running.");
throw e;
}
}
//----------------------------------------------------------------------------
// Utility Methods
//----------------------------------------------------------------------------
public AccountHome getHome() {
return accountHome;
}
//Main method
public static void main(String[] args) {
AccountTestClient1 client = new AccountTestClient1();
// Use the getHome() method of the client object to call Home interface
// methods that will return a Remote interface reference. Then
// use that Remote interface reference to access the EJB.
}
}
there is always a error:
javax.naming.NameNotFoundException: Unable to resolve Account. Resolved: '' Unresolved:'Account' ; remaining name ''
at weblogic.rmi.internal.BasicOutboundRequest.sendReceive(BasicOutboundRequest.java:85)
at weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteRef.java:253)
at weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteRef.java:220)
at weblogic.rmi.internal.ProxyStub.invoke(ProxyStub.java:35)
at $Proxy0.lookup(Unknown Source)
at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:323)
at javax.naming.InitialContext.lookup(InitialContext.java:350)
at jb6entity1.AccountTestClient1.<init>(AccountTestClient1.java:17)
at jb6entity1.AccountTestClient1.main(AccountTestClient1.java:70)

what is reason???
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!