Meaningless Drivel is fun!*
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 Android Security Essentials Live Lessons this week in the Android 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
Author

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
Rohit,

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

Lin
[ 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
Marshal

Joined: Jul 20, 2005
Posts: 9962
    
163

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 java.io.IOException;
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();
password=nameForm.getUserPassword();
}
if ( ("".equals(name))||("".equals(password)))
{
target = new String("invalid");
}
else
{
try
{

String initialContextFactory =
"weblogic.jndi.WLInitialContextFactory";
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);
if(ctx==null)
throw new Exception("Failed to load ctx");
else
{
System.out.println("Success loading ctx");
Hashtable hash=ctx.getEnvironment();
System.out.println(hash);
}

Object obj = ctx.lookup("ejb.UserVerificationRemoteHome");
UserVerificationHome tsh = (UserVerificationHome) PortableRemoteObject.narrow(obj,UserVerification.class);
UserVerificationRemote uvr=tsh.create();
if(uvr.verifyUser(name,password))
target="invalid";
}
catch(Exception e)
{
e.printStackTrace();
}
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?

Thanks

Lin
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(LoginAction.java:72)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: weblogic.jndi.T3InitialContextFactory
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1340)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1189)
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
Bartender

Joined: Oct 29, 2001
Posts: 8843
    
    7

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.


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
sai nath
Greenhorn

Joined: Sep 16, 2012
Posts: 4
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
 
jQuery in Action, 2nd edition
 
subject: Remote Home lookup from tomcat 5.0 to Weblogic 8.1
 
Similar Threads
Unable to load home class
How to lookup Remote home from Tomcat 5.0 to Weblogic 8.1 SP4
calling weblogic EJBs from Tomcat JSP
register mbeans in weblogib 8.1
Weblogic 8.1