成功部署了一个cmp,但访问拒绝?

lyo 2003-09-15 04:33:00
已经和数据库关联上了,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);
///////////////////////////////////////////////////////////
,则说:“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");”去掉,又报错说:
"java.lang.ArrayIndexOutOfBoundsException: 13"
为什麽数组越界了?就是访问第一条数据啊?
...全文
66 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
lyo 2003-09-16
  • 打赏
  • 举报
回复
Help!
jcreatorqijiashe 2003-09-16
  • 打赏
  • 举报
回复
gz
lyo 2003-09-15
  • 打赏
  • 举报
回复
客户测试程序中,我把 Context.SECURITY...删掉了,不出现访问拒绝的Exception了,但是有:
java.lang.ArrayIndexOutOfBoundsException: 13"
怎麽会呢?我的mysql数据库中有两条纪录,我的查寻方法也没错啊,Integer primary=new Integer(1);
我的Home 接口是:
/////////////////////////////////////////////////////////////
public interface CustomerHomeRemote extends EJBHome{
public CustomerRemote create(Integer id)throws CreateException,RemoteException;
public CustomerRemote findByPrimaryKey(Integer id)throws FinderException,CreateException,RemoteException;
//////////////////////////////////////////////////////////////
Bean 类;
///////////////////////////////////////////////
public abstract class CustomerBean implements EntityBean{
public Integer ejbCreate(Integer id){
this.setId(id);
return null;
}
public void ejbPostCreate(Integer id){}

/* Lyo create ejb method*/
public abstract Integer getId();
public abstract void setId(Integer id);
public abstract String getFirstName();
public abstract void setFirstName(String fname);
public abstract String getLastName();
public abstract void setLastName(String lname);
/* End Lyo create*/
...........................................
.............................................
远程接口‘
/////////////////////////////////////////////////
public interface CustomerRemote extends EJBObject{
public void setFirstName(String fname)throws RemoteException;
public String getFirstName()throws RemoteException;
public void setLastName(String lname)throws RemoteException;
public String getLastName()throws RemoteException;
}

没有错啊?请帮忙!多谢
sunny110 2003-09-15
  • 打赏
  • 举报
回复
weblogic在\bea\wlserver6.1\config\mydomain\startWebLogic.cmd中 WLS_PW=password
lyo 2003-09-15
  • 打赏
  • 举报
回复
Help!

67,513

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧