调试cmp问题

03-07-09 luck
我在高试我的cmp时出现下如误:
-- Initializing bean access.

javax.naming.NameNotFoundException: Unable to resolve cmp2Remote. Resolved: '' Unresolved:'cmp2Remote' ; 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)-- Failed initializing bean access.



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:347)

at cmp2.cmp2TestClient2.initialize(cmp2TestClient2.java:36)

at cmp2.cmp2TestClient2.(cmp2TestClient2.java:1

at cmp2.cmp2TestClient2.main(cmp2TestClient2.java:304)

源程如下:
package cmp2;

import javax.naming.*;
import java.util.Properties;
import javax.rmi.PortableRemoteObject;

public class cmp2TestClient2 extends Object
{
private static final String ERROR_NULL_REMOTE = "Remote interface reference is null. It must be created by calling one of the Home interface methods first.";
private static final int MAX_OUTPUT_LINE_LENGTH = 100;
private boolean logging = true;
private cmp2RemoteHome cmp2RemoteHomeObject = null;
private cmp2Remote cmp2RemoteObject = null;

//Construct the EJB test client
public cmp2TestClient2()
{
initialize();
}

public void initialize()
{
long startTime = 0;
if (logging)
{
log("Initializing bean access.");
startTime = System.currentTimeMillis();
}

try
{
//get naming context
Context context = getInitialContext();

//look up jndi name
Object ref = context.lookup("cmp2Remote");
//look up jndi name and cast to Home interface
cmp2RemoteHomeObject = (cmp2RemoteHome) PortableRemoteObject.narrow(ref, cmp2RemoteHome.class);
if (logging)
{
long endTime = System.currentTimeMillis();
log("Succeeded initializing bean access through Home interface.");
log("Execution time: " + (endTime - startTime) + " ms.");
}
}
catch(Exception e)
{
if (logging)
{
log("Failed initializing bean access.");
}
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)
{
log("Unable to connect to WebLogic server at " + url);
log("Please make sure that the server is running.");
throw e;
}
}

//----------------------------------------------------------------------------
// Methods that use Home interface methods to generate a Remote interface reference
//----------------------------------------------------------------------------

public cmp2Remote create(String userid, String key_letter)
{
long startTime = 0;
if (logging)
{
log("Calling create(" + userid + ", " + key_letter + ")");
startTime = System.currentTimeMillis();
}
try
{
cmp2RemoteObject = cmp2RemoteHomeObject.create(userid, key_letter);
if (logging)
{
long endTime = System.currentTimeMillis();
log("Succeeded: create(" + userid + ", " + key_letter + ")");
log("Execution time: " + (endTime - startTime) + " ms.");
}
}
catch(Exception e)
{
if (logging)
{
log("Failed: create(" + userid + ", " + key_letter + ")");
}
e.printStackTrace();
}

if (logging)
{
log("Return value from create(" + userid + ", " + key_letter + "): " + cmp2RemoteObject + ".");
}
return cmp2RemoteObject;
}

public cmp2Remote findByPrimaryKey(String userid)
{
long startTime = 0;
if (logging)
{
log("Calling findByPrimaryKey(" + userid + ")");
startTime = System.currentTimeMillis();
}
try
{
cmp2RemoteObject = cmp2RemoteHomeObject.findByPrimaryKey(userid);
if (logging)
{
long endTime = System.currentTimeMillis();
log("Succeeded: findByPrimaryKey(" + userid + ")");
log("Execution time: " + (endTime - startTime) + " ms.");
}
}
catch(Exception e)
{
if (logging)
{
log("Failed: findByPrimaryKey(" + userid + ")");
}
e.printStackTrace();
}

if (logging)
{
log("Return value from findByPrimaryKey(" + userid + "): " + cmp2RemoteObject + ".");
}
return cmp2RemoteObject;
}

//----------------------------------------------------------------------------
// Methods that use Remote interface methods to access data through the bean
//----------------------------------------------------------------------------

public String getUserid()
{
String returnValue = "";

if (cmp2RemoteObject == null)
{
System.out.println("Error in getUserid(): " + ERROR_NULL_REMOTE);
return returnValue;
}

long startTime = 0;
if (logging)
{
log("Calling getUserid()");
startTime = System.currentTimeMillis();
}

try
{
returnValue = cmp2RemoteObject.getUserid();
if (logging)
{
long endTime = System.currentTimeMillis();
log("Succeeded: getUserid()");
log("Execution time: " + (endTime - startTime) + " ms.");
}
}
catch(Exception e)
{
if (logging)
{
log("Failed: getUserid()");
}
e.printStackTrace();
}

if (logging)
{
log("Return value from getUserid(): " + returnValue + ".");
}
return returnValue;
}

public void setKey_letter(String key_letter)
{
if (cmp2RemoteObject == null)
{
System.out.println("Error in setKey_letter(): " + ERROR_NULL_REMOTE);
return ;
}

long startTime = 0;
if (logging)
{
log("Calling setKey_letter(" + key_letter + ")");
startTime = System.currentTimeMillis();
}

try
{
cmp2RemoteObject.setKey_letter(key_letter);
if (logging)
{
long endTime = System.currentTimeMillis();
log("Succeeded: setKey_letter(" + key_letter + ")");
log("Execution time: " + (endTime - startTime) + " ms.");
}
}
catch(Exception e)
{
if (logging)
{
log("Failed: setKey_letter(" + key_letter + ")");
}
e.printStackTrace();
}
}

public String getKey_letter()
{
String returnValue = "";

if (cmp2RemoteObject == null)
{
System.out.println("Error in getKey_letter(): " + ERROR_NULL_REMOTE);
return returnValue;
}

long startTime = 0;
if (logging)
{
log("Calling getKey_letter()");
startTime = System.currentTimeMillis();
}

try
{
returnValue = cmp2RemoteObject.getKey_letter();
if (logging)
{
long endTime = System.currentTimeMillis();
log("Succeeded: getKey_letter()");
log("Execution time: " + (endTime - startTime) + " ms.");
}
}
catch(Exception e)
{
if (logging)
{
log("Failed: getKey_letter()");
}
e.printStackTrace();
}

if (logging)
{
log("Return value from getKey_letter(): " + returnValue + ".");
}
return returnValue;
}

//----------------------------------------------------------------------------
// Utility Methods
//----------------------------------------------------------------------------

private void log(String message)
{
if (message == null)
{
System.out.println("-- null");
return ;
}
if (message.length() > MAX_OUTPUT_LINE_LENGTH)
{
System.out.println("-- " + message.substring(0, MAX_OUTPUT_LINE_LENGTH) + " ...");
}
else
{
System.out.println("-- " + message);
}
}
//Main method

public static void main(String[] args)
{
cmp2TestClient2 client = new cmp2TestClient2();
// Use the client object to call one of the Home interface wrappers
// above, to create a Remote interface reference to the bean.
// If the return value is of the Remote interface type, you can use it
// to access the remote interface methods. You can also just use the
// client object to call the Remote interface wrappers.
}
}

请问是什么原因?