除錯cmp問題
我在高試我的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.
}
}
請問是什麼原因?
-- 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.
}
}
請問是什麼原因?
相關文章
- go除錯的問題。Go除錯
- 使用JBOSS開發CMP的問題?
- CMP DataSource問題,尋求解決方案
- 關於 swoole 除錯問題除錯
- this問題 以及 webstorm 除錯介面WebORM除錯
- VS - 打斷點/本地除錯/遠端除錯 問題斷點除錯
- jbuilder+jboss3.2開發CMP問題UIS3
- Laravel+xdebug 除錯問題Laravel除錯
- shell 指令碼的除錯問題指令碼除錯
- CMP+Oracle 報錯!!!! HelpOracle
- 用jb+jboss+oracle開發cmp出問題Oracle
- SQLServer2008 除錯問題SQLServer除錯
- 幽默:除錯程式碼問題的最佳方法除錯
- Linux MIPI 除錯中常見的問題Linux除錯
- android 除錯攝像機黑屏問題Android除錯
- linux下幾個問題的除錯Linux除錯
- 找到問題根源——評《Windows高階除錯》Windows高階除錯
- 請教:除錯時出現的問題除錯
- JiveJdon 除錯執行了,但有兩個問題除錯
- VSCode除錯Flutter的問題解決VSCode除錯Flutter
- 解決codeblocks無法除錯的問題BloC除錯
- 除錯433M模組遇到的問題除錯
- Xcode斷點除錯出現的問題XCode斷點除錯
- 解決除錯不能命中斷點的問題除錯斷點
- 新手關於jbuilder中除錯session的問題UI除錯Session
- vs2008不能除錯問題除錯
- [求助]jsp+javaBean除錯環境問題!JSJavaBean除錯
- 『開源』大半夜除錯TCP延遲問題除錯TCP
- 解決VisualStudio無法除錯的問題除錯
- samples-1.5_03問題望除錯成功的進除錯
- [文件教程]解決SAE下本地除錯相關問題除錯
- 如何分析 SAP Spartacus 路由問題之 CheckoutAuthGuard 單步除錯路由除錯
- vscode與chrome除錯配置與常見問題VSCodeChrome除錯
- 樹莓派除錯PCF8591遇到的小問題樹莓派除錯
- 氣蒙我了,下午光給小孩除錯問題了除錯
- 秒開快取系統常見問題除錯解答快取除錯
- VS2005無法啟動除錯問題除錯
- 使用GDB與QEMU除錯核心時的問題分析(轉)除錯