HI
Using jbpm 4.4. WITH jboss-5.1.0.GA
1 :I am also having this kind of issue at the moment . What i have done was extended IdentitySessionImpl and created my own MyIdentitySession .and i have over right few methods createUser,createGroup what was already there in IdentitySessionImpl.
public class MyIdentitySession extends IdentitySessionImpl
{
/*
* This method will create or update a user
*
* */
public String createUser(String userName, String givenName, String familyName, String businessEmail)
{
User user = null;
try
{
user = findUserById(userName);
}
catch (Exception ex)
{
}
if (user == null)
{
user = new UserImpl(userName, givenName, familyName);
long dbid = EnvironmentImpl.getFromCurrent(DbidGenerator.class).getNextId();
((UserImpl) user).setDbid(dbid);
}
UserImpl userimpl = (UserImpl) user;
userimpl.setBusinessEmail(businessEmail);
userimpl.setFamilyName(familyName);
userimpl.setGivenName(givenName);
userimpl.setId(userName);
session.save(user);
return user.getId();
}
/*
* This method will create or modify Group
*
* */
public String createGroup(String groupName, String groupType, String parentGroupId)
{
GroupImpl group = null;
try
{
group = findGroupById(groupName);
}
catch (Exception ex)
{
}
if (group == null)
{
group = new GroupImpl();
String groupId = groupType != null ? groupType + "." + groupName : groupName;
group.setId(groupId);
long dbid = EnvironmentImpl.getFromCurrent(DbidGenerator.class).getNextId();
group.setDbid(dbid);
}
group.setName(groupName);
group.setType(groupType);
if (parentGroupId != null)
{
GroupImpl parentGroup = findGroupById(parentGroupId);
group.setParent(parentGroup);
}
session.save(group);
return group.getId();
}
public void setSession(Session session)
{
super.setSession(session);
Configuration.getProcessEngine().get()
}
}
2: Then i created new MyIdentitySessionBinding by extending WireDescriptorBinding
public class MyIdentitySessionBinding extends WireDescriptorBinding
{
public MyIdentitySessionBinding()
{
super("identity-session");
}
public Object parse(Element element, Parse parse, Parser parser)
{
ObjectDescriptor objectDescriptor = new ObjectDescriptor(MyIdentitySession.class);
objectDescriptor.addTypedInjection("session", Session.class);
return objectDescriptor;
}
}
3: Then this MyIdentitySessionBinding was registered using jbpm.user.wire.bindings.xml
<wire-bindings>
<!-- sessions -->
<binding class ="dd.ss.ss.MyIdentitySessionBinding" />
</wire-bindings>
4: Added this file inside that jbpm-service.sar which inside JBoss deploy directory .
5 : Customised jbpm.cfg.xml as bellow
<jbpm-configuration jndi-name="java:/ProcessEngine">
<import resource="jbpm.default.cfg.xml" />
<import resource="jbpm.businesscalendar.cfg.xml" />
<import resource="jbpm.tx.jta.cfg.xml" />
<import resource="jbpm.jpdl.cfg.xml" />
<import resource="jbpm.bpmn.cfg.xml" />
<import resource="jbpm.jobexecutor.cfg.xml" />
<import resource="jbpm.console.cfg.xml" />
<transaction-context>
<object class ="aa.bb.cc.MyIdentitySession" />
</transaction-context>
</jbpm-configuration>
Whwn i try to use createUser,createGroup methods inside MyIdentitySession, it gives me NullPointer exception when accessing session[Hybranate ].
Hope there should be a configuration issue. Please assist me on this regards
Thank you