<!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;">
    Re: Running humantasks with HumanTaskService(Running in JBoss)
</h3>
<span style="margin-bottom: 10px;">
    created by <a href="http://community.jboss.org/people/rajan01">Rajan Bansal</a> in <i>jBPM</i> - <a href="http://community.jboss.org/message/627353#627353">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>Actually I want to run the stand-alone service <strong>"HumanTaskService"</strong> via Jboss but not by ant.</p><p>And in this I want my Oracle database is used for all the transactions instead of its own db.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>So I make the necessary changes in the<strong><em> jbpm-human-task-5.1.0.Final.jar:</em></strong></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>I changed the Persistence.xml as I used the JTA data-source for it:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&lt;persistence-unit name="org.jbpm.task" transaction-type="JTA"&gt;</p><p>&#160;&#160;&#160; &lt;provider&gt;org.hibernate.ejb.HibernatePersistence&lt;/provider&gt;</p><p>&#160;&#160; <strong>&#160; &lt;jta-data-source&gt;java:/testDS1&lt;/jta-data-source&gt;&#160;&#160; </strong></p><p>&#160;&#160;&#160;&#160; &lt;class&gt;org.jbpm.task.Attachment&lt;/class&gt;</p><p>&#160;&#160;&#160;&#160; &lt;class&gt;org.jbpm.task.Content&lt;/class&gt;</p><p>&#160;&#160;&#160;&#160; &lt;class&gt;org.jbpm.task.BooleanExpression&lt;/class&gt;</p><p>&#160;&#160;&#160;&#160; &lt;class&gt;org.jbpm.task.Comment&lt;/class&gt;</p><p>&#160;&#160;&#160;&#160; &lt;class&gt;org.jbpm.task.Deadline&lt;/class&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>And my datasource is:</p><p>&lt;datasources&gt;</p><p>&#160; &lt;xa-datasource&gt;</p><p>&#160;&#160;&#160; &lt;jndi-name&gt;testDS1&lt;/jndi-name&gt;</p><p>&#160;&#160;&#160; &lt;xa-datasource-class&gt;oracle.jdbc.xa.client.OracleXADataSource&lt;/xa-datasource-class&gt;</p><p>&#160;&#160;&#160; &lt;xa-datasource-property name="URL"&gt;jdbc:oracle:thin:@172.xx.x.251:1521:lupin&lt;/xa-datasource-property&gt;</p><p>&#160;&#160; &lt;user-name&gt;xxxxx&lt;/user-name&gt;</p><p>&#160; &lt;password&gt;xxxxx&lt;/password&gt;&#160;&#160;&#160; </p><p>&#160; &lt;/xa-datasource&gt;</p><p> &lt;/datasources&gt;</p><p> It is successfully deployed in the jboss.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>But when I want to start "humantaskservice" code in the JBoss then it gives the following error when I am trying to add users:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>public void startTaskService() {</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; EntityManagerFactory emf = Persistence.createEntityManagerFactory("org.jbpm.task");</p><p>&#160;&#160;&#160;&#160; </p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; TaskService taskService = new TaskService(emf, SystemEventListenerFactory.getSystemEventListener());</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; TaskServiceSession taskSession = taskService.createSession();</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; </p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; // Add users</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; Map vars = new HashMap();</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; Reader reader = new InputStreamReader( StartTaskService.class.getResourceAsStream( "LoadUsers.mvel" ) );&#160;&#160;&#160;&#160; </p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; Map&lt;String, User&gt; users = ( Map&lt;String, User&gt; ) eval( reader, vars );&#160;&#160; </p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; for ( User user : users.values() ) {</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; taskSession.addUser( user );</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; }&#160;&#160;&#160;&#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; reader = new InputStreamReader( StartTaskService.class.getResourceAsStream( "LoadGroups.mvel" ) );&#160;&#160;&#160;&#160;&#160; </p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; Map&lt;String, Group&gt; groups = ( Map&lt;String, Group&gt; ) eval( reader, vars );&#160;&#160;&#160;&#160; </p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; for ( Group group : groups.values() ) {</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; taskSession.addGroup(group);</p><p>&#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; // start server</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; MinaTaskServer server = new MinaTaskServer(taskService);</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; Thread thread = new Thread(server);</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; thread.start();</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; taskSession.dispose();</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; System.out.println("Task service started correctly !");</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; System.out.println("Task service running ...");</p><p>&#160;&#160;&#160; }</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><strong>the error is:</strong></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>10:23:18,772 INFO&#160; [SchemaExport] Running hbm2ddl schema export</p><p>10:23:18,772 INFO&#160; [SchemaExport] exporting generated schema to database</p><p>10:23:20,895 INFO&#160; [SchemaExport] schema export complete</p><p>10:23:20,895 INFO&#160; [NamingHelper] JNDI InitialContext properties:{}</p><p>10:23:21,238 INFO&#160; [STDOUT] Hibernate: select task0_.id as col_0_0_, deadline1_.id as col_1_0_, deadline1_.deadline_date as col_2_0_ from Task task0_, Deadline deadline1_ where (deadline1_.id in (select startdeadl2_.id from Deadline startdeadl2_ where task0_.id=startdeadl2_.Deadlines_StartDeadLine_Id) or deadline1_.id in (select enddeadlin3_.id from Deadline enddeadlin3_ where task0_.id=enddeadlin3_.Deadlines_EndDeadLine_Id)) and deadline1_.escalated=0 order by deadline1_.deadline_date</p><p>10:23:21,659 INFO&#160; [STDOUT] Adding userss........</p><p><strong>10:23:21,691 ERROR [[springmvc]] Servlet.service() for servlet springmvc threw exception</strong></p><p><strong>java.lang.IllegalStateException: A JTA EntityManager cannot use getTransaction()</strong></p><p>&#160;&#160;&#160; at org.hibernate.ejb.AbstractEntityManagerImpl.getTransaction(AbstractEntityManagerImpl.java:324)</p><p>&#160;&#160;&#160; at org.jbpm.task.service.TaskServiceSession.doOperationInTransaction(TaskServiceSession.java:811)</p><p>&#160;&#160;&#160; at org.jbpm.task.service.TaskServiceSession.persistInTransaction(TaskServiceSession.java:786)</p><p>&#160;&#160;&#160; at org.jbpm.task.service.TaskServiceSession.addUser(TaskServiceSession.java:69)</p><p>&#160;&#160;&#160; at com.service.StartTaskService.startTaskService(StartTaskService.java:54)</p><p>&#160;&#160;&#160; at com.service.HumanTaskService.startHumanTask(HumanTaskService.java:17)</p><p>&#160;&#160;&#160; at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)</p><p>&#160;&#160;&#160; at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)</p><p>&#160;&#160;&#160; at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)</p><p>&#160;&#160;&#160; at java.lang.reflect.Method.invoke(Method.java:597)</p><p>&#160;&#160;&#160; at org.springframework.web.servlet.mvc.multiaction.MultiActionController.invokeNamedMethod(MultiActionController.java:471)</p><p>&#160;&#160;&#160; at org.springframework.web.servlet.mvc.multiaction.MultiActionController.handleRequestInternal(MultiActionController.java:408)</p><p>&#160;&#160;&#160; at org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:153)</p><p>&#160;&#160;&#160; at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)</p><p>&#160;&#160;&#160; at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:790)</p><p>&#160;&#160;&#160; at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)</p><p>&#160;&#160;&#160; at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)</p><p>&#160;&#160;&#160; at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:560)</p><p>&#160;&#160;&#160; at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)</p><p>&#160;&#160;&#160; at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)</p><p>&#160;&#160;&#160; at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)</p><p>&#160;&#160;&#160; at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)</p><p>&#160;&#160;&#160; at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)</p><p>&#160;&#160;&#160; at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)</p><p>&#160;&#160;&#160; at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)</p><p>&#160;&#160;&#160; at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)</p><p>&#160;&#160;&#160; at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)</p><p>&#160;&#160;&#160; at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)</p><p>&#160;&#160;&#160; at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)</p><p>&#160;&#160;&#160; at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)</p><p>&#160;&#160;&#160; at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)</p><p>&#160;&#160;&#160; at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)</p><p>&#160;&#160;&#160; at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)</p><p>&#160;&#160;&#160; at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)</p><p>&#160;&#160;&#160; at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)</p><p>&#160;&#160;&#160; at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)</p><p>&#160;&#160;&#160; at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)</p><p>&#160;&#160;&#160; at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)</p><p>&#160;&#160;&#160; at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)</p><p>&#160;&#160;&#160; at java.lang.Thread.run(Thread.java:662)</p><p>10:25:21,982 INFO&#160; [ServletContextListener] Welcome to Seam 2.1.0.SP1</p><p>10:25:30,353 WARN&#160; [Component] Component class should be serializable: org.jboss.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>please tell me what to do.</p></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/627353#627353">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>