6 Replies Latest reply on Sep 30, 2005 1:42 AM by martinganserer

    Test local interface

    martinganserer

      Hello,

      I created a simple entity bean and a session bean that works as a DAO for this entity bean.
      I made a small test app in eclipse. When I use the remote interface of my DAO everything works fine. But when I switch to the local interface I get an error like this:

      Exception in thread "main" java.lang.ClassCastException: javax.naming.Reference
       at org.jboss.ejb3.LocalProxy.readObject(LocalProxy.java:50)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
       at java.lang.reflect.Method.invoke(Unknown Source)
       at java.io.ObjectStreamClass.invokeReadObject(Unknown Source)
       at java.io.ObjectInputStream.readSerialData(Unknown Source)
       at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
       at java.io.ObjectInputStream.readObject0(Unknown Source)
       at java.io.ObjectInputStream.defaultReadFields(Unknown Source)
       at java.io.ObjectInputStream.readSerialData(Unknown Source)
       at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
       at java.io.ObjectInputStream.readObject0(Unknown Source)
       at java.io.ObjectInputStream.readObject(Unknown Source)
       at java.rmi.MarshalledObject.get(Unknown Source)
       at org.jnp.interfaces.MarshalledValuePair.get(MarshalledValuePair.java:57)
       at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:637)
       at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:572)
       at javax.naming.InitialContext.lookup(Unknown Source)
       at com.kontron.fc.test.Client.main(Client.java:56)
      


      My test app looks like this:

      // Get data access object!
      CustomerDAO customerDAO = (CustomerDAO) ctx.lookup(CustomerDAO.class.getName());


      Can I use the remote interface only when I test my app by this approach?
      I don't have to mention that client test app and JBOSS are running on the same machine!

        • 1. Re: Test local interface
          kabirkhan

          If your client runs in a different vm from the ejb container you need to use Remote interfaces

          • 2. Re: Test local interface
            martinganserer

            Hello Kabir,

            I checked my project settings. But the vm of jboss and the one of my app are the same!

            Do you have any idea what else could be wrong?

            • 3. Re: Test local interface
              kabirkhan

              I could be wrong, but to me it looks like you are running a standalone client? In which case there will be a separate vm for your client and for jboss whether you run both from whithin Eclipse or not

              • 4. Re: Test local interface
                martinganserer

                Hello,

                you're right. It is a standalone client. It has a main method. But does that mean that both applications are on the same vm but are remote to each other? What could I do to run my standalone app in the VM of the app server? How else should I test my local interfaces if I don't have any chance with a small test software??

                • 5. Re: Test local interface
                  kabirkhan

                  Main client + app running in jboss = 2 vms :-)

                  One way to test your application would be to deploy an additional bean with a remote interface, calling the local interfaces you want to test. Another to create an MBean that calls the local interfaces. Alternatively you may want to look at using embedded EJB 3 during your testing cycles.

                  • 6. Re: Test local interface
                    martinganserer

                    OK,

                    I think it will use a second entity bean!

                    But one further question only to be sure about that point:
                    If I run my application on JBOSS and use Servlets as client, I will be able to use the local interface, won't I?