2 Replies Latest reply: Jun 26, 2012 8:54 AM by xealous RSS

How to use jar files in guvnor?

xealous Newbie

Hi everyone,

I've been searching for days and still couldn't find good tutorials on jbpm5. I have a hard time using external jars in my project. Any help is appreciated

Here are the steps I took;

I have a CreateProject.jar file that I need to use with my process so that I can write stuff to the database via a web service.

I have com.deneme.CreateProject class in it that I import and use in my script task.

I've uploaded it as POJO model jar

Package validation and build is successful but I don't see my process in jbpm-console and jboss server log has the following:

 

 

15:08:21,612 ERROR [stderr] (Thread-43) java.lang.RuntimeException: KnowledgeAgent exception while trying to deserialize KnowledgeDefinitionsPackage 

15:08:21,612 ERROR [stderr] (Thread-43)     at org.drools.agent.impl.KnowledgeAgentImpl.createPackageFromResource(KnowledgeAgentImpl.java:776)

15:08:21,612 ERROR [stderr] (Thread-43)     at org.drools.agent.impl.KnowledgeAgentImpl.createPackageFromResource(KnowledgeAgentImpl.java:706)

15:08:21,612 ERROR [stderr] (Thread-43)     at org.drools.agent.impl.KnowledgeAgentImpl.incrementalBuildResources(KnowledgeAgentImpl.java:892)

15:08:21,612 ERROR [stderr] (Thread-43)     at org.drools.agent.impl.KnowledgeAgentImpl.buildKnowledgeBase(KnowledgeAgentImpl.java:675)

15:08:21,612 ERROR [stderr] (Thread-43)     at org.drools.agent.impl.KnowledgeAgentImpl.applyChangeSet(KnowledgeAgentImpl.java:203)

15:08:21,612 ERROR [stderr] (Thread-43)     at org.drools.agent.impl.KnowledgeAgentImpl$ChangeSetNotificationDetector.run(KnowledgeAgentImpl.java:1270)

15:08:21,612 ERROR [stderr] (Thread-43)     at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)

15:08:21,613 ERROR [stderr] (Thread-43)     at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)

15:08:21,613 ERROR [stderr] (Thread-43)     at java.util.concurrent.FutureTask.run(FutureTask.java:138)

15:08:21,613 ERROR [stderr] (Thread-43)     at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)

15:08:21,613 ERROR [stderr] (Thread-43)     at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)

15:08:21,613 ERROR [stderr] (Thread-43)     at java.util.concurrent.FutureTask.run(FutureTask.java:138)

15:08:21,613 ERROR [stderr] (Thread-43)     at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)

15:08:21,613 ERROR [stderr] (Thread-43)     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)

15:08:21,613 ERROR [stderr] (Thread-43)     at java.lang.Thread.run(Thread.java:662)

15:08:21,614 ERROR [stderr] (Thread-43) Caused by: java.lang.ClassNotFoundException: com.deneme.CreateProject from [Module "deployment.jbpm-gwt-console-server.war:main" from Service Module Loader]

15:08:21,614 ERROR [stderr] (Thread-43)     at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:191)

15:08:21,614 ERROR [stderr] (Thread-43)     at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:361)

15:08:21,614 ERROR [stderr] (Thread-43)     at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:333)

15:08:21,614 ERROR [stderr] (Thread-43)     at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:310)

15:08:21,614 ERROR [stderr] (Thread-43)     at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:103)

15:08:21,614 ERROR [stderr] (Thread-43)     at java.lang.Class.forName0(Native Method)

15:08:21,614 ERROR [stderr] (Thread-43)     at java.lang.Class.forName(Class.java:247)

15:08:21,615 ERROR [stderr] (Thread-43)     at org.drools.common.DroolsObjectInputStream.resolveClass(DroolsObjectInputStream.java:85)

15:08:21,615 ERROR [stderr] (Thread-43)     at org.drools.common.DroolsObjectInputStream.resolveClass(DroolsObjectInputStream.java:97)

15:08:21,615 ERROR [stderr] (Thread-43)     at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1574)

15:08:21,615 ERROR [stderr] (Thread-43)     at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1495)

15:08:21,615 ERROR [stderr] (Thread-43)     at java.io.ObjectInputStream.readClass(ObjectInputStream.java:1461)

15:08:21,615 ERROR [stderr] (Thread-43)     at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1311)

15:08:21,615 ERROR [stderr] (Thread-43)     at java.io.ObjectInputStream.readObject(ObjectInputStream.java:350)

15:08:21,615 ERROR [stderr] (Thread-43)     at java.util.HashMap.readObject(HashMap.java:1030)

15:08:21,616 ERROR [stderr] (Thread-43)     at sun.reflect.GeneratedMethodAccessor54.invoke(Unknown Source)

15:08:21,616 ERROR [stderr] (Thread-43)     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

15:08:21,616 ERROR [stderr] (Thread-43)     at java.lang.reflect.Method.invoke(Method.java:597)

15:08:21,616 ERROR [stderr] (Thread-43)     at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:969)

15:08:21,616 ERROR [stderr] (Thread-43)     at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1848)

15:08:21,616 ERROR [stderr] (Thread-43)     at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1752)

15:08:21,616 ERROR [stderr] (Thread-43)     at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1328)

15:08:21,616 ERROR [stderr] (Thread-43)     at java.io.ObjectInputStream.readObject(ObjectInputStream.java:350)

15:08:21,616 ERROR [stderr] (Thread-43)     at org.drools.rule.MVELDialectRuntimeData.readExternal(MVELDialectRuntimeData.java:85)

15:08:21,617 ERROR [stderr] (Thread-43)     at java.io.ObjectInputStream.readExternalData(ObjectInputStream.java:1791)

15:08:21,617 ERROR [stderr] (Thread-43)     at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1750)

15:08:21,617 ERROR [stderr] (Thread-43)     at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1328)

15:08:21,617 ERROR [stderr] (Thread-43)     at java.io.ObjectInputStream.readObject(ObjectInputStream.java:350)

15:08:21,617 ERROR [stderr] (Thread-43)     at java.util.HashMap.readObject(HashMap.java:1030)

15:08:21,617 ERROR [stderr] (Thread-43)     at sun.reflect.GeneratedMethodAccessor54.invoke(Unknown Source)

15:08:21,617 ERROR [stderr] (Thread-43)     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

15:08:21,617 ERROR [stderr] (Thread-43)     at java.lang.reflect.Method.invoke(Method.java:597)

15:08:21,617 ERROR [stderr] (Thread-43)     at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:969)

15:08:21,618 ERROR [stderr] (Thread-43)     at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1848)

15:08:21,618 ERROR [stderr] (Thread-43)     at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1752)

15:08:21,618 ERROR [stderr] (Thread-43)     at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1328)

15:08:21,618 ERROR [stderr] (Thread-43)     at java.io.ObjectInputStream.readObject(ObjectInputStream.java:350)

15:08:21,618 ERROR [stderr] (Thread-43)     at org.drools.rule.DialectRuntimeRegistry.readExternal(DialectRuntimeRegistry.java:59)

15:08:21,618 ERROR [stderr] (Thread-43)     at java.io.ObjectInputStream.readExternalData(ObjectInputStream.java:1791)

15:08:21,618 ERROR [stderr] (Thread-43)     at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1750)

15:08:21,618 ERROR [stderr] (Thread-43)     at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1328)

15:08:21,619 ERROR [stderr] (Thread-43)     at java.io.ObjectInputStream.readObject(ObjectInputStream.java:350)

15:08:21,619 ERROR [stderr] (Thread-43)     at org.drools.rule.Package.readExternal(Package.java:208)

15:08:21,619 ERROR [stderr] (Thread-43)     at java.io.ObjectInputStream.readExternalData(ObjectInputStream.java:1791)

15:08:21,619 ERROR [stderr] (Thread-43)     at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1750)

15:08:21,619 ERROR [stderr] (Thread-43)     at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1328)

15:08:21,619 ERROR [stderr] (Thread-43)     at java.io.ObjectInputStream.readArray(ObjectInputStream.java:1666)

15:08:21,619 ERROR [stderr] (Thread-43)     at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1322)

15:08:21,619 ERROR [stderr] (Thread-43)     at java.io.ObjectInputStream.readObject(ObjectInputStream.java:350)

15:08:21,619 ERROR [stderr] (Thread-43)     at org.drools.core.util.DroolsStreamUtils.streamIn(DroolsStreamUtils.java:205)

15:08:21,620 ERROR [stderr] (Thread-43)     at org.drools.core.util.DroolsStreamUtils.streamIn(DroolsStreamUtils.java:174)

15:08:21,620 ERROR [stderr] (Thread-43)     at org.drools.agent.impl.KnowledgeAgentImpl.createPackageFromResource(KnowledgeAgentImpl.java:749)

15:08:21,620 ERROR [stderr] (Thread-43)     ... 14 more

Moreover, is using script task is fine or should I use another approach?

Thanks in advence

  • 1. Re: How to use jar files in guvnor?
    Tihomir Surdilovic Master

    There are two things here:

    1) Using your custom classes as to define types of process variables, and using them in your script tasks,

    2) Your service node handler implementations

     

    for 1) you need to add your jar files to Guvnor (as a jar model). Your package when built will be built using the class definitions of your model jars. You also will need to make those jars available on your application classpath (since the .pkg file will not include them). If you place them in the $installer/depencencies dir they will be placed on the classpath for you (follow instructions below on the ant calls).

     

    for 2) best thing is to use the jBPM 5 installer. In this case you can simple place your dependency jars and jars that include handler impls in the $installer/dependencies directory and run

    ant clean.demo

    ant install.demo (or ant install.demo.noeclipse)

    and start.demo (or ant start.demo.noeclipse)

     

    Hope this helps.

  • 2. Re: How to use jar files in guvnor?
    xealous Newbie

    Thank you for your quick reply. I've managed to create a custom work item and now everything works as they should except that my task doesn't complete. I also don't see any errors in the server.log.

    What could be the problem?