0 Replies Latest reply on Dec 2, 2005 7:29 PM by Joshua Tree

    BPEL Procecess call

    Joshua Tree Newbie

      Dear community,

      I have done a new process based on the hello BPEL process that comes with the package. My process it is working fine, ia have a two receive operations and a couple of invokes that are working fine. I could even sort out the correlation problems that i was having.
      The thing is:
      When the i test the process within the build.xml run-test target evertything works fine. But when i try to test the process from a specific java class that i have made, it does not work. The following exception is thrown.
      I use the exactly same code in the Junit test aswell as in the class file, but the last one does not work.
      This is not the first time that something like this happens. I think i had the same problem before... (cannot remember where)


      javax.naming.NameNotFoundException: comp not bound
      at org.jnp.server.NamingServer.getBinding(NamingServer.java:491)
       at org.jnp.server.NamingServer.getBinding(NamingServer.java:499)
       at org.jnp.server.NamingServer.getObject(NamingServer.java:505)
       at org.jnp.server.NamingServer.lookup(NamingServer.java:249)
       at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:610)
       at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:572)
       at javax.naming.InitialContext.lookup(InitialContext.java:351)
       at org.jbpm.bpel.tutorial.hello.OMInvoker.setUp(OMInvoker.java:130)
       at org.jbpm.bpel.tutorial.hello.OMInvoker.main(OMInvoker.java:41)
      Exception in thread "main" java.lang.NullPointerException
       at org.jbpm.bpel.tutorial.hello.OMInvoker.main(OMInvoker.java:57)
      



      Junit based test:
      public class HelloTest extends TestCase {
      
       private ROinPT greeter;
      
       public HelloTest(String name) {
       super(name);
       }
      
       protected void setUp() throws Exception {
       InitialContext ctx = getInitialContext();
       // JNDI name bound to the service interface (in application-client.xml)
       String serviceRefName = "service/Hello";
       // lookup the service interface in the environment context
       HelloWorldService service = (HelloWorldService) ctx.lookup("java:comp/env/" + serviceRefName);
       // obtain the dynamic proxy for the web service port
       greeter = service.getCallerPort();
       }
      
      
      
       public void testSayHello() throws Exception {
      
       Random rd = new Random();
      
       String id = String.valueOf(rd.nextInt());
      
      
       String greeting = greeter.initiate(id);
       //assertEquals("Hello, Popeye!", greeting);
       System.out.println("1º reply: " +greeting);
      
       Thread.sleep(10000);
      
       greeting = greeter.receiveNotification(id);
       System.out.println("2º reply: " +greeting);
       }
      
      
      
       protected InitialContext getInitialContext() throws NamingException {
      
       // JNDI name bound to the client's environment context (in jboss-client.xml)
       String envContextName = "hello-client";
       // prepare the enviroment
       Properties env = new Properties();
       env.setProperty("j2ee.clientName", envContextName);
       // the properties in env *and* jndi.properties are placed in the context's environment
       return new InitialContext(env);
      
       }
      }
      


      Stand alone class
      /**
       *
       */
      package org.jbpm.bpel.tutorial.hello;
      
      import java.rmi.RemoteException;
      import java.util.Hashtable;
      import java.util.Properties;
      import java.util.Random;
      
      import javax.naming.InitialContext;
      import javax.naming.NamingEnumeration;
      import javax.naming.NamingException;
      
      /**
       * @author Administrator
       *
       */
      public class OMInvoker {
      
       public ROinPT greeter;
      
       /**
       * @param args
       */
       public static void main(String[] args) {
       // TODO Auto-generated method stub
      
       /**
       * @author Alejandro Guízar
       * @version $Revision: 1.4 $ $Date: 2005/09/01 18:17:19 $
       */
      
       OMInvoker omi = new OMInvoker();
      
       try {
       omi.setUp();
       } catch (Exception e1) {
       // TODO Auto-generated catch block
       e1.printStackTrace();
       }
      
       Random rd = new Random();
      
       String id = String.valueOf(rd.nextInt());
      
       String greeting = null;
       try {
       greeting = omi.greeter.initiate(id);
       } catch (RemoteException e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
       }
       //assertEquals("Hello, Popeye!", greeting);
       System.out.println("1º reply: " + greeting);
      
       try {
       Thread.sleep(10000);
       } catch (InterruptedException e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
       }
      
       try {
       greeting = omi.greeter.receiveNotification(id);
       } catch (RemoteException e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
       }
       System.out.println("2º reply: " + greeting);
       }
      
       public InitialContext getInitialContext() throws NamingException {
      
       // JNDI name bound to the client's environment context (in jboss-client.xml)
       String envContextName = "hello-client";
       // prepare the enviroment
       Properties env = new Properties();
       env.setProperty("j2ee.clientName", envContextName);
       // the properties in env *and* jndi.properties are placed in the context's environment
       return new InitialContext(env);
      
       }
      
       public void setUp() throws Exception {
      
       InitialContext ctx = getInitialContext();
       // JNDI name bound to the service interface (in application-client.xml)
       String serviceRefName = "service/Hello";
       // lookup the service interface in the environment context
       HelloWorldService service = (HelloWorldService) ctx.lookup("java:comp/env/" + serviceRefName);
       // obtain the dynamic proxy for the web service port
       greeter = service.getCallerPort();
       }
      
      }