<!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="https://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: ClassCastException
</h3>
<span style="margin-bottom: 10px;">
created by <a href="https://community.jboss.org/people/sc_boss">sc_boss</a> in <i>jBPM</i> - <a href="https://community.jboss.org/message/798879#798879">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">
<div class="jive-rendered-content"><p>It is a simple program with very little modification to the evaluation process that comes with installation. I've configured my DB as Oracle.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>Attached is the log generated. My apologies for any stupid mistake in the program. I'm still trying to get comfortable with JBPM.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>My Process basically takes a name and the user tries to modify it trough UI.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>Please note that the process is generating tasks properly as I can see it in inbox of krisv.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p><span style="font-family: courier new,courier; font-size: 8pt;">public class ProcessTest</span></p><p><span style="font-family: courier new,courier; font-size: 8pt;">{</span></p><p> <span style="font-family: courier new,courier; font-size: 8pt;">    public static final void main(String[] args) throws Exception</span></p><p><span style="font-family: courier new,courier; font-size: 8pt;">    </span><span style="font-family: courier new,courier; font-size: 8pt;">{</span></p><p> <span style="font-family: courier new,courier; font-size: 8pt;">       StatefulKnowledgeSession ksession = null;</span></p><p><span style="font-family: courier new,courier; font-size: 8pt;">        KnowledgeRuntimeLogger logger = null;</span></p><p><span style="font-family: courier new,courier; font-size: 8pt;">        HornetQHTWorkItemHandler humanTaskHandler = null;</span></p><p><span style="font-family: courier new,courier; font-size: 8pt;">        try {</span></p><p><span style="font-family: courier new,courier; font-size: 8pt;">            // load up the knowledge base</span></p><p><span style="font-family: courier new,courier; font-size: 8pt;">            KnowledgeBase kbase = readKnowledgeBase();</span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p><span style="font-family: courier new,courier; font-size: 8pt;">            ksession = createKnowledgeSession(kbase);</span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p><span style="font-family: courier new,courier; font-size: 8pt;">            humanTaskHandler = new HornetQHTWorkItemHandler(ksession);</span></p><p><span style="font-family: courier new,courier; font-size: 8pt;">            humanTaskHandler.setIpAddress("127.0.0.1");</span></p><p><span style="font-family: courier new,courier; font-size: 8pt;">            humanTaskHandler.setPort(5153);</span></p><p><span style="font-family: courier new,courier; font-size: 8pt;">            ksession.getWorkItemManager().registerWorkItemHandler("Human Task", humanTaskHandler);</span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p><span style="font-family: courier new,courier; font-size: 8pt;">            logger = KnowledgeRuntimeLoggerFactory.newThreadedFileLogger(ksession, "test", 1000);</span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p><span style="font-family: courier new,courier; font-size: 8pt;">            final StatefulKnowledgeSession k = ksession;</span></p><p><span style="font-family: courier new,courier; font-size: 8pt;">            final KnowledgeRuntimeLogger l = logger;</span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p><span style="font-family: courier new,courier; font-size: 8pt;">            // start a new process instance</span></p><p><span style="font-family: courier new,courier; font-size: 8pt;">            Map<String, Object> params = new HashMap<String, Object>();</span></p><p><span style="font-family: courier new,courier; font-size: 8pt;">            //params.put("employee", "krisv");</span></p><p><span style="font-family: courier new,courier; font-size: 8pt;">            //params.put("reason", "Yearly performance evaluation");</span></p><p><span style="font-family: courier new,courier; font-size: 8pt;">            params.put("name", "some name".toLowerCase());</span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p><span style="font-family: courier new,courier; font-size: 8pt;">            //ProcessInstance pi = ksession.startProcess("com.sample.evaluation", params);</span></p><p><span style="font-family: courier new,courier; font-size: 8pt;">            ProcessInstance pi =</span></p><p><span style="font-family: courier new,courier; font-size: 8pt;">                ksession.startProcess("mypackage.test1", params);</span></p><p>            </p><p><span style="font-family: courier new,courier; font-size: 8pt;">            System.out.println("Process started ... "+pi.getId());</span></p><p><span style="font-family: courier new,courier; font-size: 8pt;">            System.out.println("Process state ... "+pi.getState());</span></p><p><span style="font-family: courier new,courier; font-size: 8pt;">        } catch (Throwable t) {</span></p><p><span style="font-family: courier new,courier; font-size: 8pt;">            t.printStackTrace();</span></p><p><span style="font-family: courier new,courier; font-size: 8pt;">        }</span></p><p><span style="font-family: courier new,courier; font-size: 8pt;">        finally {</span></p><p><span style="font-family: courier new,courier; font-size: 8pt;">            if(ksession != null) ksession.dispose();</span></p><p><span style="font-family: courier new,courier; font-size: 8pt;">            if(humanTaskHandler != null) humanTaskHandler.dispose();</span></p><p><span style="font-family: courier new,courier; font-size: 8pt;">            if(logger != null) logger.close();</span></p><p><span style="font-family: courier new,courier; font-size: 8pt;">        }</span></p><p><span style="font-family: courier new,courier; font-size: 8pt;">    }</span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p><span style="font-family: courier new,courier; font-size: 8pt;">    private static KnowledgeBase readKnowledgeBase() throws Exception {</span></p><p><span style="font-family: courier new,courier; font-size: 8pt;">        KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();</span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p><span style="font-family: courier new,courier; font-size: 8pt;"><span>        String URL = "</span><a class="jive-link-external-small" href="http://localhost:8080/drools-guvnor/org.drools.guvnor.Guvnor/package/mypackage/LATEST" rel="nofollow" target="_blank">http://localhost:8080/drools-guvnor/org.drools.guvnor.Guvnor/package/mypackage/LATEST</a><span>";</span></span></p><p><span style="font-family: courier new,courier; font-size: 8pt;">        UrlResource resource = (UrlResource) ResourceFactory.newUrlResource(URL);</span></p><p><span style="font-family: courier new,courier; font-size: 8pt;">        resource.setBasicAuthentication("enabled");</span></p><p><span style="font-family: courier new,courier; font-size: 8pt;">        resource.setUsername("admin");</span></p><p><span style="font-family: courier new,courier; font-size: 8pt;">        resource.setPassword("admin");</span></p><p><span style="font-family: courier new,courier; font-size: 8pt;">        kbuilder.add(resource, ResourceType.PKG);</span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p><span style="font-family: courier new,courier; font-size: 8pt;">        setupDb();</span></p><p><span style="font-family: courier new,courier; font-size: 8pt;">        TransactionManagerServices.getConfiguration().setDefaultTransactionTimeout(60*10);</span></p><p><span style="font-family: courier new,courier; font-size: 8pt;">        System.setProperty("java.naming.factory.initial", "bitronix.tm.jndi.BitronixInitialContextFactory");</span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p><span style="font-family: courier new,courier; font-size: 8pt;">        //kbuilder.add(ResourceFactory.newClassPathResource("Evaluation.bpmn"), ResourceType.BPMN2);</span></p><p><span style="font-family: courier new,courier; font-size: 8pt;">        return kbuilder.newKnowledgeBase();</span></p><p><span style="font-family: courier new,courier; font-size: 8pt;">    }</span></p><p>    </p><p><span style="font-family: courier new,courier; font-size: 8pt;">    private static void setupDb() {</span></p><p><span style="font-family: courier new,courier; font-size: 8pt;">        TransactionManagerServices.getConfiguration().setServerId("TransactionManager-1");</span></p><p><span style="font-family: courier new,courier; font-size: 8pt;">        PoolingDataSource ds = new PoolingDataSource();</span></p><p><span style="font-family: courier new,courier; font-size: 8pt;">        ds.setUniqueName("processInstanceDS");</span></p><p><span style="font-family: courier new,courier; font-size: 8pt;">        ds.setClassName("oracle.jdbc.xa.client.OracleXADataSource");</span></p><p><span style="font-family: courier new,courier; font-size: 8pt;">        ds.setMaxPoolSize(3);</span></p><p><span style="font-family: courier new,courier; font-size: 8pt;">        ds.setAllowLocalTransactions(true);</span></p><p><span style="font-family: courier new,courier; font-size: 8pt;">        ds.getDriverProperties().put("user", "jbpmprocess");</span></p><p><span style="font-family: courier new,courier; font-size: 8pt;">        ds.getDriverProperties().put("password", "secret");</span></p><p><span style="font-family: courier new,courier; font-size: 8pt;">        ds.getDriverProperties().put("URL", "jdbc:oracle:thin:@127.0.0.1:1521:xe");</span></p><p><span style="font-family: courier new,courier; font-size: 8pt;">        ds.init();</span></p><p><span style="font-family: courier new,courier; font-size: 8pt;">    }</span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p><span style="font-family: courier new,courier; font-size: 8pt;">    private static StatefulKnowledgeSession createKnowledgeSession(KnowledgeBase kbase) {</span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p><span style="font-family: courier new,courier; font-size: 8pt;">        Environment env = KnowledgeBaseFactory.newEnvironment();</span></p><p><span style="font-family: courier new,courier; font-size: 8pt;">        env.set( EnvironmentName.ENTITY_MANAGER_FACTORY, Persistence.createEntityManagerFactory( "org.jbpm.persistence.jpa" ) );</span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p><span style="font-family: courier new,courier; font-size: 8pt;">        Properties properties = new Properties();</span></p><p><span style="font-family: courier new,courier; font-size: 8pt;">        KnowledgeSessionConfiguration config = KnowledgeBaseFactory.newKnowledgeSessionConfiguration(properties);</span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p><span style="font-family: courier new,courier; font-size: 8pt;">        StatefulKnowledgeSession ksession =</span></p><p><span style="font-family: courier new,courier; font-size: 8pt;">            JPAKnowledgeService.newStatefulKnowledgeSession( kbase, config, env );</span></p><p>        </p><p><span style="font-family: courier new,courier; font-size: 8pt;">        return ksession;</span></p><p><span style="font-family: courier new,courier; font-size: 8pt;">    }</span></p><p><span style="font-family: courier new,courier; font-size: 8pt;">}</span></p></div>
<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
<p style="margin: 0;">Reply to this message by <a href="https://community.jboss.org/message/798879#798879">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in jBPM at <a href="https://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>