Hello.

I know it has been mentioned in serveral times. 
However, I could not make Orion as EJB server work with Apache & Tomcat.
A servlet is placed to access ejb at tomcat's WEB-INF/classes directory, 
along with application-client.xml under META-INF directory. 

The servlet looks as follows:

import java.io.IOException;
import java.util.Date;
import java.util.*;
import java.util.Properties;
import javax.naming.*;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.rmi.PortableRemoteObject;

import hello.ejb.Hello;
import hello.ejb.HelloHome;

public class HelloServlet extends HttpServlet {

   // constructor
   public HelloServlet() {
      super();
      trace("<init>");
   }

   // A reference to the remote `Hello' object
   protected Hello _hello;

   // Initializes this servlet
   public void init(ServletConfig config) throws ServletException {
      super.init(config);
      trace("init");

                Hashtable env = new Hashtable();
                env.put("java.naming.factory.initial",
"com.evermind.server.ApplicationClientInitialContextFactory");
                env.put("java.naming.provider.url",
"ormi://localhost:800/hello-planet");
                env.put("java.naming.security.principal", "admin");
                env.put("java.naming.security.credentials", "admin");

      // Get the initial JNDI context using our settings
      Context initial;
      try {
         initial = new InitialContext(env);
      }
      catch (Throwable exception) {
         throw new ServletException(
            "Unable to get initial JNDI context: " +
exception.toString());
      }

      // Get a reference to the Hello home interface
      HelloHome helloHome;
      try {
                    Object objref = initial.lookup("ejb/Hello");
                    helloHome = (HelloHome)PortableRemoteObject.narrow(objref,
HelloHome.class);
      }
      catch (Throwable exception) {
         throw new ServletException(
            "Unable to get home interface: " + exception.toString());
      }

      // Get a reference to a Hello instance
      try {
         _hello = helloHome.create();
      }
      catch (Throwable exception) {
         throw new ServletException(
            "Unable to create Hello instance: " + exception.toString());
      }

      // Insanity check: Make sure we have a valid reference
      if (_hello == null) {
         throw new ServletException(
            "Unable to create Hello instance, create() returned null");
      }
   }

   // Handles the HTTP GET request
   public void doGet(HttpServletRequest request, HttpServletResponse
response)
   throws ServletException, IOException {
      trace("doGet");

      ServletOutputStream out = response.getOutputStream();

      response.setContentType("text/html");

      // Get the answer from the bean
      String answer;
      try {
         answer = _hello.sayHello();
      }
      catch (Throwable exception) {
         out.println("<HTML><BODY bgcolor=\"#FFFFFF\">");
         out.println("Time stamp: " + new Date().toString());
         out.println("<BR>Hello type: " + _hello.getClass().getName());
         out.println("Error calling the Hello bean");
         out.println(exception.toString());
         out.println("</BODY>");
         out.println("</HTML>");
         return;
      }

      out.println("<HTML><BODY bgcolor=\"#FFFFFF\">");
      out.println("Time stamp: " + new Date().toString());
      out.println("<BR>Hello type: " + _hello.getClass().getName());
      out.println("<BR>Answer: " + answer);
      out.println("</BODY>");
      out.println("</HTML>");
   }

   // Displays a trace message to System.out
   private void trace(String methodName) {
      System.out.print(methodName);
      System.out.println("() called");
   }

}

However, when I call this servlet from Apache, it complains as follows:

javax.servlet.ServletException: Unable to get initial JNDI context:
javax.naming.NamingException: Error reading application-client
descriptor: Error communicating with server: Lookup error:
java.net.ConnectException: Connection refused; nested exception is: 
        java.net.ConnectException: Connection refused; nested exception is: 
        javax.naming.NamingException: Lookup error: java.net.ConnectException:
Connection refused; nested exception is: 
        java.net.ConnectException: Connection refused
        at java.lang.Throwable.fillInStackTrace(Native Method)
        at java.lang.Throwable.fillInStackTrace(Compiled Code)
        at java.lang.Throwable.(Compiled Code)
        at java.lang.Exception.(Compiled Code)
        at javax.servlet.ServletException.(Compiled Code)
        at HelloServlet.init(Compiled Code)
        at org.apache.tomcat.core.ServletWrapper.doInit(Compiled Code)
        at org.apache.tomcat.core.Handler.init(Compiled Code)
        at org.apache.tomcat.core.ServletWrapper.init(Compiled Code)
        at org.apache.tomcat.core.Handler.service(Compiled Code)
        at org.apache.tomcat.core.ServletWrapper.service(Compiled Code)
        at org.apache.tomcat.core.ContextManager.internalService(Compiled Code)
        at org.apache.tomcat.core.ContextManager.service(Compiled Code)
        at
org.apache.tomcat.service.connector.Ajp12ConnectionHandler.processConnection(Compiled
Code)
        at org.apache.tomcat.service.TcpWorkerThread.runIt(Compiled Code)
        at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(Compiled Code)
        at java.lang.Thread.run(Compiled Code)

Again, application-client.xml file is at under tomcat's
webapps/WEB-INF/META-INF dir.
I tried putting META-INF/application-client.xml file in the webapps dir,
which resulted in the same error.
Does anybody have an insight on this?
Thanks in advance.



 

-- 
JangHo Ki
R&D Developer
Crunchy Technologies
-----------------------------
2111 wilson blvd, suite 350
Arlington, VA 22201
-----------------------------
Work:703.469.2040
Cell:240.606.8865
Fax :703.243.7045

Reply via email to