aspose file tools*
The moose likes BEA/Weblogic and the fly likes Security Violation:  In Cabin EJB Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Products » BEA/Weblogic
Bookmark "Security Violation:  In Cabin EJB" Watch "Security Violation:  In Cabin EJB" New topic
Author

Security Violation: In Cabin EJB

shweta mathur
Ranch Hand

Joined: Sep 23, 2002
Posts: 109
Hi,
I just deployed my first Cabin EJB (from Monson-Haefel book) on weblogic 8.1.
But when I try to run the client, I get the following error
C:\bea\work\ejbbook\ex04_1>java com.titan.clients.Client_41
java.rmi.AccessException: [EJB:010160]Security Violation: User: '<anonymous>' ha
s insufficient permission to access EJB: type=<ejb>, application=titanejb, modul
e=titanejb, ejb=CabinEJB, method=create, methodInterface=Home, signature={java.l
ang.Integer}.
at weblogic.rjvm.BasicOutboundRequest.sendReceive(BasicOutboundRequest.j
ava:108)
at weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteR
ef.java:284)
at weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteR
ef.java:244)
at com.titan.cabin.CabinEJB_o1ckw5_HomeImpl_811_WLStub.create(Unknown So
urce)
at com.titan.clients.Client_41.main(Client_41.java:20)

CAn anybody pls let me know how do I remove this access problem...


--Shweta<br />SCJP 1.4 <br />SCWCD
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

You will have to give access to user by creating a roles and giving them method permission in ejb-jar.xml. Or better read the Weblogic security docs related to EJB.
http://edocs.bea.com


Groovy
shweta mathur
Ranch Hand

Joined: Sep 23, 2002
Posts: 109
But, I have already specified permission to everyone
In ejb-jar.xml
<method-permission>
<role-name>everyone</role-name>
<method>
<ejb-name>CabinEJB</ejb-name>
<method-name>*</method-name>
</method>
</method-permission>

In weblogic-jar.xml
<security-role-assignment>
<role-name>everyone</role-name>
<principal-name>ejbbook</principal-name>
<principal-name>guest</principal-name>
<principal-name>system</principal-name>
</security-role-assignment>

What am I still missing ?
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

In the jndi lookup have you specified the username as guest?
Your ejb-jar.xml and weblogic-ejb.jar looks fine to me. Can you pasted lookup code?
[ September 26, 2003: Message edited by: Pradeep Bhat ]
shweta mathur
Ranch Hand

Joined: Sep 23, 2002
Posts: 109
I am very new to EJB.....may be itz a very basic question but
how do I give the usename as guest in jndi lookup ??
My client is as follows

public class Client_41 {
public static void main(String [] args) {
try {
Context jndiContext = getInitialContext();
Object ref = jndiContext.lookup("CabinHomeRemote");
CabinHomeRemote home = (CabinHomeRemote)
PortableRemoteObject.narrow(ref,CabinHomeRemote.class);
CabinRemote cabin_1 = home.create(new Integer(1));
cabin_1.setName("Master Suite");
cabin_1.setDeckLevel(1);
cabin_1.setShipId(1);
cabin_1.setBedCount(3);

Integer pk = new Integer(1);

CabinRemote cabin_2 = home.findByPrimaryKey(pk);
System.out.println(cabin_2.getName());
System.out.println(cabin_2.getDeckLevel());
System.out.println(cabin_2.getShipId());
System.out.println(cabin_2.getBedCount());
} catch (java.rmi.RemoteException re){re.printStackTrace();}
catch (javax.naming.NamingException ne){ne.printStackTrace();}
catch (javax.ejb.CreateException ce){ce.printStackTrace();}
catch (javax.ejb.FinderException fe){fe.printStackTrace();}
}
public static Context getInitialContext()
throws javax.naming.NamingException {
Properties p = new Properties();
p.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
p.put(Context.PROVIDER_URL, "t3://localhost:7001");
return new javax.naming.InitialContext(p);
}
}
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

shweta mathur
Ranch Hand

Joined: Sep 23, 2002
Posts: 109
Hey Pradeep,
Thanks a ton for your help, it worked !!!
My First EJB...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Security Violation: In Cabin EJB