问题描述
请问,我用java程序,去调用一个发布在websphereapplicationsever6.1下的ejb3.0程序怎么掉,因为在调用的时候是加了,用户名密码,传过去,做一个安全认证的.我想问,是我的代码错了,还是那俩个文件放错了,还是都错了。希望能给个全点的答案,谢谢。代码如下。接口:packageitso.bank;publicinterfaceSecurityEJB{publicStringecho(Stringmessage);}实现类:packageitso.bank;importjavax.annotation.security.RolesAllowed;importjavax.ejb.Remote;importjavax.ejb.Stateless;@Remote(SecurityEJB.class)@StatelesspublicclassSecurityEJBBeanimplementsSecurityEJB{@RolesAllowed({"user"})publicStringecho(Stringmessage){returnmessage+"test";}}测试代码:publicstaticvoidmain(String[]args){//TODOAuto-generatedmethodstubPropertiesproperties=newProperties();properties.put("org.omg.CORBA.ORBClass","com.ibm.CORBA.iiop.ORB");properties.put(Context.PROVIDER_URL,"iiop://localhost:2809");properties.put(Context.INITIAL_CONTEXT_FACTORY,"com.ibm.websphere.naming.WsnInitialContextFactory");properties.setProperty(Context.SECURITY_PRINCIPAL,"guo");properties.setProperty(Context.SECURITY_CREDENTIALS,"guo");try{Contextcontext=newInitialContext(properties);itso.bank.SecurityEJBsecurity=(itso.bank.SecurityEJB)context.lookup("ejb/TestEJB/TestEJB.jar/SecurityEJBBean#itso.bank.SecurityEJB");System.out.println(security.echo("XXX"));}}还有2个props文件users.props#Format:#name:passwd:uid:gids:displayname#wherename=userId/userNameoftheuser#passwd=passwordoftheuser#uid=uniqueIdoftheuser#gid=groupIdsofthegroupsthattheuserbelongsto#displayname=(optional)displaynamefortheuseradmin:admin:0:0:Administratorguo:guo:1::visitor:visitor:2::jacek:password:3::groups.props#Format:#name:gid:users:displayname#wherename=groupIdofthegroup#gid=uniqueIdofthegroup#users=listofalltheuserIdsthatthegroupcontains#displayname=(optional)displaynameforthegroupadministrator:0:admin:Administrativegroupuser:1:guo:1
解决方案
解决方案二:
没人知道吗?自己顶下
解决方案三:
没遇到过,路过学习学习!帮顶!
解决方案四:
调用程序看似没有问题,不用main方法,在web环境下调一下试试。