5 Replies Latest reply on Sep 9, 2007 2:56 AM by mnrz

    problem with Authenticator

    mnrz

      Hi

      I have an Authenticator component in my application and it was working fine until yesterday and now it's treating weird, I had no changes since yesterday but it throws following exception.

      Hibernate: select user0_.username as username3_, user0_.address as address3_, user0_.group_id as group13_3_, u
      ser0_.password as password3_, user0_.position as position3_, user0_.idCity as idCity3_, user0_.mobileContact a
      s mobileCo6_3_, user0_.phoneNo1 as phoneNo7_3_, user0_.phoneNo2 as phoneNo8_3_, user0_.speciality as specialit
      y3_, user0_.statusCode as statusCode3_, user0_.uPIN as uPIN3_, user0_.enabled as enabled3_ from user user0_ wh
      ere user0_.username=? and user0_.password=?
      Hibernate: select group0_.id as id1_1_, group0_.name as name1_1_, group0_.permissionGroup as permissi3_1_1_, g
      roup0_.exportPermission as exportPe4_1_1_, permission1_.groupId as groupId3_, permission1_.id as id3_, permiss
      ion1_.id as id2_0_, permission1_.permission as permission2_0_, permission1_.groupId as groupId2_0_, permission
      1_.fieldName as fieldName2_0_, permission1_.category as category2_0_, permission1_.displayablePermission as di
      splaya5_2_0_, permission1_.searchablePermission as searchab6_2_0_ from group_permission group0_ left outer joi
      n permission permission1_ on group0_.id=permission1_.groupId where group0_.id=?
      java.lang.IllegalStateException: No transaction.
       at org.jboss.tm.TxManager.setRollbackOnly(TxManager.java:751)
       at org.hibernate.ejb.AbstractEntityManagerImpl.markAsRollback(AbstractEntityManagerImpl.java:392)
       at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.jav
      a:545)
       at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.jav
      a:567)
       at org.hibernate.ejb.QueryImpl.getSingleResult(QueryImpl.java:72)
       at com.payvand.search.model.business.Authenticator.authenticate(Authenticator.java:59)
       at com.payvand.search.model.business.Authenticator$$FastClassByCGLIB$$28b8687e.invoke(<generated>)
       at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
       at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:45)
       at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:55)
       at org.jboss.seam.interceptors.OutcomeInterceptor.interceptOutcome(OutcomeInterceptor.java:21)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.jboss.seam.util.Reflections.invoke(Reflections.java:18)
       at org.jboss.seam.intercept.Interceptor.aroundInvoke(Interceptor.java:169)
       at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:64)
       at org.jboss.seam.interceptors.RollbackInterceptor.rollbackIfNecessary(RollbackInterceptor.java:29)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.jboss.seam.util.Reflections.invoke(Reflections.java:18)
       at org.jboss.seam.intercept.Interceptor.aroundInvoke(Interceptor.java:169)
       at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:64)
       at org.jboss.seam.interceptors.BijectionInterceptor.bijectNonreentrantComponent(BijectionInterceptor.j
      ava:79)
       at org.jboss.seam.interceptors.BijectionInterceptor.bijectComponent(BijectionInterceptor.java:58)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.jboss.seam.util.Reflections.invoke(Reflections.java:18)
       at org.jboss.seam.intercept.Interceptor.aroundInvoke(Interceptor.java:169)
       at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:64)
       at org.jboss.seam.interceptors.ConversationInterceptor.endOrBeginLongRunningConversation(ConversationI
      nterceptor.java:52)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.jboss.seam.util.Reflections.invoke(Reflections.java:18)
       at org.jboss.seam.intercept.Interceptor.aroundInvoke(Interceptor.java:169)
       at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:64)
       at org.jboss.seam.interceptors.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:27)
      
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.jboss.seam.util.Reflections.invoke(Reflections.java:18)
       at org.jboss.seam.intercept.Interceptor.aroundInvoke(Interceptor.java:169)
       at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:64)
       at org.jboss.seam.intercept.RootInterceptor.createSeamInvocationContext(RootInterceptor.java:144)
       at org.jboss.seam.intercept.RootInterceptor.invokeInContexts(RootInterceptor.java:129)
       at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:102)
       at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:145)
       at org.jboss.seam.intercept.JavaBeanInterceptor.intercept(JavaBeanInterceptor.java:80)
       at com.payvand.search.model.business.Authenticator$$EnhancerByCGLIB$$e48d63d5.authenticate(<generated>
      )
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:132)
       at org.jboss.seam.actionparam.ActionParamBindingHelper.invokeTheExpression(ActionParamBindingHelper.ja
      va:59)
       at org.jboss.seam.actionparam.ActionParamMethodBinding.invoke(ActionParamMethodBinding.java:74)
       at org.jboss.seam.core.Expressions$2.invoke(Expressions.java:102)
       at org.jboss.seam.security.jaas.SeamLoginModule.login(SeamLoginModule.java:102)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at javax.security.auth.login.LoginContext.invoke(LoginContext.java:769)
       at javax.security.auth.login.LoginContext.access$000(LoginContext.java:186)
       at javax.security.auth.login.LoginContext$5.run(LoginContext.java:706)
       at java.security.AccessController.doPrivileged(Native Method)
       at javax.security.auth.login.LoginContext.invokeCreatorPriv(LoginContext.java:703)
       at javax.security.auth.login.LoginContext.login(LoginContext.java:575)
       at org.jboss.seam.security.Identity.authenticate(Identity.java:206)
       at org.jboss.seam.security.Identity.authenticate(Identity.java:199)
       at org.jboss.seam.security.Identity.login(Identity.java:184)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at com.sun.el.parser.AstValue.invoke(AstValue.java:151)
       at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:283)
       at com.sun.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:68)
       at com.sun.facelets.el.LegacyMethodBinding.invoke(LegacyMethodBinding.java:69)
       at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:61)
       at javax.faces.component.UICommand.broadcast(UICommand.java:109)
       at org.ajax4jsf.framework.ajax.AjaxViewRoot.processEvents(AjaxViewRoot.java:180)
       at org.ajax4jsf.framework.ajax.AjaxViewRoot.broadcastEvents(AjaxViewRoot.java:158)
       at org.ajax4jsf.framework.ajax.AjaxViewRoot.processApplication(AjaxViewRoot.java:329)
       at org.apache.myfaces.lifecycle.InvokeApplicationExecutor.execute(InvokeApplicationExecutor.java:32)
       at org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:95)
       at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:70)
       at javax.faces.webapp.FacesServlet.service(FacesServlet.java:139)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.ajax4jsf.framework.ajax.xmlfilter.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:96)
       at org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter.doFilter(BaseFilter.java:220)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:100)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:147)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.jboss.seam.servlet.SeamRedirectFilter.doFilter(SeamRedirectFilter.java:29)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.jboss.seam.servlet.SeamCharacterEncodingFilter.doFilter(SeamCharacterEncodingFilter.java:41)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
       at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
       at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:482)
       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
       at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
       at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
       at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
       at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.ja
      va:744)
       at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
       at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
       at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
       at java.lang.Thread.run(Thread.java:595)
      


      as you see, it seems that select statements are produced correct but the entityManager can not be loaded

      I am using JBoss Seam v1.1.6 GA

      here is my authenticator:

      @Name("authenticator")
      public class Authenticator implements Serializable {
      
       @In
       @PersistenceContext(unitName = "SearchEngineDB")
       private EntityManager entityManager;
      
       @EJB
       private UserDao userDao;
      
       @Out(required = false, scope = SESSION)
       private User user;
      
       @In
       private Identity identity;
       private FacesMessages facesMessages;
      
       public FacesMessages getFacesMessages() {
       return facesMessages;
       }
      
       public void setFacesMessages(FacesMessages facesMessages) {
       this.facesMessages = facesMessages;
       }
      
       public boolean authenticate() {
       try {
       String username = Identity.instance().getUsername();
       String password = Identity.instance().getPassword();
       user = (User)entityManager
       .createQuery("from User where username = :username and password = :password")
       .setParameter("username", username)
       .setParameter("password", password)
       .getSingleResult();
      
       if(user == null) {
       throw new NoResultException("could not match any user with given username '"+username+"' and passowrd!");
       }
       if (user.getRoles() != null) {
       for (UserRole role : user.getRoles()) {
       identity.addRole(role.getRoleName());
       }
       }
       user.setPassword("");
       return true;
       } catch (NoResultException ex) {
       System.out.println("--Authenticator --");
       ex.printStackTrace();
       return false;
       }catch (Exception e) {
       e.printStackTrace();
       return false;
       }
       }
      
       public String logout() {
       identity.logout();
       return "home";
       }
      }
      
      


      another problem is that I can not inject my userDao as an EJB into authenticator.

      thanks

        • 1. Re: problem with Authenticator
          mnrz

          can we inject an ejb component into authenticator using @EJB?

          @EJB
          private UserDao userDao;

          • 2. Re: problem with Authenticator
            fernando_jmt

            AFAIK, you can't use @EJB in POJO components.

            • 3. Re: problem with Authenticator
              mnrz

              ok but why I get IllegalArgumentException: "No transaction" when I call entityManager?

              I also tried to call entityManager.getTransaction().begin and I get new exception "java.lang.IllegalStateException: JTA EntityManager cannot access a transactions"

              • 4. Re: problem with Authenticator
                pmuir

                No transaction normally means that an earlier exception has occurred. Use your debugger to see what goes wrong.

                • 5. Re: problem with Authenticator
                  mnrz

                   

                  "pete.muir@jboss.org" wrote:
                  No transaction normally means that an earlier exception has occurred. Use your debugger to see what goes wrong.


                  I really appreciate your nice comment, you show me the way, as you told, I tried to comment out the code in authenticator and return true for every user then I saw many exceptions :))

                  after resolving problems, I restores the commented codes and now it works fine

                  thank you again too much and sorry for sending email directly