First, if the servlet and ejb are in the same application, you don't need to
use properties to initialize your context....but if you did, it looks like
you left off the domain in the properties.

Regards,

the elephantwalker


-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]On Behalf Of Prashant
Gaikwad
Sent: Tuesday, September 11, 2001 3:27 AM
To: Orion-Interest
Subject: Calling EJB From a Servlet..


HI Friends,
            I'm having a serious problem in my code and am unable to
understand. I've deployed a simple Hello bean on the orion container and
want to access it from a servlet. I have the servlet in
D:\Oracle\iSuites\j2ee\home\default-web-app\WEB-INF\classes\trg\HelloServlet
. Following is the code in servlet

 try {

                        trace("In Try");
                        Hashtable h = new Hashtable();

h.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY,"com.evermind.server.rmi.
RMIInitialContextFactory");
                        h.put(javax.naming.Context.SECURITY_PRINCIPAL,
"ejb");
                        h.put(javax.naming.Context.SECURITY_CREDENTIALS,
"ejbadmin");

h.put(javax.naming.Context.PROVIDER_URL,"ormi://localhost/Hello");
                        trace("Before Init Contect ");
                        Context context = new InitialContext (h);
                        trace("after Initial context");
                            Object boundObject =
context.lookup("java:comp/env/ejb/HelloHome");
                             trace("At Trap");
                           helloHome = (HelloHome)
javax.rmi.PortableRemoteObject.narrow(boundObject,HelloHome.class);
                              }
                           catch (Throwable exception) {
                                        exception.printStackTrace();

                 //System.out.println("Look up exception :" +
exception.toString());
         //throw new ServletException(
         //   "Unable to get home interface: " + exception.toString());
      }


 When I run servlet from browser I get an exception when the Context is
getting crerated as  folloew

D:\Oracle\iSuites\j2ee\home>java -jar orion.jar
Oracle9iAS (1.0.2.2) Containers for J2EE initialized
ConstructorBefore TryIn TryBefore Init Contect
java.lang.NullPointerException: d
omain was null
        at com.evermind.server.rmi.RMIServer.addNode(RMIServer.java:428)
        at
com.evermind.server.rmi.RMIServer.getConnection(RMIServer.java:497)
        at
com.evermind.server.rmi.RMIInitialContextFactory.getInitialContext(RM
IInitialContextFactory.java:150)
        at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
        at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
        at javax.naming.InitialContext.init(Unknown Source)
        at javax.naming.InitialContext.<init>(Unknown Source)
        at trg.HelloServlet.init(HelloServlet.java:49)
        at
com.evermind.server.http.HttpApplication.loadServlet(HttpApplication.
java:1580)
        at
com.evermind.server.http.HttpApplication.findServlet(HttpApplication.
java:3722)
        at
com.evermind.server.http.HttpApplication.getRequestDispatcher(HttpApp
lication.java:1995)
        at
com.evermind.server.http.HttpRequestHandler.processRequest(HttpReques
tHandler.java:444)
        at
com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.ja
va:189)
        at com.evermind.util.ThreadPoolThread.run(ThreadPoolThread.java:62)
In _hello




Please let me know where I'm going wrong.
Thanks in advance
Prashant









Reply via email to