Hi,

i am using jboss3.2.3 with tomcat. I wrote a servlet, in which I want to use a JBoss - 
Session Bean. 

I always get the Excption like:

EJBException:; nested exception is: javax.ejb.EJBException: checkSecurityAssociation; 
CausedByException is: Authentication exception, principal=null

The source code is:

    public String execute(javax.servlet.http.HttpServletRequest request, 
javax.servlet.http.HttpServletResponse response, org.apache.velocity.context.Context 
pvContext) 
    {

        try
        {

            
            SecurityAssociationHandler handler = new SecurityAssociationHandler();
            Principal userPrincipal = new Principal()
            {
                    public String getName()
                    {
                            return "georg";
                    }
            };
            System.out.println(userPrincipal.getName());
            
            handler.setSecurityInfo(userPrincipal, "georg1");
            LoginContext loginContext =
                    new LoginContext("EJBSecurityDomain", (CallbackHandler) handler);
            loginContext.login();
            
            Context jndiContext = getInitialContext();

            Object ref = jndiContext.lookup("GeorgSQLHomeRemote");
             GeorgSQLHomeRemote georgHome = (GeorgSQLHomeRemote)
                PortableRemoteObject.narrow(ref,GeorgSQLHomeRemote.class);

            GeorgSQLRemote georg = georgHome.create();
             
            pvContext.put ("Meldung", "Huhu");
            
        }
        catch (Throwable t)
        {
            t.printStackTrace();
            pvContext.put ("Meldung", t.getMessage());
        }        
        
        
        return "userList.html";
    }

    static public Context getInitialContext() throws Exception 
    {
      // jndi.properties contains InitialContext properties
       Hashtable env = new Hashtable();
       env.put(Context.INITIAL_CONTEXT_FACTORY, 
"org.jnp.interfaces.NamingContextFactory");
       env.put(Context.OBJECT_FACTORIES, "org.jboss.naming:org.jnp.interfaces");
       env.put(Context.PROVIDER_URL, "192.168.249.23:1099");

       return new InitialContext(env);
    }    

My question, what have I to do, that the connection works?

Josef

View the original post : 
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3831192#3831192

Reply to the post : 
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3831192


-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to