• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Remote Home lookup from tomcat 5.0 to Weblogic 8.1

 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Post the code that you are using while doing the lookup
 
Rohit Suman
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 142
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you set username/password when you create the Context?

Thanks

Lin
 
Rohit Suman
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic