rajeev - 2011-07-06

I have a problem with mondrian dynamic roles.
I cannot use roles statically defined in the xml schema definition file, I must use dynamic roles.
After using the mondrianQuery JPivot tag in my jsp, I make something like this:
<%
OlapModel query11 = (OlapModel)session.getAttribute("query11");
MondrianMdxQuery mdxQuery1 = (MondrianMdxQuery) query11.getExtensions().get("mdxQuery");
MondrianModel mm = (MondrianModel) mdxQuery1.getModel();
RoleImpl connRole = (RoleImpl)mm.getConnection().getRole();
Cube promoCube = mm.getConnection().getSchema().lookupCube("AttachRate", true);
Hierarchy aHierarchy = promoCube.lookupHierarchy(new Id.Segment("Region", Id.Quoting.UNQUOTED), false);
Dimension clientDim = aHierarchy.getDimension();
Member defaultMember = clientDim.getSchema().getSchemaReader().getHierarchyDefaultMember(aHierarchy);
    Member aMember = clientDim.getSchema().getSchemaReader().getMemberChildren(defaultMember);
   
    connRole.grant(mm.getConnection().getSchema(), Access.ALL);
    connRole.grant(promoCube, Access.ALL);
    connRole.grant(aHierarchy, Access.CUSTOM, null, null, null);
    connRole.grant(clientDim, Access.ALL);
    connRole.grant(aMember, Access.ALL);
    connRole.grant(aMember, Access.NONE);
    connRole.grant(aMember, Access.NONE);
    connRole.grant(aMember, Access.NONE);

But it gives me an error: Mondrian Error:Internal error: assert failed: isMutable()

Am I making something wrong?
What should be the best way to set a dynamic role in jpivot - mondrian?

if anybody could send example code at my email rajeevgupta74@airtel.blackberry.com it would be really great
Thanks for any suggestion.