Discussion:
[jboss-user] [jBPM] - Re: ClassCastException
Maciej Swiderski
2013-02-21 10:40:24 UTC
Permalink
Maciej Swiderski [https://community.jboss.org/people/swiderski.maciej] created the discussion

"Re: ClassCastException"

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

--------------------------------------------------------------
could you provide more information when it happen? What operation do you invoke when this error occurs?
--------------------------------------------------------------

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

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
sc_boss
2013-02-21 15:44:58 UTC
Permalink
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]
Maciej Swiderski
2013-02-21 17:10:24 UTC
Permalink
Maciej Swiderski [https://community.jboss.org/people/swiderski.maciej] created the discussion

"Re: ClassCastException"

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

--------------------------------------------------------------
ok if it's an evaluation process then it could be that you suplly not valid employee that is process variable used to assign first task to. Antoher thing is that since you modified the evaluation process it could be that
params.put("name", "some name".toLowerCase());
"some name" must be know to task service unless you use DefaultUserGroupCallback that accepts all users.

Since you provided logs from client execution it would be good to check server log where task service is running, there are most likely some errors that causing to return incorrect response.

HTH
--------------------------------------------------------------

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

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
sc_boss
2013-02-21 20:22:21 UTC
Permalink
sc_boss [https://community.jboss.org/people/sc_boss] created the discussion

"Re: ClassCastException"

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

--------------------------------------------------------------
"name" is just a variable in my process. I checked the server logs and i did not see any error.

Just FYI (if this helps) : Switching to AsyncHornetQHTWorkItemHandler fixed my issue. I dontt see any issue or errors.
--------------------------------------------------------------

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

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