5 Replies Latest reply on Oct 20, 2003 5:49 AM by Juha Lindfors

    Context not passed between web tier and ejb tier

    Indu Newbie

      Context is not getting passed between webtier and ejb tier. What should I do to ejb container to trust the web container. I am getting the username as null and it is not passed to ejb tier. Please help me if anyone could answer this issue.

      Thanx in advance.

        • 1. Re: Context not passed between web tier and ejb tier
          Jan Radl Newbie

          You have to make new LoginContext in your JSP/Servlet tier and after that you can invoke methods in EJB container.

          Regards

          Jan

          • 2. Re: Context not passed between web tier and ejb tier
            Indu Newbie

            This is the code. Looks like it is going to the Exception and it is printing the username is null

            public static String getCallerName(EJBContext ctx)
            {
            logger.debug("In AuditHelper getCallerName entered");
            String userName = null;

            if (ctx != null)
            {
            try
            {
            logger.debug("In AuditHelper before ctx.getCallerPrincipal() ctx: " + ctx);
            java.security.Principal principal = ctx.getCallerPrincipal();
            logger.debug("In AuditHelper before principal.getName() principal: " + principal);
            userName = principal.getName();
            logger.debug("In AuditHelper after getCallerPrincipal().getName() userName: " + userName);
            }
            catch(Exception e)
            {
            logger.debug("In AuditHelper exception occurred: ");
            }
            }
            else
            {
            logger.debug("In AuditHelper ctx is null.");
            }

            logger.debug("In AuditHelper returned userName: " + userName);
            return userName;
            }

            below is my log:

            AuditHelper.getCallerName sessionContext: org.jboss.ejb.StatelessSessionEnterpriseContext$SessionContextImpl@1af8109
            2003-10-06 10:03:31,737 DEBUG [com.compuware.cis.util.application.ejb.security.AuditHelper] In AuditHelper getCallerName entered
            2003-10-06 10:03:31,737 DEBUG [com.compuware.cis.util.application.ejb.security.AuditHelper] In AuditHelper before ctx.getCallerPrincipal() ctx: org.jboss.ejb.StatelessSessionEnterpriseContext$SessionContextImpl@1af8109
            2003-10-06 10:03:31,753 DEBUG [com.compuware.cis.util.application.ejb.security.AuditHelper] In AuditHelper exception occurred:
            2003-10-06 10:03:31,753 DEBUG [com.compuware.cis.util.application.ejb.security.AuditHelper] In AuditHelper returned userName: null
            2003-10-06 10:03:31,753 DEBUG [EjbTier] In StartTargetSvcBean intiateTargeting Calling AuditHelper.getCallerName: null

            Thanks,
            Indu

            • 4. Re: Context not passed between web tier and ejb tier
              Indu Newbie

              My case is little different. We have a tool to develop application which comes with Jboss and Tomcat. The getCallerPrincipal() method is returning the principal when we test the application inside the tool. When we try to deploy it in Jboss/Jetty it is not working and I am getting an exception No security context set. Please let me know whether I should do any configuration in the Jetty or in Jboss.

              Thanks in advance,

              Indu

              • 5. Re: Context not passed between web tier and ejb tier
                Juha Lindfors Master

                Describe your configuration in more detail, are you performing authentication at the servlet tier, what do you have configured for the webtier, what security constraints do you have for your servlet?

                -- Juha