aspose file tools*
The moose likes Websphere and the fly likes creating a WAS client. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Websphere
Bookmark "creating a WAS client." Watch "creating a WAS client." New topic
Author

creating a WAS client.

Giju George
Ranch Hand

Joined: Jun 08, 2004
Posts: 333
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

Joined: Oct 23, 2005
Posts: 3716
    
    5

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.


My Blog: Down Home Country Coding with Scott Selikoff
Giju George
Ranch Hand

Joined: Jun 08, 2004
Posts: 333
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

Joined: Oct 23, 2005
Posts: 3716
    
    5

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 ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: creating a WAS client.