13 Replies Latest reply on Mar 26, 2010 1:22 AM by shane lee

    Could not instantiate Seam component: org.jboss.seam.security.ruleBasedPermissionResolver

    Anton L Newbie

      Hello!
      I use Seam 2.1.1 and I want to login:


      import javax.persistence.EntityManager;
      import javax.persistence.NoResultException;
      
      import org.jboss.seam.annotations.In;
      import org.jboss.seam.annotations.Logger;
      import org.jboss.seam.annotations.Name;
      import org.jboss.seam.log.Log;
      import org.jboss.seam.security.Credentials;
      import org.jboss.seam.security.Identity;
      
      import ru.npomit.codoc.entity.CodocUser;
      import ru.npomit.codoc.entity.Role;
      
      @Name("authenticator")
      public class Authenticator {
        @In EntityManager entityManager;
        @In Credentials credentials;
        @In Identity identity;
        public boolean authenticate() {
          try {
            CodocUser user = (CodocUser) entityManager.createQuery(
               "from CodocUser where username = :username and password = :password")
               .setParameter("username", credentials.getUsername())
               .setParameter("password", credentials.getPassword())
               .getSingleResult();
            if (user.getRoles() != null) {
               for (Role role : user.getRoles())
                  identity.addRole(role.getRolename());
            }
            return true;
          }
          catch (NoResultException ex) {
            return false;
          }
        }
      


      My version of components.xml:


      <components
           xmlns="http://jboss.com/products/seam/components"
           xmlns:core="http://jboss.com/products/seam/core"
           xmlns:persistence="http://jboss.com/products/seam/persistence"
           xmlns:security="http://jboss.com/products/seam/security"
           xmlns:identity-management="http://jboss.com/products/seam/security"
           xmlns:permission-management="http://jboss.com/products/seam/security"
           xmlns:transaction="http://jboss.com/products/seam/transaction"
           xmlns:framework="http://jboss.com/products/seam/framework"
           xmlns:drools="http://jboss.com/products/seam/drools"
           xmlns:bpm="http://jboss.com/products/seam/bpm"
           xmlns:mail="http://jboss.com/products/seam/mail"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://jboss.com/products/seam/core http://jboss.com/products/seam/core-2.1.xsd 
                       http://jboss.com/products/seam/persistence http://jboss.com/products/seam/persistence-2.1.xsd 
                       http://jboss.com/products/seam/drools http://jboss.com/products/seam/drools-2.1.xsd
                       http://jboss.com/products/seam/bpm http://jboss.com/products/seam/bpm-2.1.xsd
                       http://jboss.com/products/seam/security http://jboss.com/products/seam/security-2.1.xsd
                       http://jboss.com/products/seam/transaction http://jboss.com/products/seam/transaction-2.1.xsd
                       http://jboss.com/products/seam/mail http://jboss.com/products/seam/mail-2.1.xsd
                       http://jboss.com/products/seam/components http://jboss.com/products/seam/components-2.1.xsd
                       http://jboss.com/products/seam/framework http://jboss.com/products/seam/framework-2.1.xsd">
      
         <core:init debug="true" jndi-pattern="@jndiPattern@"/>
         
           
         <core:manager concurrent-request-timeout="500" 
                       conversation-timeout="120000" 
                       conversation-id-parameter="cid"
                       parent-conversation-id-parameter="pid"/>
          
         <persistence:managed-persistence-context name="entityManager"
                                           auto-create="true"
                            persistence-unit-jndi-name="java:/codocEntityManagerFactory"/>                          
      
           <drools:rule-base name="securityRules">
                  <drools:rule-files>
                <value>/META-INF/security.drl</value>
                 </drools:rule-files>
           </drools:rule-base>
           
           <security:rule-based-permission-resolver security-rules="#{securityRules}"/> 
           
           <security:identity-manager identity-store="#{jpaIdentityStore}" role-identity-store="#{jpaIdentityStore}"/>
                                         
           <security:jpa-identity-store user-class="ru.npomit.codoc.entity.CodocUser" role-class="ru.npomit.codoc.entity.Role"/>
      
         
       <security:identity authenticate-method="#{authenticator.authenticate}" remember-me="true"/> 
      
         <event type="org.jboss.seam.security.notLoggedIn">
            <action execute="#{redirect.captureCurrentView}"/>
         </event>
         <event type="org.jboss.seam.security.loginSuccessful">
            <action execute="#{redirect.returnToCapturedView}"/>
         </event>
         
         <mail:mail-session host="localhost" port="2525" username="test" password="test" />
              
         <!-- For use with jBPM pageflow or process management -->
         <!--  
         <bpm:jbpm>
            <bpm:process-definitions></bpm:process-definitions>
            <bpm:pageflow-definitions></bpm:pageflow-definitions>
         </bpm:jbpm>
         -->
            
      </components>
      



      Stacktrace:


      16:26:04,669 INFO  [Contexts] starting up: org.jboss.seam.security.identity
      16:26:04,673 INFO  [Contexts] starting up: org.jboss.seam.security.ruleBasedPermissionResolver
      16:26:04,873 ERROR [[/codoc]] Session event listener threw exception
      org.jboss.seam.InstantiationException: Could not instantiate Seam component: org.jboss.seam.security.ruleBasedPermissionResolver
           at org.jboss.seam.Component.newInstance(Component.java:2066)
           at org.jboss.seam.contexts.Contexts.startup(Contexts.java:304)
           at org.jboss.seam.contexts.Contexts.startup(Contexts.java:278)
           at org.jboss.seam.contexts.Lifecycle.beginSession(Lifecycle.java:191)
           at org.jboss.seam.contexts.ServletLifecycle.beginSession(ServletLifecycle.java:141)
           at org.jboss.seam.servlet.SeamListener.sessionCreated(SeamListener.java:44)
           at org.apache.catalina.session.StandardSession.tellNew(StandardSession.java:397)
           at org.apache.catalina.session.StandardSession.setId(StandardSession.java:369)
           at org.apache.catalina.session.ManagerBase.createSession(ManagerBase.java:828)
           at org.apache.catalina.session.StandardManager.createSession(StandardManager.java:291)
           at org.apache.catalina.connector.Request.doGetSession(Request.java:2310)
           at org.apache.catalina.connector.Request.getSession(Request.java:2075)
           at org.apache.catalina.connector.RequestFacade.getSession(RequestFacade.java:833)
           at org.apache.catalina.connector.RequestFacade.getSession(RequestFacade.java:844)
           at org.jboss.seam.web.IdentityRequestWrapper.<init>(IdentityRequestWrapper.java:21)
           at org.jboss.seam.web.IdentityFilter.doFilter(IdentityFilter.java:38)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:90)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:177)
           at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:267)
           at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:380)
           at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:507)
           at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:56)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:58)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:51)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
           at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
           at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
           at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
           at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:182)
           at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
           at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
           at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
           at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
           at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
           at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
           at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
           at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
           at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
           at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
           at java.lang.Thread.run(Thread.java:619)
      Caused by: org.jboss.seam.InstantiationException: Could not instantiate Seam component: securityRules
           at org.jboss.seam.Component.newInstance(Component.java:2066)
           at org.jboss.seam.Component.getInstance(Component.java:1948)
           at org.jboss.seam.Component.getInstance(Component.java:1910)
           at org.jboss.seam.Component.getInstance(Component.java:1904)
           at org.jboss.seam.Namespace.getComponentInstance(Namespace.java:55)
           at org.jboss.seam.Namespace.getComponentInstance(Namespace.java:50)
           at org.jboss.seam.el.SeamELResolver.resolveBase(SeamELResolver.java:166)
           at org.jboss.seam.el.SeamELResolver.getValue(SeamELResolver.java:53)
           at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:53)
           at org.jboss.el.parser.AstIdentifier.getValue(AstIdentifier.java:44)
           at org.jboss.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
           at org.jboss.seam.core.Expressions$1.getValue(Expressions.java:112)
           at org.jboss.seam.Component$ELInitialValue.getValue(Component.java:2461)
           at org.jboss.seam.Component.initialize(Component.java:1454)
           at org.jboss.seam.Component.postConstructJavaBean(Component.java:1380)
           at org.jboss.seam.Component.postConstruct(Component.java:1303)
           at org.jboss.seam.Component.newInstance(Component.java:2051)
           ... 52 more
      Caused by: java.lang.RuntimeException: exception invoking: compileRuleBase
           at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:148)
           at org.jboss.seam.Component.callComponentMethod(Component.java:2171)
           at org.jboss.seam.Component.callCreateMethod(Component.java:2094)
           at org.jboss.seam.Component.newInstance(Component.java:2054)
           ... 68 more
      Caused by: java.lang.reflect.InvocationTargetException
           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:597)
           at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
           at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:138)
           ... 71 more
      Caused by: java.lang.NoClassDefFoundError: org/mvel/integration/impl/LocalVariableResolverFactory
           at java.lang.ClassLoader.defineClass1(Native Method)
           at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
           at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
           at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
           at java.net.URLClassLoader.access$000(URLClassLoader.java:56)
           at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
           at java.security.AccessController.doPrivileged(Native Method)
           at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
           at org.jboss.mx.loading.RepositoryClassLoader.findClassLocally(RepositoryClassLoader.java:690)
           at org.jboss.mx.loading.RepositoryClassLoader.findClass(RepositoryClassLoader.java:670)
           at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
           at org.jboss.mx.loading.RepositoryClassLoader.loadClassLocally(RepositoryClassLoader.java:200)
           at org.jboss.mx.loading.ClassLoadingTask$ThreadTask.run(ClassLoadingTask.java:131)
           at org.jboss.mx.loading.LoadMgr3.nextTask(LoadMgr3.java:399)
           at org.jboss.mx.loading.RepositoryClassLoader.loadClassImpl(RepositoryClassLoader.java:527)
           at org.jboss.mx.loading.RepositoryClassLoader.loadClass(RepositoryClassLoader.java:415)
           at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
           at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
           at org.drools.rule.builder.dialect.java.JavaDialect.<init>(JavaDialect.java:73)
           at org.drools.rule.builder.dialect.java.JavaDialectConfiguration.getDialect(JavaDialectConfiguration.java:64)
           at org.drools.compiler.PackageBuilderConfiguration.buildDialectRegistry(PackageBuilderConfiguration.java:166)
           at org.drools.compiler.PackageBuilder.<init>(PackageBuilder.java:142)
           at org.drools.compiler.PackageBuilder.<init>(PackageBuilder.java:108)
           at org.jboss.seam.drools.RuleBase.compileRuleBase(RuleBase.java:41)
           ... 77 more
      Caused by: java.lang.ClassNotFoundException: No ClassLoaders found for: org.mvel.integration.impl.LocalVariableResolverFactory
           at org.jboss.mx.loading.LoadMgr3.beginLoadTask(LoadMgr3.java:212)
           at org.jboss.mx.loading.RepositoryClassLoader.loadClassImpl(RepositoryClassLoader.java:521)
           at org.jboss.mx.loading.RepositoryClassLoader.loadClass(RepositoryClassLoader.java:415)
           at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
           at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
           ... 101 more