-
1. Re: ClassCastException
swiderski.maciej Feb 21, 2013 5:40 AM (in response to sc_boss)could you provide more information when it happen? What operation do you invoke when this error occurs?
-
2. Re: ClassCastException
sc_boss Feb 21, 2013 10:44 AM (in response to swiderski.maciej)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;
}
}
-
log.txt.zip 5.1 KB
-
-
3. Re: ClassCastException
swiderski.maciej Feb 21, 2013 12:10 PM (in response to sc_boss)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
-
4. Re: ClassCastException
sc_boss Feb 21, 2013 3:22 PM (in response to swiderski.maciej)"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.