You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Nagaraj <na...@yahoo.com> on 2000/07/29 16:21:43 UTC
not able to get connection to ejb.
hi guys,
we are trying to access methods in EJB's which are
deployed in Oracle 8i server release2/winnt from a
servlet which is on redhat
linux6.2/apache1.3.x/tomcat3.1 servlet engine.
we have deployed EJB's in Oracle 8ir2 with the help of
Oracle jdeveloper and we have also written a servlet
in Oracle jdeveloper which is perfectly interacting
with EJB's in oracle 8i.this can be tested from oracle
jdeveloper since it has an inbuilt web server.it
automatically makes use of some zip/jar files that are
needed for the servlet to access EJB's.
so we copied all the necessary zip/jar files into
tomcat/webapps/examples/WEB-INF/lib directory and also
set the classpath in the tomcat.bat.we are getting an
exception called CommuncationException when we run the
servlet from remote machine.the servlet is getting
invoked, we could get other out.println's but not from
EJB.
Here is the code:
========================================================
package package1;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
import javax.naming.*;
import oracle.aurora.jndi.sess_iiop.*;
import oracle.aurora.jndi.*;
import oracle.aurora.*;
import oracle.*;
public class ServletClient extends HttpServlet {
/**
* Initialize global variables
*/
public void init(ServletConfig config) throws
ServletException {
super.init(config);
}
/**
* Service the request
*/
public void service(HttpServletRequest request,
HttpServletResponse response) throws ServletException,
IOException {
String ejbUrl =
"sess_iiop://192.0.0.109:2481:ssoft/test/MyEJB";
String username = "bmeth";
String password = "bmeth";
String result="Thats it!! ";
// Setup the environment
Hashtable environment = new Hashtable();
// Tell JNDI to speak sess_iiop
environment.put(javax.naming.Context.URL_PKG_PREFIXES,
"oracle.aurora.jndi");
// Tell sess_iiop who the user is
environment.put(Context.SECURITY_PRINCIPAL,
username);
// Tell sess_iiop what the password is
environment.put(Context.SECURITY_CREDENTIALS,
password);
// Tell sess_iiop to use credential authentication
environment.put(Context.SECURITY_AUTHENTICATION,
ServiceCtx.NON_SSL_LOGIN);
// Lookup the URL
MyEJBHome homeInterface = null;
MyEJB remoteInterface = null;
try {
System.out.println("Creating an initial
context");
Context ic = new InitialContext(environment);
System.out.println("Looking for the EJB
published as 'test/MyEJB'");
System.out.println(ejbUrl);
homeInterface = (MyEJBHome) ic.lookup(ejbUrl);
}
catch (NotContextException e) {
System.out.println("Unable to connect: " +
ejbUrl);
e.printStackTrace();
}
catch (ActivationException e) {
System.out.println("Unable to activate : " +
e.getMessage());
e.printStackTrace();
}
catch (CommunicationException e) {
System.out.println("Unable to connect: " +
ejbUrl);
e.printStackTrace();
}
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();
}
// That's it!
try {
System.out.println("Creating a new EJB
instance");
remoteInterface = homeInterface.create();
result=result+remoteInterface.sayHello();
System.out.println("Calling MyEJB
methods...\n");
// Method calls go here!
// e.g.
System.out.println(result);
System.out.println("...done!");
remoteInterface.remove();
remoteInterface = null;
}
catch (Exception e) {
System.out.println(e.getMessage());
e.printStackTrace();
}
response.setContentType("text/html");
PrintWriter out = new
PrintWriter(response.getOutputStream());
out.println("<html>");
out.println("<body>");
out.println("<h1>"+result);
out.println("</h1>");
out.println("</body>");
out.println("</html>");
out.close();
}
/**
* Get Servlet information
* @return java.lang.String
*/
public String getServletInfo() {
return "package1.ServletClient Information";
}
}
===========================================
when we run this,it is just desplaying the string
"THAT'S IT".It is not connecting to EJB.
please advice....
thanks-in-advance
nag
=====
nagaraj.p
E-16,
madhura nagar,
opp KK towers
yosufguda,
Hyderabad
ph:3317655(O)
__________________________________________________
Do You Yahoo!?
Kick off your party with Yahoo! Invites.
http://invites.yahoo.com/