成功部署了一個cmp,但client呼叫時說:"ArrayIndexOutOfBoundsException:"

lyojbuilder發表於2003-09-15
已經和資料庫關聯上了,weblogic顯示部署成功,如果用java程式訪問,程式碼:
////////////////////testclient.java//////////////////////////////

Properties pro=new Properties();
			pro.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
			pro.put(Context.PROVIDER_URL,"t3://127.0.0.1:7001");
			pro.put(Context.SECURITY_PRINCIPAL,"Employees");
		Context ctx=new InitialContext(pro);
		System.out.println("Debug...");
		Object obj=ctx.lookup("CustomerEJB");
		System.out.println("after lookup...");
		CustomerHomeRemote home=(CustomerHomeRemote)PortableRemoteObject.narrow(obj,CustomerHomeRemote.class);
		//create customers
		Integer primary=new Integer(1);
		
		CustomerRemote remote=home.create(primary);
		remote.setFirstName("lyo");
		remote.setLastName("Yashnoo");
		CustomerRemote customer=home.findByPrimaryKey(primary);
		String first=customer.getFirstName();
		String last=customer.getLastName();
		System.out.println("first name is"+first);
		System.out.println("=================");
		System.out.println("last name is"+last);
<p class="indent">

///////////////////////////////////////////////////////////
,則說:“Debug...
javax.naming.NamingException: Unhandled exception in lookup [Root exception is j
ava.lang.NullPointerException]”
如果寫在jsp中在weblogic中訪問,則控制檯報錯說:
“javax.naming.AuthenticationException [Root exception is javax.security.auth.logi
n.FailedLoginException: [Security:090304]Authentication Failed: User Employees j
avax.security.auth.login.FailedLoginException: [Security:090302]Authentication F
ailed: User Employees denied]

但是我的ejb-jar.xml和weblogic-ejb-jar.xml是授權了的:
///////////////////////////////////////////////
ejb-jar.xml
/////////////////////
..................
<assembly-descriptor>
<security-role>
<role-name>Employees</role-name>
</security-role>
<method-permission>
<role-name>Employees</role-name>
<method>
<ejb-name>CustomerEJB</ejb-name>
<method-name>*</method-name>
</method>
</method-permission>
.....................

weblogic-ejb-jar.xml
//////////////////////////////////

<security-role-assignment>
<role-name>Employees</role-name>
<principal-name>Employees</principal-name>
</security-role-assignment>
................................

以上不就是授權Employees可以訪問所有方法,且它的密碼為空嗎?
而且用weblogic的系統管理員都不能訪問!在weblogic中的security的group中我也加了Employees,還是不行,weblogic在哪裡設密碼?

我的資料庫中游一條紀錄,如果我把“Context.SECURITY_PRINCIPAL,"Employees");”去掉,jsp又報錯說:
"java.lang.ArrayIndexOutOfBoundsException: 13"
為什麼陣列越界了?訪問的的確就是第一條資料

如果去掉Context.SECURITY....,java控制檯程式報錯:"Debug...
after lookup...
Exception in thread "main" java.lang.AbstractMethodError: lyo.cmp.customer._Cust
omerHomeRemote_Stub.create(Ljava/lang/Integer;)Llyo/cmp/customer/CustomerRemote;"
誰能解釋一下為什麼會越界?

相關文章