2 Replies Latest reply: Nov 22, 2011 5:53 AM by Thomas Raab RSS

How to implement a custom identity model for JBoss Portal?

Thomas Raab Newbie

Hello!

 

I want to implement a custom identity model in order to connect to a proprietary webservice providing user information.

So I followed the instructions on http://docs.jboss.com/jbportal/v2.7.1/referenceGuide/html/identity.html.

 

I am using JBoss Portal 2.7.2 with JBoss AS 4.2.3; java version 1.6.0_29

 

Here are the steps that I've done:

 

Creating a new maven project, pom.xml snippet:

<dependency>
     <groupId>org.jboss.portal.identity</groupId>
     <artifactId>identity-identity</artifactId>
     <version>1.0.7</version>
     <scope>provided</scope>
</dependency>

 

 

Implementation of the User interface:

 

 

package com.mycompany.myIdentity;

import org.jboss.portal.identity.IdentityException;
import org.jboss.portal.identity.User;

public class MyUserImpl implements User {
...
}

 

 

Packaged to a jar file and deployed (= copied) to

\jboss-portal-2.7.2\server\default\deploy\jboss-portal.sar\lib.

 

Changes in \jboss-portal-2.7.2\server\default\deploy\jboss-portal.sar\conf\identity\identity-config.xml,

replacing the existing User-type module with the new one (it doesn't need any config):

 

<module>
     <type>User</type>

     <service-name>portal:service=Module,type=User</service-name>
     <class>com.mycompany.myIdentity.MyUserImpl</class>

     <config/>
</module>

 

 

After starting the server by double-clicking the run.bat und browsing the site http://localhost:8080/portal

I get the following exception:

 

 

exception

 

javax.servlet.ServletException: org.hibernate.HibernateException: Unable to locate current JTA transaction

     org.jboss.portal.server.servlet.PortalServlet.service(PortalServlet.java:278)

     javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

     org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)

 

root cause

 

org.hibernate.HibernateException: Unable to locate current JTA transaction

     org.hibernate.context.JTASessionContext.currentSession(JTASessionContext.java:61)

     org.hibernate.impl.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:544)

     org.jboss.portal.core.impl.model.portal.PersistentPortalObjectContainer.getObjectNode(PersistentPortalObjectContainer.java:252)

     org.jboss.portal.core.impl.model.portal.AbstractPortalObjectContainer.getContext(AbstractPortalObjectContainer.java:112)

     org.jboss.portal.core.impl.model.portal.AbstractPortalObjectContainer.getContext(AbstractPortalObjectContainer.java:81)

     org.jboss.portal.core.model.portal.DefaultPortalCommandFactory.doMapping(DefaultPortalCommandFactory.java:72)

     org.jboss.portal.core.controller.Controller.handle(Controller.java:252)

     org.jboss.portal.server.RequestControllerDispatcher.invoke(RequestControllerDispatcher.java:51)

     org.jboss.portal.common.invocation.Invocation.invokeNext(Invocation.java:131)

     org.jboss.portal.common.invocation.Invocation.invoke(Invocation.java:157)

     org.jboss.portal.server.servlet.PortalServlet.service(PortalServlet.java:252)

     javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

     org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)

 

 

I get the same exception even without deploying the jar file, just by changing the identity-config.xml file. So I assume

that my jar isn't loaded at all. Furthermore my new module has nothing to do with databases and thus needs no JTA transaction.

 

So what am I missing to get this thing working?

 

Thanks in advance for your help.

  • 1. Re: How to implement a custom identity model for JBoss Portal?
    Thomas Raab Newbie

    Hello again!

     

    I was able to make a little progress by carefully examining the server log files. The server could not parse

    the xml file identity-config.xml, so after some experimenting I could make it parse this new file:

     

    <identity-configuration>
       <datasources/>
       <modules>
          <module>
             <type>User</type>
             <implementation>CUSTOM</implementation>
             <config/>
          </module>
          <module>
             <type>Role</type>
             <implementation>CUSTOM</implementation>
             <config/>
          </module>
          <module>
             <type>Membership</type>
             <implementation>CUSTOM</implementation>
             <config/>
          </module>
          <module>
             <type>UserProfile</type>
             <implementation>CUSTOM</implementation>
             <config/>
          </module>
       </modules>
       <options/>
    </identity-configuration>
    

     

    I had to add the following code to the \jboss-portal-2.7.2\server\default\deploy\jboss-portal.sar\conf\identity\standardidentity-config.xml

     

    <module>
        <type>User</type>
        <implementation>CUSTOM</implementation>
    
        <service-name>portal:service=Module,type=User</service-name>
        <class>com.myCompany.MyUser</class>
    
        <config />
    </module>
    <module>
        <type>Role</type>
        <implementation>CUSTOM</implementation>
    
        <service-name>portal:service=Module,type=Role</service-name>
        <class>com.myCompany.MyRole</class>
    
        <config />
    </module>
        <module>
        <type>Membership</type>
        <implementation>CUSTOM</implementation>
    
        <service-name>portal:service=Module,type=Membership</service-name>
        <class>com.myCompany.MyMembership</class>
    
        <config />
    </module>
    <module>
        <type>UserProfile</type>
        <implementation>CUSTOM</implementation>
    
        <service-name>portal:service=Module,type=UserProfile</service-name>
        <class>com.myCompany.MyUserProfile</class>
    
        <config />
    </module>
    

     

    As you can see I also implemented Role, Membership and UserProfile.

    After that, the server complained about some missing properties it needed in those classes. So I added the following

    to each of those four classes:

     

    IdentityContext identityContext;
    ServiceJNDIBinder jndiBinder;
    String moduleType;
    
    public String getModuleType() {
        return moduleType;
    }
    
    public void setModuleType(String moduleType) {
        this.moduleType = moduleType;
    }
    
    public ServiceJNDIBinder getJndiBinder() {
        return jndiBinder;
    }
    
    public void setJndiBinder(ServiceJNDIBinder jndiBinder) {
        this.jndiBinder = jndiBinder;
    }
    
    public IdentityContext getIdentityContext() {
        return identityContext;
    }
    
    public void setIdentityContext(IdentityContext identityContext) {
        this.identityContext = identityContext;
    }
    

     

    Unfortunately the server is still not content with this. I now find the following exception in my server log and

    I have no idea how to solve this:

     

     

    2011-11-21 08:55:54,696 ERROR Cannot start object

    org.jboss.portal.portlet.container.PortletInitializationException: The portlet CMSAdminPortlet threw a portlet exception during init

        at org.jboss.portal.portlet.impl.jsr168.PortletContainerImpl.start(PortletContainerImpl.java:284)

        at org.jboss.portal.portlet.impl.container.PortletContainerLifeCycle.invokeStart(PortletContainerLifeCycle.java:76)

        at org.jboss.portal.portlet.impl.container.LifeCycle.managedStart(LifeCycle.java:92)

        at org.jboss.portal.portlet.impl.container.PortletFilterLifeCycle.startDependents(PortletFilterLifeCycle.java:74)

        at org.jboss.portal.portlet.impl.container.LifeCycle.managedStart(LifeCycle.java:128)

        at org.jboss.portal.portlet.impl.container.PortletApplicationLifeCycle.startDependents(PortletApplicationLifeCycle.java:339)

        at org.jboss.portal.portlet.impl.container.LifeCycle.managedStart(LifeCycle.java:128)

        at org.jboss.portal.portlet.deployment.jboss.PortletAppDeployment.start(PortletAppDeployment.java:226)

        at org.jboss.portal.core.deployment.jboss.PortletAppDeployment.start(PortletAppDeployment.java:94)

        at org.jboss.portal.server.deployment.jboss.DeploymentContext.start(DeploymentContext.java:99)

        at org.jboss.portal.server.deployment.jboss.PortalDeploymentInfoContext.add(PortalDeploymentInfoContext.java:86)

        at org.jboss.portal.server.deployment.jboss.ServerDeployer.registerFactory(ServerDeployer.java:134)

        at org.jboss.portal.server.deployment.jboss.AbstractDeploymentFactory.registerFactory(AbstractDeploymentFactory.java:113)

        at org.jboss.portal.server.deployment.jboss.AbstractDeploymentFactory.start(AbstractDeploymentFactory.java:152)

        at org.jboss.portal.portlet.deployment.jboss.PortletAppDeploymentFactory.start(PortletAppDeploymentFactory.java:147)

        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.portal.jems.as.system.JBossServiceModelMBean$ServiceMixin.execute(JBossServiceModelMBean.java:486)

        at org.jboss.portal.jems.as.system.JBossServiceModelMBean$ServiceMixin.startService(JBossServiceModelMBean.java:452)

        at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289)

        at org.jboss.system.ServiceMBeanSupport.start(ServiceMBeanSupport.java:196)

        at org.jboss.portal.jems.as.system.JBossServiceModelMBean$6.invoke(JBossServiceModelMBean.java:374)

        at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)

        at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)

        at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)

        at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)

        at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)

        at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)

        at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)

        at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:995)

        at $Proxy0.start(Unknown Source)

        at org.jboss.system.ServiceController.start(ServiceController.java:417)

        at org.jboss.system.ServiceController.start(ServiceController.java:435)

        at org.jboss.system.ServiceController.start(ServiceController.java:435)

        at org.jboss.system.ServiceController.start(ServiceController.java:435)

        at org.jboss.system.ServiceController.start(ServiceController.java:435)

        at org.jboss.system.ServiceController.start(ServiceController.java:435)

        at org.jboss.system.ServiceController.start(ServiceController.java:435)

        at org.jboss.system.ServiceController.start(ServiceController.java:435)

        at org.jboss.system.ServiceController.start(ServiceController.java:435)

        at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)

        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

        at java.lang.reflect.Method.invoke(Method.java:597)

        at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)

        at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)

        at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)

        at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)

        at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)

        at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)

        at $Proxy4.start(Unknown Source)

        at org.jboss.deployment.SARDeployer.start(SARDeployer.java:304)

        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.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)

        at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)

        at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)

        at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)

        at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)

        at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)

        at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)

        at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)

        at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)

        at $Proxy199.start(Unknown Source)

        at org.jboss.deployment.XSLSubDeployer.start(XSLSubDeployer.java:197)

        at org.jboss.deployment.MainDeployer.start(MainDeployer.java:1025)

        at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:819)

        at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:782)

        at sun.reflect.GeneratedMethodAccessor26.invoke(Unknown Source)

        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

        at java.lang.reflect.Method.invoke(Method.java:597)

        at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)

        at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)

        at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)

        at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)

        at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)

        at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)

        at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)

        at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)

        at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)

        at $Proxy9.deploy(Unknown Source)

        at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:421)

        at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:634)

        at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:263)

        at org.jboss.deployment.scanner.AbstractDeploymentScanner.startService(AbstractDeploymentScanner.java:336)

        at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289)

        at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:245)

        at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)

        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

        at java.lang.reflect.Method.invoke(Method.java:597)

        at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)

        at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)

        at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)

        at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)

        at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)

        at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:978)

        at $Proxy0.start(Unknown Source)

        at org.jboss.system.ServiceController.start(ServiceController.java:417)

        at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)

        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

        at java.lang.reflect.Method.invoke(Method.java:597)

        at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)

        at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)

        at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)

        at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)

        at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)

        at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)

        at $Proxy4.start(Unknown Source)

        at org.jboss.deployment.SARDeployer.start(SARDeployer.java:304)

        at org.jboss.deployment.MainDeployer.start(MainDeployer.java:1025)

        at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:819)

        at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:782)

        at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:766)

        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.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)

        at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)

        at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)

        at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)

        at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)

        at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)

        at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)

        at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)

        at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)

        at $Proxy5.deploy(Unknown Source)

        at org.jboss.system.server.ServerImpl.doStart(ServerImpl.java:482)

        at org.jboss.system.server.ServerImpl.start(ServerImpl.java:362)

        at org.jboss.Main.boot(Main.java:200)

        at org.jboss.Main$1.run(Main.java:508)

        at java.lang.Thread.run(Thread.java:662)

    Caused by: javax.portlet.PortletException: Authorization Service not found

        at org.jboss.portal.core.cms.ui.admin.CMSAdminPortlet.init(CMSAdminPortlet.java:140)

        at org.jboss.portlet.JBossPortlet.init(JBossPortlet.java:387)

        at org.jboss.portal.core.cms.ui.admin.CMSAdminPortlet.init(CMSAdminPortlet.java:151)

        at org.jboss.portal.portlet.impl.jsr168.PortletContainerImpl.initPortlet(PortletContainerImpl.java:417)

        at org.jboss.portal.portlet.impl.jsr168.PortletContainerImpl.start(PortletContainerImpl.java:256)

        ... 134 more

     

     

    and

     

     

    2011-11-21 08:55:54,977 ERROR Incomplete Deployment listing:

     

    --- MBeans waiting for other MBeans ---

    ObjectName: portal:service=Module,type=IdentityServiceController

      State: FAILED

      Reason: org.jboss.portal.identity.IdentityException: Cannot initiate identity modules:

      I Depend On:

        portal:service=Hibernate

        portal:service=IdentityEventManager

      Depends On Me:

        portal:service=AuthorizationProvider,type=cms

        portal:service=Interceptor,type=Cms,name=ACL

        portal:service=ApprovePublish,type=Workflow

        portal:service=IdentityUIConfigurationService,type=IdentityUI

        portal:service=IdentityUserManagementService,type=IdentityUI

        portal.management:service=Management,type=Identity,name=Default

        portal:service=Interceptor,type=Server,name=User

        portal:service=Module,type=Mail

        portal:service=CustomizationManager

     

    --- MBEANS THAT ARE THE ROOT CAUSE OF THE PROBLEM ---

    ObjectName: portal:service=Module,type=IdentityServiceController

      State: FAILED

      Reason: org.jboss.portal.identity.IdentityException: Cannot initiate identity modules:

      I Depend On:

        portal:service=Hibernate

        portal:service=IdentityEventManager

      Depends On Me:

        portal:service=AuthorizationProvider,type=cms

        portal:service=Interceptor,type=Cms,name=ACL

        portal:service=ApprovePublish,type=Workflow

        portal:service=IdentityUIConfigurationService,type=IdentityUI

        portal:service=IdentityUserManagementService,type=IdentityUI

        portal.management:service=Management,type=Identity,name=Default

        portal:service=Interceptor,type=Server,name=User

        portal:service=Module,type=Mail

        portal:service=CustomizationManager

     

     

     

    Perhaps anyone of you has already encountered such an error? Help would be much appreciated. Thank you.

  • 2. Re: How to implement a custom identity model for JBoss Portal?
    Thomas Raab Newbie

    Hi!

     

    After several days of investigation I finally found the solution.

     

    The element "class" of standardidentity-config.xml must reference the corresponding module, e.g. for User, it has to

    reference the implementation of UserModule (and not the implementation of User itself: MyUserImpl!!!),

    and the same for Role, Membership and UserProfile.

     

    So I implemented the interfaces UserModule, RoleModule, etc. But not directly, instead I extended UserModuleService,

    RoleModuleService etc. to save some work. The missing properties I mentioned in my last post are no longer necessary then

    and can be removed.

     

    The standardidentity-config.xml now looks like this:

     

    <module>
        <type>User</type>
        <implementation>CUSTOM</implementation>
        <service-name>portal:service=Module,type=User</service-name>
        <class>com.myCompany.MyUserModuleImpl</class>
        <config>
            <option>
               <name>jNDIName</name>
               <value>java:/portal/UserModule</value>
            </option>
        </config>
    </module>
    <module>
        <type>Role</type>
        <implementation>CUSTOM</implementation>
        <service-name>portal:service=Module,type=Role</service-name>
        <class>com.myCompany.MyRoleModuleImpl</class>
        <config>
            <option>
               <name>jNDIName</name>
               <value>java:/portal/RoleModule</value>
            </option>
        </config>
    </module>
        <module>
        <type>Membership</type>
        <implementation>CUSTOM</implementation>
        <service-name>portal:service=Module,type=Membership</service-name>
        <class>com.myCompany.MyMembershipModuleImpl</class>
        <config>
            <option>
               <name>jNDIName</name>
               <value>java:/portal/MembershipModule</value>
            </option>
        </config>
    </module>
    <module>
        <type>UserProfile</type>
        <implementation>CUSTOM</implementation>
        <service-name>portal:service=Module,type=UserProfile</service-name>
        <class>com.myCompany.MyUserProfileModuleImpl</class>
        <config>
            <option>
               <name>jNDIName</name>
               <value>java:/portal/UserProfileModule</value>
            </option>
        </config>
    </module>
    

     

     

    In order to implement those interfaces I had to add the following dependencies to the pom.xml:

     

    <dependency>
        <groupId>org.jboss.portal.common</groupId>
        <artifactId>common-common</artifactId>
        <version>1.2.0</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>jboss</groupId>
        <artifactId>jboss-common-client</artifactId>
        <version>3.2.3</version>
        <scope>provided</scope>
    </dependency>
    

     

     

    Now everthing is working as expected: the server is starting and I can login. :-)