0 Replies Latest reply on Sep 27, 2005 7:16 AM by Yves Van Walle

    Deploy application using interfaces

    Yves Van Walle Newbie

      Hello,

      I want to deploy an application on a JBOSS server using templates. I created 2 interfaces for each class, one with the object and one to get objects/ make them persistent.

      public interface InvestigatorDAO {
      public Investigator find(long id) throws Exception ;
      public Investigator getCurInvestigator();
      public void makePersistent(Investigator invsetigator);
      public void checkout();
      }

      public interface Investigator {
      public long getId();
      ?
      }

      On the server, I made an implementation for each interface. They work properly; I can see the info printed in these beans.

      @Stateful
      @Remote(InvestigatorDAO.class)
      public class InvestigatorsDAOBean implements InvestigatorDAO, Serializable {
      ?
      private Investigator curInv;
      @PersistenceContext
      private EntityManager manager; // persistence context is injected

      /*
      * get an investigator for a specific id
      */
      public Investigator find(long id) throws Exception {
      System.out.println("Search for investigator...");
      curInv = (Investigator)manager.find(InvestigatorBean.class, id);
      System.out.println("Investigator " + curInv.getFirstname() + " " + curInv.getLastname() + " found");
      return curInv;
      }
      ?
      }

      On the client site, I don?t have those beans; I just used the interfaces to connect. If I run this application below, the client will connect to the server (output?) but I always get an ?ClassNotFoundException? (see below) I know the client don?t know any ?InvestigatorBean?, but he knows about an investigator, and this is the object I return.

      public class Client
      {
      public static void main(String[] args) throws Exception {
      InitialContext ctx = new InitialContext();

      InvestigatorDAO dao = (InvestigatorDAO) ctx.lookup(InvestigatorDAO.class.getName());

      System.out.println("Getting entity bean with id = 142...");
      //Investigator inv = (Investigator) ctx.lookup(Investigator.class.getName());
      Investigator inv = (Investigator)dao.find(142L);
      ?..
      dao.checkout();

      }
      }

      I get the error below on the command: ?Investigator inv = (Investigator)dao.find(142L);?

      [java] ERROR 27-09 12:49:29,951 (SocketClientInvoker.java:transport:258) -Got marshalling exception, exiting
      [java] java.lang.ClassNotFoundException: be.barc.tests.liststudies.bean.investigator.InvestigatorBean
      [java] at java.net.URLClassLoader$1.run(Unknown Source)
      [java] at java.security.AccessController.doPrivileged(Native Method)
      [java] at java.net.URLClassLoader.findClass(Unknown Source)
      [java] at java.lang.ClassLoader.loadClass(Unknown Source)
      [java] at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
      [java] at java.lang.ClassLoader.loadClass(Unknown Source)
      [java] at java.lang.ClassLoader.loadClassInternal(Unknown Source)
      [java] at java.lang.Class.forName0(Native Method)
      [java] at java.lang.Class.forName(Unknown Source)
      [java] at java.io.ObjectInputStream.resolveClass(Unknown Source)
      [java] at org.jboss.remoting.loading.ObjectInputStreamWithClassLoader.resolveClass(ObjectInputStreamWithClassLoader.java:102)
      [java] at java.io.ObjectInputStream.readNonProxyDesc(Unknown Source)
      [java] at java.io.ObjectInputStream.readClassDesc(Unknown Source)
      [java] at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
      [java] at java.io.ObjectInputStream.readObject0(Unknown Source)
      [java] at java.io.ObjectInputStream.readObject(Unknown Source)
      [java] at org.jboss.aop.joinpoint.InvocationResponse.readExternal(InvocationResponse.java:107)
      [java] at java.io.ObjectInputStream.readExternalData(Unknown Source)
      [java] at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
      [java] at java.io.ObjectInputStream.readObject0(Unknown Source)
      [java] at java.io.ObjectInputStream.defaultReadFields(Unknown Source)
      [java] at java.io.ObjectInputStream.readSerialData(Unknown Source)
      [java] at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
      [java] at java.io.ObjectInputStream.readObject0(Unknown Source)
      [java] at java.io.ObjectInputStream.readObject(Unknown Source)
      [java] at org.jboss.remoting.marshal.serializable.SerializableUnMarshaller.read(SerializableUnMarshaller.java:72)
      [java] at org.jboss.remoting.transport.socket.SocketClientInvoker.transport(SocketClientInvoker.java:244)
      [java] at org.jboss.remoting.RemoteClientInvoker.invoke(RemoteClientInvoker.java:117)
      [java] at org.jboss.remoting.Client.invoke(Client.java:201)
      [java] at org.jboss.aspects.remoting.InvokeRemoteInterceptor.invoke(InvokeRemoteInterceptor.java:41)
      [java] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
      [java] at org.jboss.aspects.tx.ClientTxPropagationInterceptor.invoke(ClientTxPropagationInterceptor.java:46)
      [java] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
      [java] at org.jboss.aspects.security.SecurityClientInterceptor.invoke(SecurityClientInterceptor.java:40)
      [java] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
      [java] at org.jboss.ejb3.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:41)
      [java] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
      [java] at org.jboss.ejb3.stateful.StatefulRemoteProxy.invoke(StatefulRemoteProxy.java:119)
      [java] at $Proxy1.find(Unknown Source)
      [java] at be.barc.tests.liststudies.client.Client.main(Client.java:34)