You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Zhiyong Li <Zh...@ibiomatics.com> on 2001/07/03 15:27:22 UTC

How to keep the same credential in the new thread

This is not a direct Struts question. But I will go ahead ask:
I am using WebLogic 6.0 on Sun Solaris. I have my servlet be protected
by RDBMS realm. When the servlet is invoked, it will
spawn a new thread. However, this new thread gets a "guest" credential.
For example,
weblogic.security.acl.Security.getCurrentUser.getName() will return
"guest"

Is there a easy way to create a new thread however keep the
"credential"?

Thanks,
Zhiyong Li
Platform Development
iBiomatics LLC ,  a SAS Company
(919) 653-2746
Zhiyong.Li@iBiomatics.com



RE: Problem with sturts and ejb

Posted by joi <jo...@maskina.com>.
this is my lookup code for the UserManagementBean.
Have also tried 
Object homeObject = m_ctx.lookup("java:comp/env/ejbUserManagement");
but it returns class not found exception
my system.out.println("m_ctx.getEnvironment().size() =")  prints out
zero or "0"

I hope this will help.
	
    m_ctx = new InitialContext();
    UserManagementHome home = null;
    try
    {
        System.out.println("m_ctx.getEnvironment().size() = " +
m_ctx.getEnvironment().size() );
        Object homeObject = m_ctx.lookup("ejbUserManagement");
        home =
(UserManagementHome)PortableRemoteObject.narrow(homeObject,
UserManagementHome.class);
    }
    catch (Exception e)
    {
        System.out.println("Class: Model, Method: registerUser, Message:
" + e);
    }
      UserManagementRemote pUserManagement = null;
      try
      {
         pUserManagement = home.create();
      }
      catch (Exception e)
      {
         System.out.println("Class: Model, Method : registerUser, Error
message" + e);
      }
     try
      {
         if (pUserManagement == null)
         {
            System.out.println("pUserManagement is null");
         }
         pUserManagement.registerUser(strUsername,strPassword);
      }
      catch (RemoteException ex)
      {
         System.out.println("Class: Model, Method : registerUser, Error
message: RemoteException " + ex);
      }


with thanks.

-----Original Message-----
From: Wayland Chan [mailto:infinii@yahoo.com] 
Sent: Tuesday, 03, July, 2001 15:45
To: struts-user@jakarta.apache.org
Subject: Re: Problem with sturts and ejb


Johann,

Can you show us the code in your action class that
does the EJB lookup?

Should probably look something like...

Properties p = new Properties(); p.put(Context.INITIAL_CONTEXT_FACTORY,
DBConnectionManager.getInstance().JNDI_INITIAL_FACTORY);
p.put(Context.PROVIDER_URL,
DBConnectionManager.getInstance().JNDI_PROVIDER_URL);
Context ctx = new InitialContext(p);
java.lang.Object o = ctx.lookup("UserManagerHome"); UserManagerHome
userHome = (UserManagerHome)javax.rmi.PortableRemoteObject.narrow(o,
UserManagerHome.class);
userManager = userHome.create();

Regards,

Wayland Chan

--- joi <jo...@maskina.com> wrote:
> Hi!
> I have a problem accessing the InitialContext in the
> action
> classes..when i perform lookup on my ejb's I get
> this error message...
> 
> "Error instantiating web-app JNDI-context: No
> location specified and no
> suitable instance of the type
>
'com.maskina.mcstudio.model.persistance.UserManagementRemote'
> found for
> the ejb-ref ejbUserManagement"
>  
> Does anyone have the answer..?
> 


__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/


Re: Problem with sturts and ejb

Posted by Wayland Chan <in...@yahoo.com>.
Johann,

Can you show us the code in your action class that
does the EJB lookup?

Should probably look something like...

Properties p = new Properties();
p.put(Context.INITIAL_CONTEXT_FACTORY,
DBConnectionManager.getInstance().JNDI_INITIAL_FACTORY);
p.put(Context.PROVIDER_URL,
DBConnectionManager.getInstance().JNDI_PROVIDER_URL);
Context ctx = new InitialContext(p);
java.lang.Object o = ctx.lookup("UserManagerHome");
UserManagerHome userHome =
(UserManagerHome)javax.rmi.PortableRemoteObject.narrow(o,
UserManagerHome.class);
userManager = userHome.create();

Regards,

Wayland Chan

--- joi <jo...@maskina.com> wrote:
> Hi!
> I have a problem accessing the InitialContext in the
> action
> classes..when i perform lookup on my ejb's I get
> this error message...
> 
> "Error instantiating web-app JNDI-context: No
> location specified and no
> suitable instance of the type
>
'com.maskina.mcstudio.model.persistance.UserManagementRemote'
> found for
> the ejb-ref ejbUserManagement"
>  
> Does anyone have the answer..?
> 


__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/

Problem with sturts and ejb

Posted by joi <jo...@maskina.com>.
Hi!
I have a problem accessing the InitialContext in the action
classes..when i perform lookup on my ejb's I get this error message...

"Error instantiating web-app JNDI-context: No location specified and no
suitable instance of the type
'com.maskina.mcstudio.model.persistance.UserManagementRemote' found for
the ejb-ref ejbUserManagement"
 
Does anyone have the answer..?

 -----Original Message-----
From: Zhiyong Li [mailto:Zhiyong.Li@ibiomatics.com] 
Sent: Tuesday, 03, July, 2001 13:27
To: struts-user@jakarta.apache.org
Subject: How to keep the same credential in the new thread



This is not a direct Struts question. But I will go ahead ask: 
I am using WebLogic 6.0 on Sun Solaris. I have my servlet be protected
by RDBMS realm. When the servlet is invoked, it will
spawn a new thread. However, this new thread gets a "guest" credential.
For example,
weblogic.security.acl.Security.getCurrentUser.getName() will return
"guest"

Is there a easy way to create a new thread however keep the
"credential"?

Thanks, 
Zhiyong Li 
Platform Development 
iBiomatics LLC ,  a SAS Company 
(919) 653-2746 
Zhiyong.Li@iBiomatics.com