File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes EJB and other Java EE Technologies and the fly likes Remote Home lookup from tomcat 5.0 to Weblogic 8.1 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Remote Home lookup from tomcat 5.0 to Weblogic 8.1" Watch "Remote Home lookup from tomcat 5.0 to Weblogic 8.1" New topic

Remote Home lookup from tomcat 5.0 to Weblogic 8.1

Rohit Suman
Ranch Hand

Joined: Sep 09, 2006
Posts: 37
Hi all,
can any body tell me the complete procedure to do jndi lookup from tomcat web server to Weblogic 8.1 SP 4. I will be very thankful for the person how can help me
Rohit Suman
Lin Feng
Ranch Hand

Joined: Dec 11, 2002
Posts: 142

I do not have a step by step prodecure for you. Basically you will do two things
1) Put the necessary classes such as Remote interface , Home interface to the class path of Tomcat
2) Point your Context to the weblogic server.

Hope this help

[ September 11, 2006: Message edited by: Lin Feng ]
Rohit Suman
Ranch Hand

Joined: Sep 09, 2006
Posts: 37
thanks Lin
i have tried all these steps the main problem i am facing is that i am not able to get context to webloigc. I have done mine best to solve this problem but wasn't able to. One of mine friend adviced me to check javaranch and post the problem in this site so i posted it but still i have not got the answer
Jaikiran Pai

Joined: Jul 20, 2005
Posts: 10441

Post the code that you are using while doing the lookup

[My Blog] [JavaRanch Journal]
Rohit Suman
Ranch Hand

Joined: Sep 09, 2006
Posts: 37
package beans.login;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import weblogic.jndi.WLInitialContextFactory;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.rmi.PortableRemoteObject;
import user.verification.*;
import java.util.Properties;
import java.util.Hashtable;
public class LoginAction extends Action {
public ActionForward execute(ActionMapping mapping, ActionForm form1,
HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
String target = new String("valid");
String name=null;
String password=null;
LoginForm form=(LoginForm)form1;
if ( form != null )
LoginForm nameForm = (LoginForm)form;
name = nameForm.getUserName();
if ( ("".equals(name))||("".equals(password)))
target = new String("invalid");

String initialContextFactory =
String localContextURL = "t3://localhost:7001";
Properties p = new Properties();
p.put( Context.INITIAL_CONTEXT_FACTORY, initialContextFactory );
p.put( Context.PROVIDER_URL, localContextURL );
Context ctx = new InitialContext(p);
throw new Exception("Failed to load ctx");
System.out.println("Success loading ctx");
Hashtable hash=ctx.getEnvironment();

Object obj = ctx.lookup("ejb.UserVerificationRemoteHome");
UserVerificationHome tsh = (UserVerificationHome) PortableRemoteObject.narrow(obj,UserVerification.class);
UserVerificationRemote uvr=tsh.create();
catch(Exception e)
request.setAttribute("UserName", name);
return (mapping.findForward(target));
/* I have added the weblogic.jar file also but there used to be some Servlet Specification violation issue after that i unziped the the jar file and removed the javax\servlet from the weblogic and made the jar file after the servlet violation issue was resolved.
Lin Feng
Ranch Hand

Joined: Dec 11, 2002
Posts: 142
Can you set username/password when you create the Context?


Rohit Suman
Ranch Hand

Joined: Sep 09, 2006
Posts: 37
No the stack trace being printed in tomcat is as follows
javax.naming.NoInitialContextException: Cannot instantiate class: weblogic.jndi.T3InitialContextFactory [Root exception is java.lang.ClassNotFoundException: weblogic.jndi.T3InitialContextFactory]
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 beans.login.LoginAction.execute(
at org.apache.struts.action.RequestProcessor.processActionPerform(
at org.apache.struts.action.RequestProcessor.process(
at org.apache.struts.action.ActionServlet.process(
at org.apache.struts.action.ActionServlet.doPost(
at javax.servlet.http.HttpServlet.service(
at javax.servlet.http.HttpServlet.service(
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
at org.apache.catalina.core.ApplicationFilterChain.doFilter(
at org.apache.catalina.core.StandardWrapperValve.invoke(
at org.apache.catalina.core.StandardValveContext.invokeNext(
at org.apache.catalina.core.StandardPipeline.invoke(
at org.apache.catalina.core.StandardContextValve.invokeInternal(
at org.apache.catalina.core.StandardContextValve.invoke(
at org.apache.catalina.core.StandardValveContext.invokeNext(
at org.apache.catalina.core.StandardPipeline.invoke(
at org.apache.catalina.core.StandardHostValve.invoke(
at org.apache.catalina.core.StandardValveContext.invokeNext(
at org.apache.catalina.valves.ErrorReportValve.invoke(
at org.apache.catalina.core.StandardValveContext.invokeNext(
at org.apache.catalina.core.StandardPipeline.invoke(
at org.apache.catalina.core.StandardEngineValve.invoke(
at org.apache.catalina.core.StandardValveContext.invokeNext(
at org.apache.catalina.core.StandardPipeline.invoke(
at org.apache.catalina.core.ContainerBase.invoke(
at org.apache.coyote.tomcat5.CoyoteAdapter.service(
at org.apache.coyote.http11.Http11Processor.process(
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(
at org.apache.tomcat.util.threads.ThreadPool$
at Source)
Caused by: java.lang.ClassNotFoundException: weblogic.jndi.T3InitialContextFactory
at org.apache.catalina.loader.WebappClassLoader.loadClass(
at org.apache.catalina.loader.WebappClassLoader.loadClass(
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at com.sun.naming.internal.VersionHelper12.loadClass(Unknown Source)
... 35 more
Joe Ess

Joined: Oct 29, 2001
Posts: 9191

The stack trace tells you exactly what your problem is:

You configure the initial context factory in your code on this line:

You either have to use a class Tomcat provides (I don't know that there is one) or include Weblogic's class in your Tomcat web application.

[How To Ask Questions On JavaRanch]
sai nath

Joined: Sep 16, 2012
Posts: 6
i m try to run struts in tomcat and ejb 3 in weblogin server. but i m unable to run the program in tomcat Initialcontext not reading the weblogic properties.
Initialcontext not creading any object for lookup. please help me
I agree. Here's the link:
subject: Remote Home lookup from tomcat 5.0 to Weblogic 8.1
It's not a secret anymore!