<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body link="#355491" alink="#4262a1" vlink="#355491" style="background: #e2e2e2; margin: 0; padding: 20px;">

<div>
        <table cellpadding="0" bgcolor="#FFFFFF" border="0" cellspacing="0" style="border: 1px solid #dadada; margin-bottom: 30px; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                <tbody>
                        <tr>

                                <td>

                                        <table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border: solid 2px #ccc; background: #dadada; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                                                <tbody>
                                                        <tr>
                                                                <td bgcolor="#000000" valign="middle" height="58px" style="border-bottom: 1px solid #ccc; padding: 20px; -moz-border-radius-topleft: 3px; -moz-border-radius-topright: 3px; -webkit-border-top-right-radius: 5px; -webkit-border-top-left-radius: 5px;">
                                                                        <h1 style="color: #333333; font: bold 22px Arial, Helvetica, sans-serif; margin: 0; display: block !important;">
                                                                        <!-- To have a header image/logo replace the name below with your img tag -->
                                                                        <!-- Email clients will render the images when the message is read so any image -->
                                                                        <!-- must be made available on a public server, so that all recipients can load the image. -->
                                                                        <a href="http://community.jboss.org/index.jspa" style="text-decoration: none; color: #E1E1E1">JBoss Community</a></h1>
                                                                </td>

                                                        </tr>
                                                        <tr>
                                                                <td bgcolor="#FFFFFF" style="font: normal 12px Arial, Helvetica, sans-serif; color:#333333; padding: 20px;  -moz-border-radius-bottomleft: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px;"><h3 style="margin: 10px 0 5px; font-size: 17px; font-weight: normal;">
    adding a custom service to jbpm.cfg.xml
</h3>
<span style="margin-bottom: 10px;">
    reply from <a href="http://community.jboss.org/people/kelum">kelum_sv N</a> in <i>jBPM</i> - <a href="http://community.jboss.org/message/559052#559052">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">

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

<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
    <p style="margin: 0;">Reply to this message by <a href="http://community.jboss.org/message/559052#559052">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in jBPM at <a href="http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034">Community</a></p>
</div></td>
                        </tr>
                    </tbody>
                </table>


                </td>
            </tr>
        </tbody>
    </table>

</div>

</body>
</html>