[jboss-user] [jBPM] - Re: ClassCastException

sc_boss do-not-reply at jboss.com
Thu Feb 21 10:44:58 EST 2013


sc_boss [https://community.jboss.org/people/sc_boss] created the discussion

"Re: ClassCastException"

To view the discussion, visit: https://community.jboss.org/message/798879#798879

--------------------------------------------------------------
It is a simple program with very little modification to the evaluation process that comes with installation. I've configured my DB as Oracle.

Attached is the log generated. My apologies for any stupid mistake in the program. I'm still trying to get comfortable with JBPM.

My Process basically takes a name and the user tries to modify it trough UI.

Please note that the process is generating tasks properly as I can see it in inbox of krisv.

public class ProcessTest
{
     public static final void main(String[] args) throws Exception
    {
        StatefulKnowledgeSession ksession = null;
        KnowledgeRuntimeLogger logger = null;
        HornetQHTWorkItemHandler humanTaskHandler = null;
        try {
            // load up the knowledge base
            KnowledgeBase kbase = readKnowledgeBase();

            ksession = createKnowledgeSession(kbase);

            humanTaskHandler = new HornetQHTWorkItemHandler(ksession);
            humanTaskHandler.setIpAddress("127.0.0.1");
            humanTaskHandler.setPort(5153);
            ksession.getWorkItemManager().registerWorkItemHandler("Human Task", humanTaskHandler);

            logger = KnowledgeRuntimeLoggerFactory.newThreadedFileLogger(ksession, "test", 1000);

            final StatefulKnowledgeSession k = ksession;
            final KnowledgeRuntimeLogger l = logger;

            // start a new process instance
            Map<String, Object> params = new HashMap<String, Object>();
            //params.put("employee", "krisv");
            //params.put("reason", "Yearly performance evaluation");
            params.put("name", "some name".toLowerCase());

            //ProcessInstance pi = ksession.startProcess("com.sample.evaluation", params);
            ProcessInstance pi =
                ksession.startProcess("mypackage.test1", params);

            System.out.println("Process started ... "+pi.getId());
            System.out.println("Process state ... "+pi.getState());
        } catch (Throwable t) {
            t.printStackTrace();
        }
        finally {
            if(ksession != null) ksession.dispose();
            if(humanTaskHandler != null) humanTaskHandler.dispose();
            if(logger != null) logger.close();
        }
    }

    private static KnowledgeBase readKnowledgeBase() throws Exception {
        KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();

        String URL = "http://localhost:8080/drools-guvnor/org.drools.guvnor.Guvnor/package/mypackage/LATEST";
        UrlResource resource = (UrlResource) ResourceFactory.newUrlResource(URL);
        resource.setBasicAuthentication("enabled");
        resource.setUsername("admin");
        resource.setPassword("admin");
        kbuilder.add(resource, ResourceType.PKG);

        setupDb();
        TransactionManagerServices.getConfiguration().setDefaultTransactionTimeout(60*10);
        System.setProperty("java.naming.factory.initial", "bitronix.tm.jndi.BitronixInitialContextFactory");

        //kbuilder.add(ResourceFactory.newClassPathResource("Evaluation.bpmn"), ResourceType.BPMN2);
        return kbuilder.newKnowledgeBase();
    }

    private static void setupDb() {
        TransactionManagerServices.getConfiguration().setServerId("TransactionManager-1");
        PoolingDataSource ds = new PoolingDataSource();
        ds.setUniqueName("processInstanceDS");
        ds.setClassName("oracle.jdbc.xa.client.OracleXADataSource");
        ds.setMaxPoolSize(3);
        ds.setAllowLocalTransactions(true);
        ds.getDriverProperties().put("user", "jbpmprocess");
        ds.getDriverProperties().put("password", "secret");
        ds.getDriverProperties().put("URL", "jdbc:oracle:thin:@127.0.0.1:1521:xe");
        ds.init();
    }

    private static StatefulKnowledgeSession createKnowledgeSession(KnowledgeBase kbase) {

        Environment env = KnowledgeBaseFactory.newEnvironment();
        env.set( EnvironmentName.ENTITY_MANAGER_FACTORY, Persistence.createEntityManagerFactory( "org.jbpm.persistence.jpa" ) );

        Properties properties = new Properties();
        KnowledgeSessionConfiguration config = KnowledgeBaseFactory.newKnowledgeSessionConfiguration(properties);

        StatefulKnowledgeSession ksession =
            JPAKnowledgeService.newStatefulKnowledgeSession( kbase, config, env );

        return ksession;
    }
}
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/798879#798879]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20130221/6ee66b6c/attachment-0001.html 


More information about the jboss-user mailing list