tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David Treves" <>
Subject please help me to pass that obstacle...
Date Sun, 21 Oct 2001 09:27:06 GMT

I am really tired of that trial and error games... I am trying to have the
Tomcat look for EJB object stored in JBoss application server.

I am using Tomcat  and JBoss 2.4.0.

I did the following:

1) added context parameters (the environment variables for JNDI)


2) copied all the necessary jars to the WEB-INF\lib folder

3) <ejb-ref> to the web.xml

  <description>reference to LoginBean - authenticates user's login and
returns rights level</description>

4) added the following code to the servlet:

// Set properties
Properties newProps = System.getProperties();
newProps.put ("java.naming.factory.initial",
getServletContext().getInitParameter ("java.naming.factory.initial"));
newProps.put ("java.naming.provider.url",
getServletContext().getInitParameter ("java.naming.provider.url"));
System.setProperties (newProps);
AnEJB gocha = null;

// Obtain a remote reference
try {
  InitialContext jndiContext = new InitialContext();
  Object ref = jndiContext.lookup("java:comp/ejb/AnEJBHome");
  AnEJBHome home = (AnEJBHome) PortableRemoteObject.narrow (ref,
  gocha = home.create();

catch (Exception e) {
  System.err.println ("An exception occurred while obtaining a remote
  System.err.println (e.toString());

InitialContext ctx = new InitialContext();
Object ref = ctx.lookup("java:comp/ejb/AuthHome");  //THIS LINE THROWS AN


why this lookup fails?
in the <ejb-ref> I explicitly typed that the ref-name is "ejb/AuthHome".

I know it is a small thing...

What am I missing?


View raw message