Hi Robert.
 
I just create a new project with a complete new EJB and a new return class.
Can you tell me if there is something wrong on the java side?
Or is there a fundamental mistake in my way to do it?
 
 
------------------------- EJB class ---------------------------
package ELJBTest2;
 
import java.rmi.RemoteException;
import javax.ejb.*;
 
public class EJBTest2Class implements SessionBean
{
 SessionContext ctx;
 
 public EJBTest2Class()
 {
 }
 
 public void ejbCreate() throws RemoteException, CreateException
 {
 }
 
 public void ejbActivate() throws RemoteException
 {
 }
 
 public void ejbPassivate() throws RemoteException
 {
 }
 
 public void ejbRemove() throws RemoteException
 {
 }
 
 public void setSessionContext(SessionContext ctx) throws RemoteException
 {
     this.ctx = ctx;
 }
 
   public NewReturnedClass getNewReturnedClass() throws RemoteException
   {
  NewReturnedClass aNewReturnedClass = new NewReturnedClass();
      return aNewReturnedClass;
   }
}
---------------------------------------------------------------------
 
------------------------- EJB Home ---------------------------
package ELJBTest2;
 
import java.rmi.*;
import javax.ejb.*;
 
public interface EJBTest2Home extends EJBHome
{
 
 EJBTest2 create() throws java.rmi.RemoteException, javax.ejb.CreateException;
}
---------------------------------------------------------------------
 
------------------------- EJB Remote ---------------------------
package ELJBTest2;
 
import java.rmi.*;
import javax.ejb.*;
 
public interface EJBTest2 extends EJBObject
{
 
 public ELJBTest2.NewReturnedClass getNewReturnedClass() throws java.rmi.RemoteException;
}
---------------------------------------------------------------------
 
------------------------- Client ---------------------------
package  ELJBTest2;
 
import java.sql.*;
import java.util.*;
import javax.naming.*;
import oracle.aurora.jndi.sess_iiop.*;
 

public class EJB_Client {
  public static void main(String[] args) {
 
    String ejbUrl = "sess_iiop://ranger:2481:e1/test/EJBTest2";
    String username = "bayfis";
    String password = "bayfis";
 
    Hashtable environment = new Hashtable();
    environment.put(javax.naming.Context.URL_PKG_PREFIXES, "oracle.aurora.jndi");
    environment.put(Context.SECURITY_PRINCIPAL, username);
    environment.put(Context.SECURITY_CREDENTIALS, password);
    environment.put(Context.SECURITY_AUTHENTICATION, ServiceCtx.NON_SSL_LOGIN);
 
    // Lookup the URL
    ELJBTest2.EJBTest2Home homeInterface = null;
    try {
      System.out.println("Creating an initial context");
      Context ic = new InitialContext(environment);
      System.out.println("Looking for the EJB published as 'test/EJBTest2'");
      homeInterface = (ELJBTest2.EJBTest2Home) ic.lookup(ejbUrl);
    }
    catch (ActivationException e) {
      System.out.println("Unable to activate : " + e.getMessage());
      e.printStackTrace();
      System.exit(1);
    }
    catch (CommunicationException e) {
      System.out.println("Unable to connect: " + ejbUrl);
      e.printStackTrace();
      System.exit(1);
    }
    catch (NamingException e) {
      System.out.println("Exception occurred!");
      System.out.println("Cause:  This may be an unknown URL, or some" +
        " classes required by the EJB are missing from your classpath.");
      System.out.println("Suggestion:  Check the components of the URL," +
        " and make sure your project includes a library containing the" +
        " EJB .jar files generated by the deployment utility.");
      e.printStackTrace();
      System.exit(1);
    }
 
    // That's it!
    try {
      System.out.println("Creating a new EJB instance");
      ELJBTest2.EJBTest2 remoteInterface = homeInterface.create();
 
      System.out.println("Calling ELJBTest2.EJBTest2 methods...\n");
      // Method calls go here!
      NewReturnedClass aNewReturnedClass = new NewReturnedClass();
      aNewReturnedClass.aString = "foo"; // just to change the std value.
      aNewReturnedClass = remoteInterface.getNewReturnedClass(); // recieve a new
      System.out.println(aNewReturnedClass.aString); // show what is inside. if possible :-(.
      System.out.println("...done!");
    }
    catch (Exception e) {
      System.out.println(e.getMessage());
      e.printStackTrace();
    }
  }
}
---------------------------------------------------------------------
 
------------------------- ReturnedClass ---------------------------
package ELJBTest2;
 
public class NewReturnedClass extends Object
{
   public String aString = "";
 
 public NewReturnedClass()
 {
  aString = "EJB OK!!";
 }
}
---------------------------------------------------------------------
 
 
----- Original Message -----
Sent: Wednesday, May 17, 2000 10:09 AM
Subject: Re: Basic EJB problem

Hi Hinrich,
 
 
Not too sure on the Oracle side, but maybe on the VisiBroker side....
 
When you receive a org.omg.CORBA.UNKNOWN it means that an exception was thrown that is not defined in the CORBA spec, which when using Java is often (although not always) a NullPointerException. So I would try looking at the parameters and types that are being marshalled over the wire and check that they are not null. From memory -per CORBA standard, you should also return empty strings "" , not nulls when wanting to return a "Null" type string.
 
regards,
 
-Robert
 
----- Original Message -----
Sent: Wednesday, May 17, 2000 4:57 PM
Subject: Basic EJB problem

I start with EJB some days ago.
I am using JDeveloper 3.0 and Oracle 8i (8.1.6)
 
My special interest goes to stateless session beans.
Everything works fine with my tests.
But I just have primitive types or String as return values.
 
Now I add a new Serializable class with some public members.
This class should now be returned from an EJB call.
 
Looking up the EJB and creating a new instance works.
But if I try to call the new method, the following exception occurs.
What is wrong?
Why does it works with primitives and with objects it doesn't?
 
----------------------------------------------------------------
::: org.omg.CORBA.UNKNOWN
::::A non CORBA exception is caught by the ORB runtime on the server:::::::
null
org.omg.CORBA.UNKNOWN[minor=16, completed=MAYBE]
 at com.visigenic.vbroker.orb.SE.read(Compiled Code)
 at com.visigenic.vbroker.orb.GiopStubDelegate.invoke(Compiled Code)
 at com.visigenic.vbroker.orb.GiopStubDelegate.invoke(Compiled Code)
 at org.omg.CORBA.portable.ObjectImpl._invoke(Compiled Code)
 at ejbtest1._st_EJB1Remote.getSomething(Compiled Code)
 at ejbtest1.MyEJBJSClient.main(Compiled Code)
----------------------------------------------------------------

 

Reply via email to