3 Replies Latest reply on Oct 11, 2012 4:56 AM by guinotphil

    Need help:Class not found when run the JBPM 5.3 progress in Jboss As 7 servertt

    du feng Newbie

      I have designed a workflow process with JBPM 5.3 eclipse designer and planed to start this workflow in the session bean which was deployed in the Jboss 7.1.1 server.

      The client application use JNDI to find the session bean and invoke the methods with the interface but the Jboss server can't find the JBPM related classes "org.drools.builder.KnowledgeBuilderFactory".

      Should I add the JBPM as a extension module to Jboss server? or there is another way to configure the runtime enviorment in Jboss server to find the JBPM API class?Please give some gudiences on that. Thanks a lot.

      The following is the soruce code and the reporting error from Jboss server.

       

      //Remote interface

       

      public interface SFWorkFlowOperation {

       

                public boolean startWorkFlow(String WorkFlowBpmnName,String processID);

       

                public void setWorkFlowTimer(int timeInterval);

      }

       

      //Stateless Session Bean which use the JBPM to start the special workflow instance.

       

      import javax.ejb.Stateless;

      import javax.ejb.Remote;

      import org.drools.KnowledgeBase;

      import org.drools.builder.KnowledgeBuilder;

      import org.drools.builder.KnowledgeBuilderFactory;

      import org.drools.builder.ResourceType;

      import org.drools.io.ResourceFactory;

      import org.drools.runtime.StatefulKnowledgeSession;

       

      @Stateless

      @Remote(SFWorkFlowOperation.class)

      public class SFWorkFlowOperationBean implements SFWorkFlowOperation {

       

       

                public boolean startWorkFlow(String WorkFlowBpmnName, String processID) {

                          KnowledgeBase kbase;

                          KnowledgeBuilder kbuilder;

                          try {

                                    // load up the knowledge base

                                    kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();

                                    kbuilder.add(ResourceFactory.newClassPathResource(WorkFlowBpmnName),

                                                        ResourceType.BPMN2);

                                    kbase = kbuilder.newKnowledgeBase();

                                    StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();

                                    // start a new process instance

                                    ksession.startProcess(processID);

                          } catch (Exception e) {

                                    e.printStackTrace();

                                    return false;

                          }

                          return true;

                }

       

                public void setWorkFlowTimer(int timeInterval){

                          System.out.println("Set Timer Successfully!"+timeInterval);

                }

      }

       

      //After deployed in the standalone Jboss server ,test main function to use the JNDI to look up the SFWorkFlowOperationBean to start the workflow

      //There will be a error:

       

      public class WorkFlowMain {

                public static final void main(String[] args) throws Exception {

                          final String BPMNNAME = "ImageFormatConversion.bpmn";

                          final String PROCESSID = "com.astrium.sfv01.imageconversion";

       

                          final String INIT_FACTORY = "org.jboss.naming.remote.client.InitialContextFactory";

                          final String SERVER_URL = "remote://localhost:4447";

                          final String USERNAME = "dufeng";// Application Realm Authorization should be added user with adduser.sh

                          final String PASSWORD = "dufeng82";

                          Context context = null;

                          try {

                                    Properties envset = new Properties();

                                    envset.put(Context.INITIAL_CONTEXT_FACTORY, INIT_FACTORY);

                                    envset.put(Context.PROVIDER_URL, SERVER_URL);

                                    envset.put(Context.SECURITY_PRINCIPAL, USERNAME);

                                    envset.put(Context.SECURITY_CREDENTIALS, PASSWORD);

                                    envset.put("jboss.naming.client.ejb.context", true);

                                    context = new InitialContext(envset);

                          } catch (NamingException e) {

                                    e.printStackTrace();

                          }

                          SFWorkFlowOperation workflow = (SFWorkFlowOperation) context

                                              .lookup("SFWorkFlow/SFWorkFlowOperationBean!com.astrium.sfv01.wamf.SFWorkFlowOperation");

                          workflow.startWorkFlow(BPMNNAME, PROCESSID);

                }

      }

       

      //Jboss error reporting:

       

      Exception in thread "main" javax.ejb.EJBException: Unexpected Error

                at org.jboss.as.ejb3.tx.CMTTxInterceptor.handleExceptionInOurTx(CMTTxInterceptor.java:163)

                at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:230)

                at org.jboss.as.ejb3.tx.CMTTxInterceptor.required(CMTTxInterceptor.java:304)

                at org.jboss.as.ejb3.tx.CMTTxInterceptor.processInvocation(CMTTxInterceptor.java:190)

                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

                at org.jboss.as.ejb3.remote.EJBRemoteTransactionPropagatingInterceptor.processInvocation(EJBRemoteTransactionPropagatingInterceptor.java:80)

                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

                at org.jboss.as.ejb3.component.interceptors.CurrentInvocationContextInterceptor.processInvocation(CurrentInvocationContextInterceptor.java:41)

                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

                at org.jboss.as.ejb3.component.interceptors.LoggingInterceptor.processInvocation(LoggingInterceptor.java:59)

                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

                at org.jboss.as.ee.component.NamespaceContextInterceptor.processInvocation(NamespaceContextInterceptor.java:50)

                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

                at org.jboss.as.ejb3.component.interceptors.AdditionalSetupInterceptor.processInvocation(AdditionalSetupInterceptor.java:43)

                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

                at org.jboss.as.ee.component.TCCLInterceptor.processInvocation(TCCLInterceptor.java:45)

                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

                at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)

                at org.jboss.as.ee.component.ViewService$View.invoke(ViewService.java:165)

                at org.jboss.as.ejb3.remote.protocol.versionone.MethodInvocationMessageHandler.invokeMethod(MethodInvocationMessageHandler.java:302)

                at org.jboss.as.ejb3.remote.protocol.versionone.MethodInvocationMessageHandler.access$200(MethodInvocationMessageHandler.java:64)

                at org.jboss.as.ejb3.remote.protocol.versionone.MethodInvocationMessageHandler$1.run(MethodInvocationMessageHandler.java:196)

                at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)

                at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)

                at java.util.concurrent.FutureTask.run(FutureTask.java:138)

                at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)

                at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)

                at java.lang.Thread.run(Thread.java:662)

                at org.jboss.threads.JBossThread.run(JBossThread.java:122)

                at ...asynchronous invocation...(Unknown Source)

                at org.jboss.ejb.client.remoting.InvocationExceptionResponseHandler$MethodInvocationExceptionResultProducer.getResult(InvocationExceptionResponseHandler.java:99)

                at org.jboss.ejb.client.EJBClientInvocationContext.getResult(EJBClientInvocationContext.java:270)

                at org.jboss.ejb.client.TransactionInterceptor.handleInvocationResult(TransactionInterceptor.java:47)

                at org.jboss.ejb.client.EJBClientInvocationContext.getResult(EJBClientInvocationContext.java:272)

                at org.jboss.ejb.client.ReceiverInterceptor.handleInvocationResult(ReceiverInterceptor.java:132)

                at org.jboss.ejb.client.EJBClientInvocationContext.getResult(EJBClientInvocationContext.java:260)

                at org.jboss.ejb.client.EJBClientInvocationContext.awaitResponse(EJBClientInvocationContext.java:399)

                at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:140)

                at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:121)

                at org.jboss.ejb.client.EJBInvocationHandler.invoke(EJBInvocationHandler.java:104)

                at $Proxy0.startWorkFlow(Unknown Source)

                at com.astrium.sfv01.wamf.WorkFlowMain.main(WorkFlowMain.java:46)

      Caused by: java.lang.NoClassDefFoundError: org/drools/builder/KnowledgeBuilderFactory

                at com.astrium.sfv01.impl.SFWorkFlowOperationBean.startWorkFlow(SFWorkFlowOperationBean.java:24)

                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

                at java.lang.reflect.Method.invoke(Method.java:597)

                at org.jboss.as.ee.component.ManagedReferenceMethodInterceptorFactory$ManagedReferenceMethodInterceptor.processInvocation(ManagedReferenceMethodInterceptorFactory.java:72)

                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

                at org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53)

                at org.jboss.as.ee.component.interceptors.UserInterceptorFactory$1.processInvocation(UserInterceptorFactory.java:36)

                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

                at org.jboss.as.jpa.interceptor.SBInvocationInterceptor.processInvocation(SBInvocationInterceptor.java:47)

                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

                at org.jboss.invocation.InitialInterceptor.processInvocation(InitialInterceptor.java:21)

                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

                at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)

                at org.jboss.as.ee.component.interceptors.ComponentDispatcherInterceptor.processInvocation(ComponentDispatcherInterceptor.java:53)

                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

                at org.jboss.as.ejb3.component.pool.PooledInstanceInterceptor.processInvocation(PooledInstanceInterceptor.java:51)

                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

                at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:228)

                at org.jboss.as.ejb3.tx.CMTTxInterceptor.required(CMTTxInterceptor.java:304)

                at org.jboss.as.ejb3.tx.CMTTxInterceptor.processInvocation(CMTTxInterceptor.java:190)

                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

                at org.jboss.as.ejb3.remote.EJBRemoteTransactionPropagatingInterceptor.processInvocation(EJBRemoteTransactionPropagatingInterceptor.java:80)

                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

                at org.jboss.as.ejb3.component.interceptors.CurrentInvocationContextInterceptor.processInvocation(CurrentInvocationContextInterceptor.java:41)

                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

                at org.jboss.as.ejb3.component.interceptors.LoggingInterceptor.processInvocation(LoggingInterceptor.java:59)

                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

                at org.jboss.as.ee.component.NamespaceContextInterceptor.processInvocation(NamespaceContextInterceptor.java:50)

                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

                at org.jboss.as.ejb3.component.interceptors.AdditionalSetupInterceptor.processInvocation(AdditionalSetupInterceptor.java:43)

                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

                at org.jboss.as.ee.component.TCCLInterceptor.processInvocation(TCCLInterceptor.java:45)

                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

                at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)

                at org.jboss.as.ee.component.ViewService$View.invoke(ViewService.java:165)

                at org.jboss.as.ejb3.remote.protocol.versionone.MethodInvocationMessageHandler.invokeMethod(MethodInvocationMessageHandler.java:302)

                at org.jboss.as.ejb3.remote.protocol.versionone.MethodInvocationMessageHandler.access$200(MethodInvocationMessageHandler.java:64)

                at org.jboss.as.ejb3.remote.protocol.versionone.MethodInvocationMessageHandler$1.run(MethodInvocationMessageHandler.java:196)

                at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)

                at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)

                at java.util.concurrent.FutureTask.run(FutureTask.java:138)

                at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)

                at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)

                at java.lang.Thread.run(Thread.java:662)

                at org.jboss.threads.JBossThread.run(JBossThread.java:122)

      Caused by: java.lang.ClassNotFoundException: org.drools.builder.KnowledgeBuilderFactory from [Module "deployment.SFWorkFlow.jar:main" from Service Module Loader]

                at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190)

                at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468)

                at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456)

                at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:423)

                at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)

                at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120)

                ... 47 more

      1    06/10 21:48:15,028[Remoting "config-based-naming-client-endpoint" task-1] ERROR protocol.v1.RemoteNamingStoreV1.handleEnd  - Channel end notification received, closing channel Channel ID c1a937ea (outbound) of Remoting connection 3d358f03 to localhost/127.0.0.1:4447

        • 1. Re: Need help:Class not found when run the JBPM 5.3 progress in Jboss As 7 servertt
          guinotphil Apprentice

          What can od deployment are you doing ? Looks like a JAR deployment, isn't it ?

           

          In case of a EAR/WAR deployment, I'd recommend you to add the Drools (not JBPM) jar within your WEB-INF/lib directory. But with a jar deployment, I think the best way is indeed to instlal Drools as a module.

           

          Here is the drools module definition I made for my own JBoss AS 7 installation by the way:

           

          <module xmlns="urn:jboss:module:1.1" name="org.jboss.drools">

            <resources>

                  <resource-root path="drools-decisiontables-5.0.1.jar"/>

                  <resource-root path="drools-templates-5.0.1.jar"/>

                  <resource-root path="drools-compiler-5.0.1.jar"/>

                  <resource-root path="drools-api-5.0.1.jar"/>

                  <resource-root path="drools-core-5.0.1.jar"/>

              <!-- Insert resources here -->

            </resources>

           

            <dependencies>

                              <module name="com.sun.xml.bind" services="import" />

                              <module name="javax.api" />

                              <module name="org.antlr" slot="3" />

                              <module name="org.codehaus.janino" />

                              <module name="org.codehaus.mvel" />

                              <module name="org.codehaus.xstream" />

                              <module name="org.eclipse.jdt" />

                              <module name="org.joda.time" />

                              <!-- net.sf.jxls -->

            </dependencies>

          </module>

           

          It's not perfect since I haven't managed to install the jxls dependency (I don't seems to need it for the moment).

          Also the version of antlr it needs is not the same as the one shipped with AS 7, so I installed v3 in another slot.

           

           

           

           

          xstream and mvel are needed as well, so you've got to set up new modules. xstream may need also other modules to be installed. I can give you my xstream module definition, but I can't be sure they are 100% ok.

           

           

           

           

          I don't think you need both janino and jdt at the same time. Actually the org.eclipse.jdt module use the jasper-jdt jar shipped with AS 7 (in org.jboss.as.web module).

           

           

          Hope that helps!

           

          Philippe

          • 2. Re: Need help:Class not found when run the JBPM 5.3 progress in Jboss As 7 servertt
            du feng Newbie

            Philippe.Thanks for your help.Regards to the module implements I still have some questions.

             

            1.I want to add all the jbpm-5.3.0.Final dependency jar package as two modules.So I create two modules one is org.jboss.drools and one is org.jboss.jbpm.

            For the org.jboss.drools I just want to add following three jars.Regarding to the drools-persistence-jpa-5.4.0.Final.jar how can I know its dependency jars?

            I also find in other modules folder there are many .index files(fox example jboss-ejb3-ext-api-2.0.0.jar.index) to preserve the jar detailed package informations.

            How this index file generated?

            jboss-as-7.1.1.Final/

               modules/

                  org/

                     jboss/

                        drools/

                           main/

                             module.xml

                              drools-persistence-jpa-5.4.0.Final.jar

                              drools-compiler-5.4.0.Final.jar

                              drools-core-5.4.0.Final.jar

             

             

            2.Assume that all above necessary files for drools module are in place what is the next step?

            (1)Modify the standalone.xml to add drools module information?

            (2)Add the module to the application path in jboss-deployment-structure.xml?Where should I put this file?My deployemnt is a jar not Ear or War.

            <?xml version="1.0" encoding="UTF-8"?>

            <jboss-deployment-structure>

              <deployment>

                <dependencies>

                  <module name="org.jboss.drools" />

                </dependencies>

              </deployment>

            </jboss-deployment-structure>

             

            Please give some guidance on that.

            • 3. Re: Need help:Class not found when run the JBPM 5.3 progress in Jboss As 7 servertt
              guinotphil Apprentice

              Hi,

               

              Regarding to question 1, the index is generated at server startup. You don't need to create it when creating the module.

               

              Regarding to question 2, yes add the dependecy to org.jboss.drools in the jboss-deployment-structure.xml. I think it's got to be in META-INF of the jar.

               

              Finally, about jbpm as a module, here is how I create the module. Yours can be different if you use hibernate 4..

               

               

               

              <module xmlns="urn:jboss:module:1.1" name="org.jboss.jbpm">

                <resources>

                      <resource-root path="jbpm-jpdl-3.2.11.SP2.jar"/>

                              <!-- Insert resources here -->

                      <resource-root path="seam-conf"/>

                </resources>

               

                <dependencies>

                                    <module name="org.beanshell.bsh" />

               

                                  <module name="javaee.api" />

                                  <module name="org.jboss.as.jpa.hibernate" slot="3" />

                                  <module name="org.hibernate" slot="3" />

                                  <module name="org.hibernate.validator" />

               

                                  <module name="org.apache.commons.collections" />

                            <module name="org.apache.commons.logging" />

                                  <module name="org.javassist" />

                                  <module name="org.dom4j" />

                                  <module name="org.apache.log4j" />

                                  <module name="org.antlr" />

               

                                  <module name="net.sourceforge.ehcache" />

                </dependencies>

              </module>

               

               

               

              seam-conf containes an org/jboss/seam/bpm/jbpm.pageflow.cfg.xml file to avoid class loading issue with seam's usage of jbpm:

              <pageflow-configuration>

                        <string name="jbpm.class.loader" value="context" />

                <jbpm-context />

              </pageflow-configuration>

               

              I'm not really sure you need it though...

               

               

              To figure out the dependency of a module, I actually take inspiration from the project's pom to see what libraries it need. I can also look at the sources and the import to make sure of the packages it needs. So as I said it may not be 100% accurate. So you've got to make sure to test the library within your server.