5 Replies Latest reply on Aug 11, 2011 1:18 PM by Jason Porter

    NullpointerException in Seam 3 Security

    Emeric Kwemou Newbie
      In org.picketlink.idm.impl.api.session.IdentitySessionImpl line 138
      IdentityStoreSession storeSession = repository.createIdentityStoreSession(sessionOptions);
      repository is null.

      ------------------------------------------------------
      I have created a Singleton TUserAction that is used to create update users and roles.
      the whole is based on a JpaIdentityStoreConfiguration, as showed in the idm example (in fact i have copied the idm example).
      beans.xml is configured.

      The singleton is called in another Singleton bean at @Startup (jboss start).
      Please does somebody knows what is wrong here.
      Thank you in advance
      Emeric
        • 1. Re: NullpointerException in Seam 3 Security
          Shane Bryzak Master

          Could you please post the full stack trace?  There should be a more detailed exception.

          • 2. Re: NullpointerException in Seam 3 Security
            Vladimir Seprak Newbie

            Hello,


            I'm expiriencing same problem (NPE on repository). I'm using seam 3. On JBoss6 it worked fine, but when I mooved to JBoss7 I'm getting following exception:





            14:11:49,140 ERROR [org.jboss.seam.security.IdentityImpl] (http--127.0.0.1-8080-2) Login failed: java.lang.RuntimeException: java.lang.NullPointerException
                 at org.jboss.seam.security.IdentityImpl.authenticate(IdentityImpl.java:329) [seam-security-3.0.0.Final.jar:]
                 at org.jboss.seam.security.IdentityImpl.login(IdentityImpl.java:229) [seam-security-3.0.0.Final.jar:]
                 at org.jboss.seam.security.IdentityImpl$Proxy$_$$_WeldClientProxy.login(IdentityImpl$Proxy$_$$_WeldClientProxy.java) [seam-security-3.0.0.Final.jar:]
                 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [:1.6.0_16]
                 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [:1.6.0_16]
                 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [:1.6.0_16]
                 at java.lang.reflect.Method.invoke(Method.java:597) [:1.6.0_16]
                 at org.apache.el.parser.AstValue.invoke(AstValue.java:196) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]
                 at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]
                 at org.jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:43) [weld-core-1.1.2.AS7.jar:2011-07-06 12:26]
                 at org.jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:56) [weld-core-1.1.2.AS7.jar:2011-07-06 12:26]
                 at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105) [jsf-impl-2.0.4-b09-jbossorg-4.jar:2.0.4-b09-jbossorg-4]
                 at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88) [jboss-jsf-api_2.0_spec-1.0.0.Final.jar:1.0.0.Final]
                 at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102) [jsf-impl-2.0.4-b09-jbossorg-4.jar:2.0.4-b09-jbossorg-4]
                 at javax.faces.component.UICommand.broadcast(UICommand.java:315) [jboss-jsf-api_2.0_spec-1.0.0.Final.jar:1.0.0.Final]
                 at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:787) [jboss-jsf-api_2.0_spec-1.0.0.Final.jar:1.0.0.Final]
                 at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1252) [jboss-jsf-api_2.0_spec-1.0.0.Final.jar:1.0.0.Final]
                 at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81) [jsf-impl-2.0.4-b09-jbossorg-4.jar:2.0.4-b09-jbossorg-4]
                 at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) [jsf-impl-2.0.4-b09-jbossorg-4.jar:2.0.4-b09-jbossorg-4]
                 at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118) [jsf-impl-2.0.4-b09-jbossorg-4.jar:2.0.4-b09-jbossorg-4]
                 at javax.faces.webapp.FacesServlet.service(FacesServlet.java:312) [jboss-jsf-api_2.0_spec-1.0.0.Final.jar:1.0.0.Final]
                 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]
                 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]
                 at org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:67) [weld-core-1.1.2.AS7.jar:2011-07-06 12:26]
                 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]
                 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]
                 at com.ocpsoft.pretty.PrettyFilter.doFilter(PrettyFilter.java:118) [prettyfaces-jsf2-3.2.1.jar:]
                 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]
                 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]
                 at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]
                 at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]
                 at org.jboss.as.web.NamingValve.invoke(NamingValve.java:57) [jboss-as-web-7.0.0.Final.jar:7.0.0.Final]
                 at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:49) [jboss-as-jpa-7.0.0.Final.jar:7.0.0.Final]
                 at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:154) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]
                 at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]
                 at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]
                 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:362) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]
                 at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]
                 at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:667) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]
                 at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:951) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]
                 at java.lang.Thread.run(Thread.java:619) [:1.6.0_16]
            Caused by: java.lang.NullPointerException
                 at org.picketlink.idm.impl.api.session.IdentitySessionImpl.<init>(IdentitySessionImpl.java:138) [picketlink-idm-core-1.5.0.Alpha02.jar:]
                 at org.picketlink.idm.impl.api.IdentitySessionFactoryImpl.createIdentitySession(IdentitySessionFactoryImpl.java:114) [picketlink-idm-core-1.5.0.Alpha02.jar:]
                 at org.jboss.seam.security.management.picketlink.IdentitySessionProducer.createIdentitySession(IdentitySessionProducer.java:136) [seam-security-3.0.0.Final.jar:]
                 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [:1.6.0_16]
                 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [:1.6.0_16]
                 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [:1.6.0_16]
                 at java.lang.reflect.Method.invoke(Method.java:597) [:1.6.0_16]
                 at org.jboss.weld.util.reflection.SecureReflections$13.work(SecureReflections.java:305) [weld-core-1.1.2.AS7.jar:2011-07-06 12:26]
                 at org.jboss.weld.util.reflection.SecureReflectionAccess.run(SecureReflectionAccess.java:54) [weld-core-1.1.2.AS7.jar:2011-07-06 12:26]
                 at org.jboss.weld.util.reflection.SecureReflectionAccess.runAsInvocation(SecureReflectionAccess.java:163) [weld-core-1.1.2.AS7.jar:2011-07-06 12:26]
                 at org.jboss.weld.util.reflection.SecureReflections.invoke(SecureReflections.java:299) [weld-core-1.1.2.AS7.jar:2011-07-06 12:26]
                 at org.jboss.weld.introspector.jlr.WeldMethodImpl.invokeOnInstance(WeldMethodImpl.java:188) [weld-core-1.1.2.AS7.jar:2011-07-06 12:26]
                 at org.jboss.weld.injection.MethodInjectionPoint.invokeOnInstance(MethodInjectionPoint.java:169) [weld-core-1.1.2.AS7.jar:2011-07-06 12:26]
                 at org.jboss.weld.bean.ProducerMethod$1.produce(ProducerMethod.java:149) [weld-core-1.1.2.AS7.jar:2011-07-06 12:26]
                 at org.jboss.weld.bean.AbstractProducerBean.create(AbstractProducerBean.java:361) [weld-core-1.1.2.AS7.jar:2011-07-06 12:26]
                 at org.jboss.weld.context.AbstractContext.get(AbstractContext.java:122) [weld-core-1.1.2.AS7.jar:2011-07-06 12:26]
                 at org.jboss.weld.bean.proxy.ContextBeanInstance.getInstance(ContextBeanInstance.java:99) [weld-core-1.1.2.AS7.jar:2011-07-06 12:26]
                 at org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:124) [weld-core-1.1.2.AS7.jar:2011-07-06 12:26]
                 at org.jboss.weld.proxies.IdentitySession$-116769523$Proxy$_$$_WeldClientProxy.getAttributesManager(IdentitySession$-116769523$Proxy$_$$_WeldClientProxy.java) [weld-core-1.1.2.AS7.jar:]
                 at org.jboss.seam.security.management.IdmAuthenticator.authenticate(IdmAuthenticator.java:44) [seam-security-3.0.0.Final.jar:]
                 at org.jboss.seam.security.management.IdmAuthenticator$Proxy$_$$_WeldClientProxy.authenticate(IdmAuthenticator$Proxy$_$$_WeldClientProxy.java) [seam-security-3.0.0.Final.jar:]
                 at org.jboss.seam.security.IdentityImpl.authenticate(IdentityImpl.java:305) [seam-security-3.0.0.Final.jar:]
                 ... 40 more
            
            



            And the code. identity and security are beans from seam-security 3...


            <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
            <html xmlns="http://www.w3.org/1999/xhtml"
                 xmlns:h="http://java.sun.com/jsf/html"
                 xmlns:f="http://java.sun.com/jsf/core"
                 xmlns:ui="http://java.sun.com/jsf/facelets">
            
            <h:head></h:head>
            <h:body>
                 <h:outputStylesheet library="css" name="style.css" />
                 <h:form id="login_form">
                      <h:panelGrid id="panel" columns="2" styleClass="panel_greed">
                           <h:outputText value="#{msgs.input_passphrase}" />
                           <h:inputSecret id="name" value="#{credentials.username}" />
                           <f:facet name="footer" styleClass="panel_greed_footer">
                                <h:commandButton id="link" value="#{msgs.submit}" action="#{identity.login}" styleClass="command_button"/>
                           </f:facet>
                      </h:panelGrid>
                 </h:form>
            </h:body>
            </html>
            
            



            • 3. Re: NullpointerException in Seam 3 Security
              Vladimir Seprak Newbie

              When I added ceam-config-xml jar to my project I'm getting




              14:50:33,609 ERROR [org.jboss.seam.security.IdentityImpl] (http--127.0.0.1-8080-1) Login failed: java.lang.RuntimeException: org.jboss.weld.exceptions.UnsatisfiedResolutionException: WELD-001308 Unable to resolve any beans for Types: [class com.company.survey.security.auth.SurveyAuthenticator]; Bindings: [@javax.enterprise.inject.Any()]
                   at org.jboss.seam.security.IdentityImpl.authenticate(IdentityImpl.java:329) [seam-security-3.0.0.Final.jar:]
                   at org.jboss.seam.security.IdentityImpl.login(IdentityImpl.java:229) [seam-security-3.0.0.Final.jar:]
                   at org.jboss.seam.security.IdentityImpl$Proxy$_$$_WeldClientProxy.login(IdentityImpl$Proxy$_$$_WeldClientProxy.java) [seam-security-3.0.0.Final.jar:]
                   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [:1.6.0_16]
                   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [:1.6.0_16]
                   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [:1.6.0_16]
                   at java.lang.reflect.Method.invoke(Method.java:597) [:1.6.0_16]
                   at org.apache.el.parser.AstValue.invoke(AstValue.java:196) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]
                   at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]
                   at org.jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:43) [weld-core-1.1.2.AS7.jar:2011-07-06 12:26]
                   at org.jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:56) [weld-core-1.1.2.AS7.jar:2011-07-06 12:26]
                   at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105) [jsf-impl-2.0.4-b09-jbossorg-4.jar:2.0.4-b09-jbossorg-4]
                   at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88) [jboss-jsf-api_2.0_spec-1.0.0.Final.jar:1.0.0.Final]
                   at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102) [jsf-impl-2.0.4-b09-jbossorg-4.jar:2.0.4-b09-jbossorg-4]
                   at javax.faces.component.UICommand.broadcast(UICommand.java:315) [jboss-jsf-api_2.0_spec-1.0.0.Final.jar:1.0.0.Final]
                   at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:787) [jboss-jsf-api_2.0_spec-1.0.0.Final.jar:1.0.0.Final]
                   at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1252) [jboss-jsf-api_2.0_spec-1.0.0.Final.jar:1.0.0.Final]
                   at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81) [jsf-impl-2.0.4-b09-jbossorg-4.jar:2.0.4-b09-jbossorg-4]
                   at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) [jsf-impl-2.0.4-b09-jbossorg-4.jar:2.0.4-b09-jbossorg-4]
                   at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118) [jsf-impl-2.0.4-b09-jbossorg-4.jar:2.0.4-b09-jbossorg-4]
                   at javax.faces.webapp.FacesServlet.service(FacesServlet.java:312) [jboss-jsf-api_2.0_spec-1.0.0.Final.jar:1.0.0.Final]
                   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]
                   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]
                   at org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:67) [weld-core-1.1.2.AS7.jar:2011-07-06 12:26]
                   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]
                   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]
                   at com.ocpsoft.pretty.PrettyFilter.doFilter(PrettyFilter.java:118) [prettyfaces-jsf2-3.2.1.jar:]
                   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]
                   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]
                   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]
                   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]
                   at org.jboss.as.web.NamingValve.invoke(NamingValve.java:57) [jboss-as-web-7.0.0.Final.jar:7.0.0.Final]
                   at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:49) [jboss-as-jpa-7.0.0.Final.jar:7.0.0.Final]
                   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:154) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]
                   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]
                   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]
                   at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:362) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]
                   at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]
                   at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:667) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]
                   at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:951) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]
                   at java.lang.Thread.run(Thread.java:619) [:1.6.0_16]
              Caused by: org.jboss.weld.exceptions.UnsatisfiedResolutionException: WELD-001308 Unable to resolve any beans for Types: [class com.company.survey.security.auth.SurveyAuthenticator]; Bindings: [@javax.enterprise.inject.Any()]
                   at org.jboss.weld.manager.BeanManagerImpl.getBean(BeanManagerImpl.java:812) [weld-core-1.1.2.AS7.jar:2011-07-06 12:26]
                   at org.jboss.weld.bean.builtin.InstanceImpl.get(InstanceImpl.java:108) [weld-core-1.1.2.AS7.jar:2011-07-06 12:26]
                   at org.jboss.seam.security.IdentityImpl.lookupAuthenticator(IdentityImpl.java:429) [seam-security-3.0.0.Final.jar:]
                   at org.jboss.seam.security.IdentityImpl.authenticate(IdentityImpl.java:297) [seam-security-3.0.0.Final.jar:]
                   ... 40 more
              
              



              my beans.xml




              <beans xmlns="http://java.sun.com/xml/ns/javaee"
                 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                 xmlns:s="urn:java:ee" 
                 xmlns:plidm="urn:java:org.jboss.seam.security.management.picketlink"
                 xmlns:security="urn:java:org.jboss.seam.security"
                 xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://jboss.org/schema/cdi/beans_1_0.xsd">
              
                 <security:IdentityImpl>
                    <s:modifies/>      
                    <security:authenticatorClass>com.company.survey.security.auth.SurveyAuthenticator</security:authenticatorClass>
                 </security:IdentityImpl>
              </beans>
              



              and




              package com.company.survey.security.auth;
              
              import javax.inject.Inject;
              
              import org.jboss.seam.security.Authenticator;
              import org.jboss.seam.security.BaseAuthenticator;
              import org.jboss.seam.security.Credentials;
              import org.picketlink.idm.api.IdentitySession;
              import org.picketlink.idm.impl.api.model.SimpleUser;
              
              public class SurveyAuthenticator extends BaseAuthenticator implements Authenticator {
              
                 @Inject Credentials credentials;
                 
                 @Inject IdentitySession identitySession;
              
                 @Override
                 public void authenticate() {
                    if ("demo".equals(credentials.getUsername())|| "demo2".equals(credentials.getUsername()))  {
                       setStatus(AuthenticationStatus.SUCCESS);
                       setUser(new SimpleUser(credentials.getUsername()));         
                    }
                 }
              
              }







              • 4. Re: NullpointerException in Seam 3 Security
                Vladimir Seprak Newbie

                I have found the problem. My benas.xml was in wrong place (WEB-INF/classes/META-INF). When i mooved it to WEB-INF it started working. This was confusing because it worked fine on AS6..

                • 5. Re: NullpointerException in Seam 3 Security
                  Jason Porter Master

                  Bug in AS6, that isn't actually a valid location for the beans.xml