1 Reply Latest reply on Jul 30, 2010 2:11 AM by asterisk

    Calling EJB results in Authentication exception, principal=null

    Sebastian Bayerlein Newbie

      Hi,

       

      I am calling an EJB from a swing application. In each dialog I am calling stateless EJB's from a JBoss 5.1.0 application server.

      The access of the ejb's is secured by a realm.

       

      I am calling the ejb once only. When first invoking a method of the ejb, it works fine. I can call this method as often as possible. But when calling a second method it fails with:

       

           java.lang.SecurityException: Authentication exception, principal=null
              at org.jboss.ejb.plugins.SecurityInterceptor.checkSecurityContext(SecurityInterceptor.java:321)
              at org.jboss.ejb.plugins.SecurityInterceptor.process(SecurityInterceptor.java:243)
              at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:211)
              at org.jboss.ejb.plugins.security.PreSecurityInterceptor.process(PreSecurityInterceptor.java:134)
              at org.jboss.ejb.plugins.security.PreSecurityInterceptor.invoke(PreSecurityInterceptor.java:81)
              at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:205)
              at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:138)

       

      getting initial context:


              Configuration.setConfiguration ( new LoginConfiguration ());

              Class cb = Class.forName ( "org.jboss.security.auth.callback.UsernamePasswordHandler" );
              Constructor c = cb.getConstructor ( new Class[] { String.class, char[].class });
              loginContext = new LoginContext ( "other", ( CallbackHandler ) c.newInstance ( new Object[] { appServerUser, appServerPassword.toCharArray() }));
              loginContext.login();
             
              result = new InitialContext ( h );

       

      getting ejb:


           context = getInitialContext( this.url, this.session.createQualifiedUsername( this.session.member, this.session.apptype, this.session.username), this.session.password, this.channel );

       

            EJBHome ejbHome = (EJBHome) context.lookup(( "b3." )+ managerName);
           
            Method creator = ejbHome.getClass().getMethod( "create", new Class[0]);
           
            EJBObject ejb = (EJBObject)creator.invoke( ejbHome, new Object[0]);
           
            return ejb;

       

      Can somebody tell me, what's the problem?

       

      Best regards,

      sebbay