Hi All,
I'm using EJB2.0 with WSAD 5.0.
I'm having a simple
EJB deployed on the WSAD's
test Server.
This EJB logs the message given by the client EJB.
Following is its Deployment Descriptor, which is having one role and method permission.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
<ejb-jar id="ejb-jar_ID">
<display-name>SCEA_Preperation</display-name>
<enterprise-beans>
<session id="SCEASLSessionBean">
<ejb-name>SCEASLSessionBean</ejb-name>
<home>com.scea.test.ejb.sls.SCEASLSessionBeanHome</home>
<remote>com.scea.test.ejb.sls.SCEASLSessionBean</remote>
<ejb-class>com.scea.test.ejb.sls.SCEASLSessionBeanBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
</session>
</enterprise-beans>
<assembly-descriptor>
<security-role>
<description></description>
<role-name>Administrator</role-name>
</security-role>
<method-permission>
<role-name>Administrator</role-name>
<method>
<ejb-name>SCEASLSessionBean</ejb-name>
<method-name>*</method-name>
</method>
</method-permission>
<container-transaction>
<method>
<ejb-name>SCEASLSessionBean</ejb-name>
<method-name>*</method-name>
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction>
</assembly-descriptor>
</ejb-jar>
This is the client from which I'm calling this Bean.
public class StatelessBeanClient
{
public static void main(
String[] args)
{
SCEASLSessionBeanHome home = null;
SCEASLSessionBean bean = null;
try {
Properties prop = new Properties();
//prop.put(Context.SECURITY_PRINCIPAL, "manager2");
//prop.put(Context.SECURITY_CREDENTIALS, "manager2");
prop.put(Context.INITIAL_CONTEXT_FACTORY,"com.ibm.websphere.naming.WsnInitialContextFactory");
prop.put(Context.PROVIDER_URL, "iiop://10.74.64.85:2809");
InitialContext context = new InitialContext(prop);
Object object =context.lookup("ejb/com/scea/test/ejb/sls/SCEASLSessionBeanHome");
home = (SCEASLSessionBeanHome) PortableRemoteObject.narrow(object, SCEASLSessionBeanHome.class);
bean = home.create();
bean.logMessage("Hello from Test Client....");
System.out.println("Done....");
} catch (NamingException e) {
System.out.print("NamingException");
e.printStackTrace();
}
catch (RemoteException e) {
System.out.print("RemoteException");
e.printStackTrace();
}
catch (CreateException e) {
System.out.print("CreateException");
e.printStackTrace();
}
finally
{
try {
if (bean != null)
{
bean.remove();
}
} catch (RemoteException e) {
} catch (RemoveException e) {
}
}
}
}
------
Issue is irrespective of the PRINCIPAL I'm passing or not passing I'm able to access the method Bean.
Ideally it should container should throw SecuritException.
Please correct me If I'm wrong or I have to do some more configuration in the deployment descrp. for enabling the security.
And I have one more small issue, As I start the Test Server I can the output of the Sysouts on the console but when I run any other
Java Application the existing server console overwritten with the new Sysouts of the Java Application. And I'm not able to see the Server side Sysouts.
So, can any body please give me direction to solve the above two issues.
Thanks for your help!
Regards,
Manish