1 2 Previous Next 16 Replies Latest reply on Oct 27, 2012 8:24 PM by jlgranda

    IdentitySession is null

    riboriori

      I have a simple war packaged seam 3 project. I want investigate on security features and in a action
      i inject identitysession like this:


      @Inject IdentitySession identitySession;


      but it's null.
      I've setup all classes in beans.xml like this:



            <security:IdentityImpl>
                      <s:modifies/>
                      <security:authenticatorName>databaseAuthenticator</security:authenticatorName>
              </security:IdentityImpl>
             
              <security:JpaPermissionStore>
            <s:replaces/>     
            <security:identityPermissionClass>com.mycompany.mypackage.myproject.domain.entity.security.IdentityPermission</security:identityPermissionClass>
          </security:JpaPermissionStore>
              
              <plidm:JpaIdentityStoreConfiguration>
            <s:replaces/>     
            <plidm:identityClass>com.mycompany.mypackage.myproject.domain.entity.security.IdentiyObject</plidm:identityClass>     
            <plidm:credentialClass>it.unipa.cuc.myproject.domain.entity.security.IdentiyObjectCredential</plidm:credentialClass>
            <plidm:relationshipClass>com.mycompany.mypackage.myproject.domain.entity.security.IdentityObjectRelationship</plidm:relationshipClass>
            <plidm:roleTypeClass>it.unipa.cuc.myproject.myproject.domain.entity.security.IdentityRoleName</plidm:roleTypeClass>
            <plidm:attributeClass>com.mycompany.mypackage.myproject.domain.entity.security.IdentityObjectAttribute</plidm:attributeClass>
            
         </plidm:JpaIdentityStoreConfiguration>

      What's i wrong?

        • 1. Re: IdentitySession is null
          riboriori

          I dont sure that identitySession is null, but i got a NPE: (report the part of exception taht seems to me relevant):



          Caused by: java.lang.NullPointerException
                  at org.picketlink.idm.impl.api.session.IdentitySessionImpl.<init>(IdentitySessionImpl.java:138) [:1.5.0.Alpha02]


          I use SEAM 3 final, jboss 6 final.


          Anyone?

          • 2. Re: IdentitySession is null
            lightguard

            Try setting things up with seam-beans.xml instead of beans.xml. This is the preferred file for Seam Config

            • 3. Re: IdentitySession is null
              riboriori

              Same result: i put seam-beans.xml under WEB-INF/ but i got always NPE, when i call a method that use identitySession variable.
              What can i do?

              • 4. Re: IdentitySession is null
                shane.bryzak

                seam-beans.xml can't be found in WEB-INF/, as it's not in the classpath.  It has to go in WEB-INF/classes.

                • 5. Re: IdentitySession is null
                  riboriori

                  Tank you Jason and Shane, i've put seam-beans under WEB-INF/classes/META-INF and it works, but now
                  i have another excpetion.
                  Post initial part and final part of the stack tarce:


                  16:37:23,711 GRAVE [javax.enterprise.resource.webcontainer.jsf.application] java.lang.RuntimeException: java.lang.RuntimeException: Could not set field value to class configured in XML: com.mycompany.domain.entity.security.IdentiyObject: javax.faces.el.EvaluationException: java.lang.RuntimeException: java.lang.RuntimeException: Could not set field value to class configured in XML: com.mycompany.domain.entity.security.IdentiyObject
                          at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:98) [:2.0.3-]


                  ...



                  Caused by: java.lang.ClassNotFoundException: com.mycompany.domain.entity.security.IdentiyObject
                          at java.net.URLClassLoader$1.run(URLClassLoader.java:202) [:1.6.0_21]
                          at java.security.AccessController.doPrivileged(Native Method) [:1.6.0_21]
                          at java.net.URLClassLoader.findClass(URLClassLoader.java:190) [:1.6.0_21]
                          at java.lang.ClassLoader.loadClass(ClassLoader.java:307) [:1.6.0_21]
                          at java.lang.ClassLoader.loadClass(ClassLoader.java:248) [:1.6.0_21]
                          at org.jboss.seam.config.xml.util.XmlObjectConverter.convert(XmlObjectConverter.java:54) [:3.0.0.Final]
                          ... 88 more

                  It appear that cant find IdentityObject class, but it is compiled uder WEB-INF/classes.
                  I post seam-beans content:








                  <?xml version="1.0" encoding="UTF-8"?>
                  <beans      xmlns="http://java.sun.com/xml/ns/javaee"
                            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                            xmlns:s="urn:java:ee"
                            xmlns:security="urn:java:org.jboss.seam.security"
                            xmlns:pm="urn:java:org.jboss.seam.security.permission"
                            xmlns:plidm="urn:java:org.jboss.seam.security.management.picketlink" 
                            xsi:schemaLocation="http://java.sun.com/xml/ns/javaee  http://jboss.org/schema/cdi/beans_1_0.xsd">
                       
                       
                       <security:IdentityImpl>
                            <s:modifies/>
                            <security:authenticatorName>databaseAuthenticator</security:authenticatorName>
                       </security:IdentityImpl>
                       <!-- 
                       <security:JpaPermissionStore>
                        <s:replaces/>            
                        <security:identityPermissionClass>com.mycompany.domain.entity.security.IdentityPermission</security:identityPermissionClass>
                      </security:JpaPermissionStore>
                         -->
                       <plidm:JpaIdentityStoreConfiguration>
                       <s:replaces/>   
                        
                        <plidm:identityClass>com.mycompany.domain.entity.security.IdentiyObject</plidm:identityClass>      
                        <plidm:credentialClass>com.mycompany.domain.entity.security.IdentiyObjectCredential</plidm:credentialClass>
                        <plidm:relationshipClass>com.mycompany.domain.entity.security.IdentityObjectRelationship</plidm:relationshipClass>
                        <plidm:roleTypeClass>com.mycompany.domain.entity.security.IdentityRoleName</plidm:roleTypeClass>
                        <plidm:attributeClass>com.mycompany.domain.entity.security.IdentityObjectAttribute</plidm:attributeClass>
                         
                     </plidm:JpaIdentityStoreConfiguration>     
                       
                  </beans>






                  • 6. Re: IdentitySession is null
                    riboriori

                    Sorry for bad format of stack trace, i repost it:






                    Initial part:


                    6:37:23,711 GRAVE [javax.enterprise.resource.webcontainer.jsf.application] java.lang.RuntimeException: java.lang.RuntimeException: Could not set field value to class configured in XML: com.mycompany.domain.entity.security.IdentiyObject: javax.faces.el.EvaluationException: java.lang.RuntimeException: java.lang.RuntimeException: Could not set field value to class configured in XML: com.mycompany.domain.entity.security.IdentiyObject at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:98) [:2.0.3-]
                    




                    Final part:



                    Caused by: java.lang.ClassNotFoundException: com.mycompany.domain.entity.security.IdentiyObject at java.net.URLClassLoader$1.run(URLClassLoader.java:202) [:1.6.0_21] at java.security.AccessController.doPrivileged(Native Method) [:1.6.0_21] at java.net.URLClassLoader.findClass(URLClassLoader.java:190) [:1.6.0_21] at java.lang.ClassLoader.loadClass(ClassLoader.java:307) [:1.6.0_21] at java.lang.ClassLoader.loadClass(ClassLoader.java:248) [:1.6.0_21] at org.jboss.seam.config.xml.util.XmlObjectConverter.convert(XmlObjectConverter.java:54) [:3.0.0.Final] ... 88 more



                    • 7. Re: IdentitySession is null
                      shane.bryzak

                      Looks like a typo, you spelled identity wrong in the configuration.

                      • 8. Re: IdentitySession is null
                        riboriori

                        MEA MAXIMA CULPA.
                        Shane is right. it was a typo. My class is com.mycompany.domain.entity.security.IdentityObject,
                        not com.mycompany.domain.entity.security.IdentiyObject; there was a missing t letter.


                        Tank you Shane and Jason
                        Best regards

                        • 9. Re: IdentitySession is null
                          robertfink

                          hi there, i got the same error.


                          NPE on
                          org.picketlink.idm.impl.api.session.IdentitySessionImpl.<init>(IdentitySessionImpl.java:138) [picketlink-idm-core-1.5.0.Alpha02.jar:]


                          im using seam 3.0.0.Final. the configuration is located in WEB-INF/classes/META-INF/seam-beans.xml and looks like:



                          <beans xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                               xmlns:s="urn:java:ee" xmlns:security="urn:java:org.jboss.seam.security"
                               xmlns:plidm="urn:java:org.jboss.seam.security.management.picketlink"
                               xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://jboss.org/schema/cdi/beans_1_0.xsd">
                          
                               <security:IdentityImpl>
                                    <s:modifies />
                                    <security:authenticatorName>databaseAuthenticator
                                    </security:authenticatorName>
                               </security:IdentityImpl>
                          
                               <plidm:JpaIdentityStoreConfiguration>
                                    <s:replaces />
                                    <plidm:identityClass>org.mycompany.model.IdentityObject
                                    </plidm:identityClass>
                                    <plidm:credentialClass>org.mycompany.model.IdentityObjectCredential
                                    </plidm:credentialClass>
                                    <plidm:relationshipClass>org.mycompany.model.IdentityObjectRelationship
                                    </plidm:relationshipClass>
                                    <plidm:roleTypeClass>org.mycompany.model.IdentityRoleName
                                    </plidm:roleTypeClass>
                                    <plidm:attributeClass>org.mycompany.model.IdentityObjectAttribute
                                    </plidm:attributeClass>
                               </plidm:JpaIdentityStoreConfiguration>
                          
                          </beans>






                          the stack trace looks like...





                          at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:118) [jsf-impl-2.1.3-b02-jbossorg-2.jar:2.1.3-SNAPSHOT]
                               at javax.faces.component.UICommand.broadcast(UICommand.java:315) [jboss-jsf-api_2.1_spec-2.0.0.Beta1.jar:2.0.0.Beta1]
                               at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:794) [jboss-jsf-api_2.1_spec-2.0.0.Beta1.jar:2.0.0.Beta1]
                               at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1259) [jboss-jsf-api_2.1_spec-2.0.0.Beta1.jar:2.0.0.Beta1]
                               at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81) [jsf-impl-2.1.3-b02-jbossorg-2.jar:2.1.3-SNAPSHOT]
                               at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) [jsf-impl-2.1.3-b02-jbossorg-2.jar:2.1.3-SNAPSHOT]
                               at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118) [jsf-impl-2.1.3-b02-jbossorg-2.jar:2.1.3-SNAPSHOT]
                               at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593) [jboss-jsf-api_2.1_spec-2.0.0.Beta1.jar:2.0.0.Beta1]
                               at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329) [jbossweb-7.0.1.Final.jar:7.0.2.Final]
                               at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.1.Final.jar:7.0.2.Final]
                               at org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:67) [weld-core-1.1.2.Final.jar:2011-07-26 15:02]
                               at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.1.Final.jar:7.0.2.Final]
                               at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.1.Final.jar:7.0.2.Final]
                               at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [jbossweb-7.0.1.Final.jar:7.0.2.Final]
                               at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [jbossweb-7.0.1.Final.jar:7.0.2.Final]
                               at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:139) [jboss-as-web-7.0.2.Final.jar:7.0.2.Final]
                               at org.jboss.as.web.NamingValve.invoke(NamingValve.java:57) [jboss-as-web-7.0.2.Final.jar:7.0.2.Final]
                               at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:49) [jboss-as-jpa-7.0.2.Final.jar:7.0.2.Final]
                               at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:154) [jbossweb-7.0.1.Final.jar:7.0.2.Final]
                               at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.1.Final.jar:7.0.2.Final]
                               at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.1.Final.jar:7.0.2.Final]
                               at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:362) [jbossweb-7.0.1.Final.jar:7.0.2.Final]
                               at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [jbossweb-7.0.1.Final.jar:7.0.2.Final]
                               at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:667) [jbossweb-7.0.1.Final.jar:7.0.2.Final]
                               at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:952) [jbossweb-7.0.1.Final.jar:7.0.2.Final]
                               at java.lang.Thread.run(Thread.java:722) [:1.7.0_01]
                          Caused by: javax.faces.el.EvaluationException: java.lang.NullPointerException
                               at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:102) [jboss-jsf-api_2.1_spec-2.0.0.Beta1.jar:2.0.0.Beta1]
                               at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102) [jsf-impl-2.1.3-b02-jbossorg-2.jar:2.1.3-SNAPSHOT]
                               ... 25 more
                          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.7.0_01]
                               at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [:1.7.0_01]
                               at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [:1.7.0_01]
                               at java.lang.reflect.Method.invoke(Method.java:601) [:1.7.0_01]
                               at org.jboss.weld.util.reflection.SecureReflections$13.work(SecureReflections.java:305) [weld-core-1.1.2.Final.jar:2011-07-26 15:02]
                               at org.jboss.weld.util.reflection.SecureReflectionAccess.run(SecureReflectionAccess.java:54) [weld-core-1.1.2.Final.jar:2011-07-26 15:02]
                               at org.jboss.weld.util.reflection.SecureReflectionAccess.runAsInvocation(SecureReflectionAccess.java:163) [weld-core-1.1.2.Final.jar:2011-07-26 15:02]
                               at org.jboss.weld.util.reflection.SecureReflections.invoke(SecureReflections.java:299) [weld-core-1.1.2.Final.jar:2011-07-26 15:02]
                               at org.jboss.weld.introspector.jlr.WeldMethodImpl.invokeOnInstance(WeldMethodImpl.java:188) [weld-core-1.1.2.Final.jar:2011-07-26 15:02]
                               at org.jboss.weld.injection.MethodInjectionPoint.invokeOnInstance(MethodInjectionPoint.java:169) [weld-core-1.1.2.Final.jar:2011-07-26 15:02]
                               at org.jboss.weld.bean.ProducerMethod$1.produce(ProducerMethod.java:149) [weld-core-1.1.2.Final.jar:2011-07-26 15:02]
                               at org.jboss.weld.bean.AbstractProducerBean.create(AbstractProducerBean.java:361) [weld-core-1.1.2.Final.jar:2011-07-26 15:02]
                               at org.jboss.weld.context.AbstractContext.get(AbstractContext.java:122) [weld-core-1.1.2.Final.jar:2011-07-26 15:02]
                               at org.jboss.weld.bean.proxy.ContextBeanInstance.getInstance(ContextBeanInstance.java:99) [weld-core-1.1.2.Final.jar:2011-07-26 15:02]
                               at org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:124) [weld-core-1.1.2.Final.jar:2011-07-26 15:02]
                               at org.jboss.weld.proxies.IdentitySession$-116769523$Proxy$_$$_WeldClientProxy.getPersistenceManager(IdentitySession$-116769523$Proxy$_$$_WeldClientProxy.java) [weld-core-1.1.2.Final.jar:]
                               at at.flimmerkistev2.account.RegistrationHandler.registerUser(RegistrationHandler.java:21) [classes:]
                               at at.flimmerkistev2.account.RegistrationHandler$Proxy$_$$_WeldClientProxy.registerUser(RegistrationHandler$Proxy$_$$_WeldClientProxy.java) [classes:]
                               at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [:1.7.0_01]
                               at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [:1.7.0_01]
                               at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [:1.7.0_01]
                               at java.lang.reflect.Method.invoke(Method.java:601) [:1.7.0_01]
                               at org.apache.el.parser.AstValue.invoke(AstValue.java:196) [jbossweb-7.0.1.Final.jar:7.0.2.Final]
                               at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276) [jbossweb-7.0.1.Final.jar:7.0.2.Final]
                               at org.jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:43) [weld-core-1.1.2.Final.jar:2011-07-26 15:02]
                               at org.jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:56) [weld-core-1.1.2.Final.jar:2011-07-26 15:02]
                               at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105) [jsf-impl-2.1.3-b02-jbossorg-2.jar:2.1.3-SNAPSHOT]
                               at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88) [jboss-jsf-api_2.1_spec-2.0.0.Beta1.jar:2.0.0.Beta1]
                               ... 26 more






                          i hope anybody can help me


                          • 10. Re: IdentitySession is null
                            lightguard

                            Something didn't get setup right, but I can't tell from the stack trace, or looking at the Picketlink code at that line. Would mind trying the 3.1.0.CR1 release? There are many bug fixes and also some ease in configuration. 3.1.0.Final is due this week as well.

                            • 11. Re: IdentitySession is null
                              robertfink

                              with version 3.1.0.CR1, i get the following error:



                              Caused by: org.picketlink.idm.common.exception.IdentityException: Error creating IdentitySession - no PicketLink IdentityStore repositories have been configured.
                                   at org.jboss.seam.security.management.picketlink.IdentitySessionProducer.createIdentitySession(IdentitySessionProducer.java:155) [seam-security-3.1.0.CR1.jar:]
                                   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [:1.7.0_01]
                                   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [:1.7.0_01]
                                   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [:1.7.0_01]
                                   at java.lang.reflect.Method.invoke(Method.java:601) [:1.7.0_01]
                                   at org.jboss.weld.util.reflection.SecureReflections$13.work(SecureReflections.java:305) [weld-core-1.1.2.Final.jar:2011-07-26 15:02]
                                   at org.jboss.weld.util.reflection.SecureReflectionAccess.run(SecureReflectionAccess.java:54) [weld-core-1.1.2.Final.jar:2011-07-26 15:02]
                                   at org.jboss.weld.util.reflection.SecureReflectionAccess.runAsInvocation(SecureReflectionAccess.java:163) [weld-core-1.1.2.Final.jar:2011-07-26 15:02]
                                   at org.jboss.weld.util.reflection.SecureReflections.invoke(SecureReflections.java:299) [weld-core-1.1.2.Final.jar:2011-07-26 15:02]
                                   at org.jboss.weld.introspector.jlr.WeldMethodImpl.invokeOnInstance(WeldMethodImpl.java:188) [weld-core-1.1.2.Final.jar:2011-07-26 15:02]
                                   at org.jboss.weld.injection.MethodInjectionPoint.invokeOnInstance(MethodInjectionPoint.java:169) [weld-core-1.1.2.Final.jar:2011-07-26 15:02]
                                   ... 50 more



                              • 12. Re: IdentitySession is null
                                lightguard

                                Did you change to use the annotation configuration approach? I'd still have to get to the project and debug through it to see what's null, sorry.

                                • 13. Re: IdentitySession is null
                                  aluke

                                  If I am building a simple JSF application using WELD and the I have beans.xml. How do I include Seam-security into the applicstion ?

                                  • 14. Re: IdentitySession is null
                                    blabno

                                    Luke, I think this is question for separate thread. First you need to do is to read Manual. Then add seam-security jars to your WAR and enable SecurityInterceptor in beans.xml or seam-beans.xml.

                                    1 2 Previous Next