You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by David Treves <dw...@macam.ac.il> on 2001/10/21 11:27:06 UTC
please help me to pass that obstacle...
Hi,
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)
<context-param>
<param-name>java.naming.factory.initial</param-name>
<param-value>org.jnp.interfaces.NamingContextFactory</param-value>
</context-param>
<context-param>
<param-name>java.naming.provider.url</param-name>
<param-value>localhost:1099</param-value>
</context-param>
2) copied all the necessary jars to the WEB-INF\lib folder
3) <ejb-ref> to the web.xml
<ejb-ref>
<description>reference to LoginBean - authenticates user's login and
returns rights level</description>
<ejb-ref-name>ejb/AuthHome</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
<home>authBean.AuthHome</home>
<remote>authBean.Auth</remote>
</ejb-ref>
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,
AnEJBHome.class);
gocha = home.create();
}
catch (Exception e) {
System.err.println ("An exception occurred while obtaining a remote
reference:");
System.err.println (e.toString());
}
InitialContext ctx = new InitialContext();
Object ref = ctx.lookup("java:comp/ejb/AuthHome"); //THIS LINE THROWS AN
ERROR
--------
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?
Thanks!
David.