Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

creating a WAS client.

 
Giju George
Ranch Hand
Posts: 333
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have deployed a session bean in IBM WAS 5 using the console. The JNDI Name for that bean is "Mailer". Now I am trying to create a client in eclipse trying to access the session bean. I just added a whole bunch of IBM jar files to my project. I am confused how to do a look up to that bean. I have tried different ways. Attaching my client code ..

import javax.naming.Context;
import javax.naming.InitialContext;

import com.mweb.bsd.global.util.mailer.ejb.Mailer;
import com.mweb.bsd.global.util.mailer.ejb.MailerHome;

import java.util.*;

public class WebSphereMailerClient {
static String url = "iiop://localhost:2809";
// static String url="iiop://localhost:2809/nodes/bsd-ggeorge/servers/server1";

public static void main(String args[]){
WebSphereMailerClient wClient =new WebSphereMailerClient();
try {
Context ctx = getInitialContext();
System.out.println("1..");
MailerHome home=(MailerHome)ctx.lookup("Mailer");
System.out.println("2");
Mailer mailer=home.create();
System.out.println("3");
System.out.println("..."+mailer.test("gmg"));
System.out.println("4");
} catch (Exception e) {
System.out.println("eee"+e);
}
}


public static Context getInitialContext() throws Exception {
Properties p = new Properties();


p.put(Context.INITIAL_CONTEXT_FACTORY,
"com.ibm.websphere.naming.WsnInitialContextFactory");
p.put(Context.PROVIDER_URL, url);

/*
p.put("org.omg.CORBA.ORBClass","com.ibm.rmi.iiop.ORB");
p.put("org.omg.CORBA.ORBSingletonClass","com.ibm.rmi.corba.ORBSingleton");
p.put("javax.rmi.CORBA.UtilClass","com.ibm.rmi.javax.rmi.CORBA.Util");
p.put("javax.rmi.CORBA.StubClass","com.ibm.rmi.javax.rmi.CORBA.StubDelegateImpl");
p.put("javax.rmi.CORBA.PortableRemoteObjectClass","com.ibm.rmi.javax.rmi.PortableRemoteObject");
p.put("java.naming.factory.url.pkgs","com.ibm.ws.naming");
*/

return new InitialContext(p);
}

}
 
Scott Selikoff
author
Saloon Keeper
Posts: 4014
18
Eclipse IDE Flex Google Web Toolkit
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try the WebSphere Universal Test Client and see if the name of the bean appears under the JNDI Explorer. You should see a home interface, then when create() is invoke, will produce a remote object to work with.

This will at least help you verify the JNDI is set up right before trying to access it from a client.
 
Giju George
Ranch Hand
Posts: 333
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is this test client part of the WSAD ?? I am using eclipse and xdoclet for building the ejbs and test client. Is there any other way .. ???
 
Scott Selikoff
author
Saloon Keeper
Posts: 4014
18
Eclipse IDE Flex Google Web Toolkit
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, it should have been turned on when you installed your server, and if not can be turned on via the Admin Console.

First, try this URL (port may very) and see if works:

http://localhost:9080/UTC/

Else, from the Admin Console select "Install New Application" and point it to the UTC EAR file usually found at:

[was_home]\deploytool\itp\plugins\com.ibm.etools.utc_6.0.0\IBMUTC.ear

If the file is not found here you need to re-run the WebSphere install and have it install "with samples"
[ December 01, 2005: Message edited by: Scott Selikoff ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic