0 Replies Latest reply on Sep 7, 2009 2:55 AM by sateesh kommineni

    HibernateUserImpl cannot be cast to org.jboss.portal.identit

    sateesh kommineni Newbie

      Hi All,

      I am trying to get the User Object from the User Module and i am getting the following exception:

      java.lang.ClassCastException: org.jboss.portal.identity.db.HibernateUserImpl cannot be cast to org.jboss.portal.identity.User
       at $Proxy289.findUserByUserName(Unknown Source)
       at test.portlet.ChangePasswordPortlet.getUser(ChangePasswordPortlet.java)
       at test.portlet.ChangePasswordPortlet.isValidCurrentPassword(ChangePasswordPortlet.java)
       at test.portlet.ChangePasswordPortlet.checkInputValdiity(ChangePasswordPortlet.java)
       at test.portlet.ChangePasswordPortlet.doView(ChangePasswordPortlet.java:)
       at javax.portlet.GenericPortlet.doDispatch(GenericPortlet.java:328)
       at javax.portlet.GenericPortlet.render(GenericPortlet.java:233)
      


      The code i have is:

      
       private UserModule getUserModule()
       {
       UserModule userModule = (UserModule) getPortletContext().getAttribute("UserModule");
       if(userModule==null)
       {
       try
       {
       userModule = (UserModule)new InitialContext().lookup("java:portal/UserModule");
       }
       catch(NamingException ne)
       {
       ne.printStackTrace();
       }
       }
       return userModule;
       }
      
      
       private User getUser(RenderRequest request)
       {
       User user = null;
       try
       {
       UserModule userModule = getUserModule();
       String userName = getUserName(request);
       if(userModule!=null)
       {
       user =userModule.findUserByUserName(userName);
       }
       }
       catch (IllegalArgumentException e)
       {
       e.printStackTrace();
       }
       catch (NoSuchUserException e)
       {
       e.printStackTrace();
       }
       catch (IdentityException e)
       {
       e.printStackTrace();
       }
       return user;
       }
      
       private String getUserName(RenderRequest request) {
       String userName = request.getRemoteUser();
       if(userName==null && request.getUserPrincipal()!=null)
       {
       userName = request.getUserPrincipal().getName();
       }
       return userName;
       }
      
      



      And in jboss-portlet.xml i have specified the required services..

      
      <portlet-app>
       <portlet>
       <portlet-name>ChangePasswordPortlet</portlet-name>
       <transaction>
       <trans-attribute>Required</trans-attribute>
       </transaction>
       </portlet>
       <service>
       <service-name>UserModule</service-name>
       <service-class>org.jboss.portal.identity.UserModule</service-class>
       <service-ref>:service=Module,type=User</service-ref>
       </service>
       <service>
       <service-name>UserProfileModule</service-name>
       <service-class>org.jboss.portal.identity.UserProfileModule</service-class>
       <service-ref>:service=Module,type=UserProfile</service-ref>
       </service>
      


      Pls let me know why i am getting this strange exception as HibenrateUserImpl implemets the Interface User !!!!!

      mars